pathsim.blocks.noise module

class pathsim.blocks.noise.WhiteNoise(spectral_density=1, sampling_rate=None)[source]

Bases: Block

White noise source with uniform spectral density. Samples from distribution with ‘sampling_rate’ and holds noise values constant for time bins.

If no ‘sampling_rate’ (None) is specified, every simulation timestep gets a new noise value. This is the default setting.

Parameters:
  • spectral_density (float) – noise spectral density

  • noise (float) – internal noise value

  • sampling_rate (float, None) – frequency with which the noise is sampled

sigma

sqrt of spectral density -> signal amplitude

Type:

float

n_samples

internal sample counter

Type:

int

reset()[source]

Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.

sample(t)[source]

Sample from a normal distribution after successful timestep

Parameters:

t (float) – evaluation time for sampling

update(t)[source]

update system equation for fixed point loop, here just setting the outputs

Note

no direct passthrough, so the ‘update’ method is optimized for this case

Parameters:

t (float) – evaluation time

class pathsim.blocks.noise.PinkNoise(spectral_density=1, num_octaves=16, sampling_rate=None)[source]

Bases: Block

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

Samples from distribution with ‘sampling_rate’ and generates noise with a power spectral density inversely proportional to frequency.

Parameters:
  • spectral_density (float) – Desired noise spectral density

  • num_octaves (int) – Number of octaves (levels of randomness)

  • sampling_rate (float, None) – Frequency with which the noise is sampled

sigma

sqrt of spectral density normalized to number of octaves

Type:

float

n_samples

internal sample counter

Type:

int

noise

internal noise value

Type:

float

octaves_values

internal random numbers for octaves in the Voss-McCartney algorithm

Type:

array[float]

reset()[source]

Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.

sample(t)[source]

Generate a new pink noise sample at ‘t’ using the Voss-McCartney algorithm.

Parameters:

t (float) – evaluation time for sampling

update(t)[source]

update system equation for fixed point loop, here just setting the outputs

Note

no direct passthrough, so the ‘update’ method is optimized for this case

Parameters:

t (float) – evaluation time