simulate

Simulation Related

pynumdiff.utils.simulate.linear_autonomous(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.0001)

Create toy example of time series from an autonomous linear system

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series from an autonomous linear system;

  • pos – a noise-free time series from an autonomous linear system (truth);

  • vel – a true derivative information of the time series

pynumdiff.utils.simulate.lorenz_x(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.0001)

Create toy example of x component from a lorenz attractor

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series of x component from Lorenz system;

  • pos – a noise-free time series of x component from Lorenz system (truth);

  • vel – a true derivative information of the time series

pynumdiff.utils.simulate.pi_cruise_control(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.01)

Create a toy example of linear proportional integral controller with nonlinear control inputs. Simulate proportional integral control of a car attempting to maintain constant velocity while going up and down hills. We assume the car has arbitrary power and can achieve whatever acceleration it wants; its mass only factors in via -mg pulling it downhill. This is a linear interpretation of something similar to what is described in Astrom and Murray 2008 Chapter 3.

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series of linear proportional integral controller with

    nonlinear control inputs;

  • pos – a noise-free time series of linear proportional integral controller with

    nonlinear control inputs (truth);

  • vel – a true derivative information of the time series

pynumdiff.utils.simulate.pop_dyn(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.0001)

Create toy example of bounded exponential growth: http://www.biologydiscussion.com/population/population-growth/population-growth-curves-ecology/51854

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series consisted of bounded exponential growth;

  • pos – a noise-free time series consisted of bounded exponential growth (truth);

  • vel – a true derivative information of the time series

pynumdiff.utils.simulate.sine(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.0001, frequencies=(1, 1.7), magnitude=1)

Create toy example of time series consisted of sinusoidal modes

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

  • frequencies (list[float]) – frequencies for sinusoidal modes

  • magnitude (float) – magnitude/frequencies[i] is the true magnitude of the ith sinusoidal mode

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series consisted of several sinusoidal modes;

  • pos – a noise-free time series consisted of several sinusoidal modes (truth);

  • vel – a true derivative information of the time series

pynumdiff.utils.simulate.triangle(duration=4, noise_type='normal', noise_parameters=(0, 0.5), outliers=False, random_seed=1, dt=0.01, simdt=0.0001)

Create toy example of sharp-edged triangle wave with increasing frequencies

Parameters:
  • duration (float) – governs the length of the series, duration/dt

  • noise_type (str) – type of noise, compatible with np.random functions (eg. ‘normal’, ‘uniform’, ‘poisson’)

  • noise_parameters – parameters of the noise used in np.random, leaving off size

  • outliers (bool) – whether to corrupt 1% of the data points with out-of-distribution values

  • random_seed (int) – an integer seed used to initialize the random number generator

  • dt (float) – the step size

  • simdt (float) – simulation step size used to generate the time series, typically smaller than dt to achieve high precision

Returns:

tuple[np.array, np.array, np.array] of

  • noisy_pos – a noisy time series consisted of sharp-edged triangles;

  • pos – a noise-free time series consisted of sharp-edged triangles (truth);

  • vel – a true derivative information of the time series