Skip to content

_input_generator

Functions:

Name Description
gen_gbn_seq

Generate sequence of inputs GBN.

gen_rw_seq

Generate a sequence of inputs as Random walk.

gen_gbn_seq

gen_gbn_seq(
    n_samples: int,
    p_swd: float,
    n_min: int = 1,
    scale: tuple[float, float] = (-1.0, 1.0),
    tol: float = 0.01,
    nit_max: int = 30,
    seed: int | None = None,
) -> tuple[ndarray, float, int]

Generate sequence of inputs GBN.

Generate Generalized Binary Noise (GBN), apseudo-random binary sequence.

Parameters:

Name Type Description Default

n_samples

int

sequence length (total number of samples)

required

p_swd

float

desired probability of switching (no switch: 0<x<1 :always switch)

required

n_min

int

minimum number of samples between two switches

1

scale

tuple[float, float]

upper and lower values of the sequence

(-1.0, 1.0)

tol

float

tolerance on switching probability relative error

0.01

nit_max

int

maximum number of iterations to get the desired switching probability

30
Return

array of given length and switching probability. actual probability of switching (which may differ a little from p_swd according to tol. number of switches in the sequence.

Examples:

Generating an array of length equal to 1000, 10% of switch probability, switching at least every 20 samples, between -10 or 5;

>>> bn_b, p_sw_b, Nswb = gen_gbn_seq(1000, 0.1, 20, (-10, 5))
References

Y. Zhu. Multivariable System Identification For Process Control. 2001.

gen_rw_seq

gen_rw_seq(
    n_samples: int,
    rw0: float,
    sigma: float = 1.0,
    seed: int | None = None,
) -> ndarray

Generate a sequence of inputs as Random walk.

Generate a random signal sequence (a random walk from a normal distribution).

Parameters:

Name Type Description Default

n_samples

int

sequence length (total number of samples);

required

sigma

float

standard deviation (mobility) of randow walk

1.0

rw0

float

initial value

required

Parameters:

Name Type Description Default

n_samples

int

sequence length (total number of samples)

required

rw0

float

initial value

required

sigma

float

standard deviation (mobility) of random walk

1.0

seed

int | None

seed for random number generator

None
Return

array of given length and switching probability. actual probability of switching (which may differ a little from p_swd according to tol. number of switches in the sequence.

Examples:

Generating an array of length equal to 1000, 10% of switch probability, switching at least every 20 samples, between -10 or 5;

>>> bn_b, p_sw_b, Nswb = gen_gbn_seq(1000, 0.1, 20, (-10, 5))
References

Y. Zhu. Multivariable System Identification For Process Control. 2001.