Noise

class pathsim.blocks.noise.WhiteNoise(standard_deviation=1.0, spectral_density=None, sampling_period=None, seed=None)[source]

Bases: Block

White noise source with Gaussian distribution.

Generates uncorrelated random samples with either constant amplitude (standard_deviation mode) or timestep-scaled amplitude for stochastic integration (spectral_density mode).

In spectral density mode, output is scaled as √(S₀/dt) so that integrating the noise yields correct statistical properties (Wiener process).

Note

If spectral_density is provided, it takes precedence over standard_deviation. If sampling_period is set, noise is sampled at fixed intervals (zero-order hold).

Parameters:
  • standard_deviation (float) – output standard deviation for constant-amplitude mode (default: 1.0)

  • spectral_density (float, optional) – power spectral density S₀ in [signal²/Hz]

  • sampling_period (float, optional) – time between samples, if None samples every timestep

  • seed (int, optional) – random seed for reproducibility

input_port_labels = {}
output_port_labels = {'out': 0}
sample(t, dt)[source]

Generate new noise sample after successful timestep.

Only generates new samples in continuous mode (sampling_period=None).

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

update(t)[source]

The ‘update’ method is called iteratively for all blocks to evaluate the algebraic components of the global system ode from the DAG.

It is meant for instant time blocks (blocks that dont have a delay due to the timestep, such as Amplifier, etc.) and updates the ‘outputs’ of the block directly based on the ‘inputs’ and possibly internal states.

Note

The implementation of the ‘update’ method in the base ‘Block’ class is intended as a fallback and is not performance optimized. Special blocks might reimplement this method differently for higher performance, for example SISO or MISO blocks.

Parameters:

t (float) – evaluation time

class pathsim.blocks.noise.PinkNoise(standard_deviation=1.0, spectral_density=None, num_octaves=16, sampling_period=None, seed=None)[source]

Bases: Block

Pink noise (1/f noise) source using the Voss-McCartney algorithm.

Generates noise with power spectral density proportional to 1/f, where lower frequencies have more power than higher frequencies.

The algorithm maintains num_octaves independent random values representing different frequency bands. At each sample, one octave is updated based on the binary representation of the sample counter, creating the characteristic 1/f spectrum through the superposition of different update rates.

Note

If spectral_density is provided, it takes precedence over standard_deviation. If sampling_period is set, noise is sampled at fixed intervals (zero-order hold).

Parameters:
  • standard_deviation (float) – approximate output standard deviation (default: 1.0)

  • spectral_density (float, optional) – power spectral density, output scaled as √(S₀/(N·dt))

  • num_octaves (int) – number of frequency bands in algorithm (default: 16)

  • sampling_period (float, optional) – time between samples, if None samples every timestep

  • seed (int, optional) – random seed for reproducibility

input_port_labels = {}
output_port_labels = {'out': 0}
reset()[source]

Reset the noise generator state.

Resets the sample counter and reinitializes all octave values.

sample(t, dt)[source]

Generate new noise sample after successful timestep.

Only generates new samples in continuous mode (sampling_period=None).

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

update(t)[source]

The ‘update’ method is called iteratively for all blocks to evaluate the algebraic components of the global system ode from the DAG.

It is meant for instant time blocks (blocks that dont have a delay due to the timestep, such as Amplifier, etc.) and updates the ‘outputs’ of the block directly based on the ‘inputs’ and possibly internal states.

Note

The implementation of the ‘update’ method in the base ‘Block’ class is intended as a fallback and is not performance optimized. Special blocks might reimplement this method differently for higher performance, for example SISO or MISO blocks.

Parameters:

t (float) – evaluation time