yupi.generators
This module contains different statistical models to generate trajectories given certain statistical constrains.
All the resources of this module should be imported directly
from yupi.generators.
- class DiffDiffGenerator(T, dim=1, units=None, dt=1.0, tau=1.0, sigma=1.0, dim_aux=1, bounds=None, bounds_extent=None, bounds_strength=None, r0=None, seed=None)
Random Walk class for the Diffusing Diffusivity model. Boundary conditions to model confined or semi-infinite processes are supported.
- Parameters:
T (float) – Total duration of each Trajectory.
dim (int, optional) – Dimension of each Trajectory, by default 1.
units (Units | None) – Units of the Trajectory, by default None. If None, the units are set to the default ones (i.e., m/s).
dt (float, optional) – Time step of the Trajectory, by default 1.0.
tau (float, optional) – Relaxation characteristic time of the auxiliary variable, by default 1.
sigma (float, optional) – Scale parameter of the auxiliary variable noise, by default 1.
dim_aux (int, optional) – Dimension of the auxiliary process, which is the square of the diffusivity, by default 1.
bounds (np.ndarray | None) – Lower and upper reflecting boundaries that confine the trajectories. Must have shape (2, dim). The first row contains the lower boundaries and the second row contains the upper boundaries. If None is passed, trajectories are simulated in a free space. By default None.
bounds_extent (np.ndarray | None) – Decay length of boundary forces, by default None.
bounds_strength (np.ndarray | None) – Boundaries strength, by default None.
r0 (Collection[Collection[float]] | Collection[float] | float | None) – Initial positions, by default None.
seed (int | None)
- class Generator(T, units=None, dim=1, dt=1.0, seed=None)
Abstract class to model a Trajectory Generator. Classes inheriting from this class should implement
generatemethod.- Parameters:
T (float) – Total duration of each Trajectory.
dim (int, optional) – Dimension of each Trajectory, by default 1.
units (Units | None) – Units of the Trajectory, by default None. If None, the units are set to the default ones (i.e., m/s).
dt (float, optional) – Time step of the Trajectory, by default 1.0.
seed (int, optional) – Seed for the random number generator. If None, no seed is set. By default None.
- T
Total duration of each Trajectory.
- Type:
float
- dim
Dimension of each Trajectory, by default 1.
- Type:
int, optional
- dt
Time step of the Trajectory, by default 1.0.
- Type:
float, optional
- n
Number of samples on each Trajectory.
- Type:
int
- rng
Random number generator.
- Type:
np.random.Generator
- abstract generate(N)
Abstract method that is implemented on inheriting classes. It should compute a list of
NTrajectory objects with the given parameters using a method specific to the inheriting class.- Parameters:
N (int) – Number of Trajectory objects to be generated.
- Return type:
list[Trajectory]
- class LangevinGenerator(T, dim=1, units=None, dt=1.0, gamma=1.0, sigma=1.0, bounds=None, bounds_extent=None, bounds_strength=None, v0=None, r0=None, seed=None)
Random Walk class from a multidimensional Langevin Equation. Boundary conditions to model confined or semi-infinite processes are supported.
- Parameters:
T (float) – Total duration of trajectories.
dim (int, optional) – Trajectories dimension, by default 1.
units (Units | None) – Units of the Trajectory, by default None. If None, the units are set to the default ones (i.e., m/s).
dt (float, optional) – Time step, by default 1.0.
gamma (float, optional) – Drag parameter or inverse of the persistence time, by default 1.
sigma (float, optional) – Noise intensity (i.e., scale parameter of noise pdf), by default 1.
bounds (np.ndarray | None) – Lower and upper reflecting boundaries that confine the trajectories. Must have shape (2, dim). The first row contains the lower boundaries and the second row contains the upper boundaries. If None is passed, trajectories are simulated in a free space. By default None.
bounds_extent (np.ndarray | None) – Decay length of boundary forces, by default None.
bounds_strength (np.ndarray | None) – Boundaries strength, by default None.
v0 (Collection[float] | float | None) – Initial velocities, by default None. Could be a float, an array of shape (dim,) or an array of shape (dim, N).
r0 (Collection[float] | float | None) – Initial positions, by default None. Could be a float, an array of shape (dim,) or an array of shape (dim, N).
seed (int | None)
- class RandomWalkGenerator(T, units=None, dim=1, dt=1, actions_prob=None, step_length_func=<function ones>, seed=None, **step_length_kwargs)
Multidimensional Random Walk Generator.
- Parameters:
T (float) – Total duration of each Trajectory.
dim (int, optional) – Dimension of each Trajectory, by default 1.
units (Units | None) – Units of the Trajectory, by default None. If None, the units are set to the default ones (i.e., m/s).
dt (float, optional) – Time step of the Trajectory, by default 1.0.
actions_prob (np.ndarray, optional) – Probability of each action (i.e., decrease, stead or increase) to be taken, according to every axis. If this parameter is not passed the walker will assume uniform probability for each action, by default None.
step_length_func (Callable[[tuple], np.ndarray], optional) – Function that returns the distribution of step lengths that will be taken by the walker on each time step, dimension and instance of a trajectory. Expected shape of the return value is (int(T/dt)-1, dim, N), by default np.ones.
step_length_kwargs (dict, optional) – Key-word arguments of the
step_length_func, by default{}.seed (int | None)
- generate(N)
Abstract method that is implemented on inheriting classes. It should compute a list of
NTrajectory objects with the given parameters using a method specific to the inheriting class.- Parameters:
N (int) – Number of Trajectory objects to be generated.
- Return type:
list[Trajectory]