dadra package¶
Subpackages¶
dadra.disturbance module¶
dadra.dyn_sys module¶
- class dadra.dyn_sys.DisturbedSystem(dyn_func, intervals, state_dim, disturbance: dadra.disturbance.Disturbance, timesteps=100, parts=1001, all_time=False)[source]¶
Bases:
dadra.dyn_sys.System
- sample_system(N)[source]¶
Draws
N
samples from the specified system- Parameters
N (int) – The number of samples to be drawn
- Returns
Array of
N
samples- Return type
numpy.ndarray
- system_sampler(x=None)[source]¶
Obtains sample from specified system with disturbance
- Parameters
x (NoneType, optional) – Placeholder variable over which to evaluate, defaults to None
- Returns
The sample from the specified system at the last timestep if the
all_time
is False and including all timesteps otherwise
- class dadra.dyn_sys.Sampler(sample_fn, state_dim, timesteps, parts, all_time)[source]¶
Bases:
dadra.dyn_sys.System
class implementation of a dynamical system with a means of sampling the system specified by the user
- Parameters
sample_fn (function) – A function to sample from
state_dim (int) – The degrees of freedom of the system
timesteps (int, optional) – The number of timesteps over which to compute the sample, defaults to 100
parts (int, optional) – The number of parts to partition the time interval into for computing the sample, defaults to 1001
all_time (bool, optional) – If True, each sample will include all timesteps from the system, rather than only the last timestep, defaults to False
- class dadra.dyn_sys.SimpleSystem(dyn_func, intervals, state_dim, timesteps=100, parts=1001, all_time=False)[source]¶
Bases:
dadra.dyn_sys.System
Class implementation of a dynamical system that allows for parallelized sampling.
- Parameters
dyn_func (function) – The function defining the dynamics of the system
intervals (list) – The intervals corresponding to the possible values of the initial states of the variables in the system
state_dim (int) – The degrees of freedom of the system
timesteps (int, optional) – The number of timesteps over which to compute the sample, defaults to 100
parts (int, optional) – The number of parts to partition the time interval into for computing the sample, defaults to 1001
all_time (bool, optional) – If True, each sample will include all timesteps from the system, rather than only the last timestep, defaults to False
- static dyn_to_sys(arr, t, func_list, *args)[source]¶
Static method which allows for defining the dynamics of a system from an initial state, the time, and a list of functions for each dimension
- Parameters
arr (numpy.ndarray) – Array input, corresponding to the initial state
t (float) – The time
func_list (list) – A list of functions, one for each dimension
- Returns
The functional dynamics of the system
- Return type
list
- classmethod from_list(func_list, intervals, timesteps=100, parts=1001, all_time=False)[source]¶
Class method that allows for an instance of
dadra.DynamicSystem
to be initialized using a list of functions, one for each variable, to define the dynamics of a system rather than a single function- Parameters
func_list (list) – The list of functions, one for each variable, that define the dynamics of the system
intervals (list) – The intervals corresponding to the possible values of the initial states of the variables in the system
timesteps (int, optional) – The number of timesteps over which to compute the sample, defaults to 100
parts (int, optional) – The number of parts to partition the time interval into for computing the sample, defaults to 1001
all_time (bool, optional) – If True, each sample will include all timesteps from the system, rather than only the last timestep, defaults to False
- Raises
TypeError – If not all functions in
func_list
are callableValueError – If not all functions in
func_list
include parameters for the intial state and timeValueError – If not all functions in
func_list
include parameters for the intial state, time, and the provided additional arguments
- Returns
A
dadra.DynamicSystem
object- Return type
dadra.DynamicSystem
- sample_system(N)[source]¶
Draws
N
samples from the specified system- Parameters
N (int) – The number of samples to be drawn
- Returns
Array of
N
samples- Return type
numpy.ndarray
- system_sampler(x=None)[source]¶
Obtains sample from specified system
- Parameters
x (NoneType, optional) – Placeholder variable over which to evaluate, defaults to None
- Returns
The sample from the specified system at the last timestep if the
all_time
is False and including all timesteps otherwise- Return type
numpy.ndarray
- class dadra.dyn_sys.System(dyn_func, state_dim, intervals)[source]¶
Bases:
object
Parent class that serves as an interface for dynamic systems objects
- Parameters
dyn_func (function) – The function defining the dynamics of the system
state_dim (int) – The degrees of freedom of the system
intervals (list) – The intervals corresponding to the possible values of the initial states of the variables in the system
- check_dyn_func()[source]¶
Checks whether the dynamic function in this instance of the
dadra.DynamicSystem
class is valid- Raises
TypeError – If the provided dynamic function is not callable
ValueError – If there is an invalid number of required arguments in the dynamic function
- check_intervals()[source]¶
Checks whether the list of intervals in this instance of the
dadra.DynamicSystem
class is valid- Raises
ValueError – If there is not an interval defined for each variable
ValueError – If not all intervals include an upper and a lower bound
ValueError – If not all intervals consist of two numbers
dadra.estimate module¶
dadra.sampling module¶
- dadra.sampling.make_sample_n(sample_fn, parallel=True, pool=None)[source]¶
Takes in a sample function and allows for parallelized sampling
- Parameters
sample_fn (function) – A function to compute samples
parallel (bool, optional) – True if parallelization is to be used to compute samples, defaults to True
pool (multiprocessing.pool.Pool, optional) – Pool to use for parallelization if specified, defaults to None