neuromancer.psl.signals module
Random signals to simulate arbitrary sequence of control actions or disturbances.
- neuromancer.psl.signals.arma(nsim, d, min=0.0, max=1.0, q=10, p=10, bound=True, rng=Generator(PCG64) at 0x305B127A0)[source]
Random autoregressive moving average signal.
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
- Returns:
(np.array shape=(nsim, d)) ARMA time series
- neuromancer.psl.signals.beta(nsim, d, min=0.0, max=1.0, alpha: float = 2, beta: float = 2, rng=Generator(PCG64) at 0x305B12960)[source]
roughly upside down parabola shaped probability with a=b=2, support (0,1). The beta distribution is flexible with parameters a,b. It always has support (0,1).
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
alpha – (float) parameter of beta distribution
beta – (float) parameter of beta distribution
rng – (np.random.Generator) random number generator
- Returns:
(np.array shape=(nsim, d)) scatter of beta distributed points
- neuromancer.psl.signals.beta_walk_max_step(nsim, d, min: float | ~numpy.ndarray = 0.0, max: float | ~numpy.ndarray = 1.0, max_step: float | ~numpy.ndarray | None = None, x0: float | ~numpy.ndarray | None = None, dtype: ~numpy.dtype = <class 'numpy.float32'>, alpha: float = 2, beta: float = 2, p: float = 0.3, rng=Generator(PCG64) at 0x305B12C00) ndarray [source]
Generate a random walk from a beta distribution with parameters (2,2). between min and max, with a maximum step size of max_step. No truncation is necessary, beta distro is bounded.
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
max_step – (float or 1-d array) Maximum step size
x0 – (float or 1-d array) Initial value
dtype – (dtype) Data type of output
alpha – (float) alpha parameter of beta distribution
beta – (float) beta parameter of beta distribution
p – (float) probability of stepping
rng – (np.random.Generator) Random number generator
- Returns:
(np.ndarray) Random walk
- neuromancer.psl.signals.beta_walk_mean(nsim, d, min: float | ~numpy.ndarray = 0.0, max: float | ~numpy.ndarray = 1.0, max_step: float | ~numpy.ndarray | None = None, x0: float | ~numpy.ndarray | None = None, dtype: ~numpy.dtype = <class 'numpy.float32'>, ab: float = 8, p: float = 0.5, q: float = 0.5, rng=Generator(PCG64) at 0x305B12B20) ndarray [source]
Generate a random walk from a beta distribution with parameters alpha beta set so that the mean is the current position and the pdf is frown-like when the other parameter is 2.
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
max_step – (float or 1-d array) Maximum step size
x0 – (float or 1-d array) Initial value
dtype – (dtype) Data type of output
ab – (float) alpha or beta parameter of beta distribution
p – (float) probability of any step
q – (float) probability of individual beta step
rng – (np.random.Generator) Random number generator
- Returns:
(np.array shape=(nsim, d)) Random walk
- neuromancer.psl.signals.nd_walk(nsim, d, min: float | ~numpy.ndarray = 0.0, max: float | ~numpy.ndarray = 1.0, x0: float | ~numpy.ndarray | None = None, max_step: float | ~numpy.ndarray | None = None, p: float = 0.3, avoid_edge: bool = True, granularity: int = 0, dtype: ~numpy.dtype = <class 'numpy.float32'>, rng=Generator(PCG64) at 0x305B12CE0) ndarray [source]
random walk which avoids the edge by default. If granularity is 0 takes uniform random steps, if granularity is 1 always takes max_step.
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
x0 – (float or 1-d array) Initial value
max_step – (float or 1-d array) Maximum step size
p – (float) probability of stepping
avoid_edge – (bool) whether to avoid the edge
granularity – (int) granularity of steps (0 is uniform random, 1 is max_step, >1 takes a step of length n*max_step/granularity where n is random int 1<=n<=granularity.
dtype – (dtype) Data type of output
rng – (np.random.Generator) Random number generator
- Returns:
(np.ndarray) Random walk
- neuromancer.psl.signals.noise(nsim, d, min=0.0, max=1.0, sigma=0.05, bound=True, rng=Generator(PCG64) at 0x305B12340)[source]
Independent Gaussian noise for arbitrary number of dimensions scaled between min/max bounds
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
sigma – (float or 1-d array) Variance of normal distribution
bound – (bool) Whether to scale signal to between min and max
- Returns:
(np.array shape=(nsim, d)) White noise time series of dimension d and length nsim
- neuromancer.psl.signals.periodic(nsim, d, min=0.0, max=1.0, periods=30, form='sin', phase_offset=False, rng=Generator(PCG64) at 0x305B12500)[source]
periodic signals, sine, cosine
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
periods – (int) Number of periods taking place across nsim
- Returns:
(np.array shape=(nsim, d)) Periodic time-series
- neuromancer.psl.signals.prbs(nsim, d, min=0.0, max=1.0, p=0.9, rng=Generator(PCG64) at 0x305B12880)[source]
pseudo-random binary signal taking values min or max.
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
p – (float) probability of switching from min to max or vice versa.
- Returns:
(np.array shape=(nsim, d)) PRBS time series
- neuromancer.psl.signals.sines(nsim, d, min=0.0, max=1.0, periods=30, nwaves=20, form='sin', rng=Generator(PCG64) at 0x305B125E0)[source]
sum of sines
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
periods – (int) Number of periods taking place across nsim
- Returns:
(np.array shape=(nsim, d)) Periodic time-series
- neuromancer.psl.signals.spline(nsim, d, min=0.0, max=1.0, values=None, n_interpolants=30, rng=Generator(PCG64) at 0x305B126C0)[source]
Generates a smooth cubic spline trajectory by interpolating between data points
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
n_interpolants – (int) Number of values to interpolate between
- Returns:
(np.array shape=(nsim, d)) Periodic time-series
- neuromancer.psl.signals.step(nsim, d, min=0.0, max=1.0, randsteps=30, values=None, rng=Generator(PCG64) at 0x305B12420)[source]
Random step function for arbitrary number of dimensions
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
randsteps – (int) Number of random steps in time series (will infer from values if values is not None)
values – (np.array) An ordered list of values for each step change
- Returns:
(np.array shape=(nsim, d)) Time series of random steps
- neuromancer.psl.signals.walk(nsim, d, min=0.0, max=1.0, sigma=0.05, bound=True, rng=Generator(PCG64) at 0x305B120A0)[source]
Gaussian random walk for arbitrary number of dimensions scaled between min/max bounds
- Parameters:
nsim – (int) Number of simulation steps
d – (int) Number of dimensions
min – (float or 1-d array) Lower bound on values
max – (float or 1-d array) Upper bound on values
sigma – (float or 1-d array) Variance of normal distribution
bound – (bool) Whether to scale signal to between min and max
- Returns:
(np.array shape=(nsim, d)) Random walk time series of dimension d and length nsim