Skip to content

datasets

Load and fetch sample data for benchmarking and testing purposes.

Functions:

Name Description
gen_gbn_seq

Generate sequence of inputs GBN.

gen_rw_seq

Generate a sequence of inputs as Random walk.

make_tf

Generate a Transfer Function object of a system.

white_noise

Add a white noise to a signal y.

white_noise_var

Generate a white noise matrix (rows with zero mean).

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.

make_tf

make_tf(
    numerator: list[float],
    denominator: list[float],
    ts: float = 1.0,
    noise: float = 0.0,
    random_state: int | None = None,
) -> TransferFunction
make_tf(
    numerator: list[list[float]],
    denominator: list[list[float]],
    ts: float = 1.0,
    noise: float = 0.0,
    random_state: int | None = None,
) -> NestedTransferFunction
make_tf(
    numerator: list[float] | list[list[float]],
    denominator: list[float] | list[list[float]],
    ts: float = 1.0,
    noise: float = 0.0,
    random_state: int | None = None,
) -> TransferFunction | NestedTransferFunction

Generate a Transfer Function object of a system.

Parameters:

Name Type Description Default

numerator

list[float] | list[list[float]]

Numerator coefficients of the transfer function.

required

denominator

list[float] | list[list[float]]

Denominator coefficients of the transfer function.

required

ts

float

Sampling time, by default 1.0.

1.0

noise

float

Standard deviation of Gaussian noise, by default 0.0.

0.0

random_state

int | None

Random seed, by default None.

None

Returns:

Type Description
TransferFunction | NestedTransferFunction

TransferFunction or nested structure of TransferFunctions.

white_noise

white_noise(
    y: ndarray, A_rel: float, seed: int | None = None
)

Add a white noise to a signal y.

noise amplitude= A_rel*(standard deviation of y)

Parameters:

Name Type Description Default

y

ndarray

original signal

required

A_rel

float

relative amplitude (0<x<1) to the standard deviation of y

required

seed

int | None

random seed

None

white_noise_var

white_noise_var(
    L: int, Var: ndarray, seed: int | None = None
) -> ndarray

Generate a white noise matrix (rows with zero mean).

Parameters:

Name Type Description Default

L

int

size (columns)

required

Var

ndarray

variance vector

required

Returns:

Type Description
ndarray

white_noise_var(100,[1,1]) , noise matrix has two row vectors with variance=1