Noise (FPScript)

21.09.2021

Generates equally, normally or exponentially distributed random numbers.

Syntax

Noise(Value, [ Distribution = NOISE_UNIFORM ] [ , Init ])

 

The syntax of the Noise function consists of the following parts:

Part

Description

Value

Any value that determines the number, data structure and the unit of the random numbers.

All data structures are allowed. All numeric data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Distribution

Determines the statistical distribution for the random numbers.

The argument Distribution can have the following values:

Constant

Meaning

NOISE_UNIFORM

Generates equally distributed random numbers within the interval [-1, 1].

NOISE_NORMAL

Generates normally distributed random numbers with mean equal to 0 and standard deviation equal to 1.

NOISE_EXPONENTIAL

Generates exponentially distributed random numbers with lambda equal to 1.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value NOISE_UNIFORM.

Init

The initialization value for the random number generator. If you pass 0, then the generator is not re-initialized, i.e. the sequence already started using a previous call continues. If you omit the argument or call the function for the first time, then the generator is initialized using the current system time.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

The data type of the result is always 64-bit floating point.

The structure of the result corresponds to that of the argument Value.

If Value has an aggregate data structure, i.e. is a signal, signal series or space curve, then the X and, if applicable, Z component is copied into the result and a random number is generated for each value of the Y component.

To generate uniformly distributed random numbers, the function uses a random generator with random cycle lengths, as it is described for "RANROT Type W" generator in [1].

The normally distributed random numbers are generated from uniformly distributed random numbers using the Box-Mueller method. The generated random numbers have a mean of 0 and a standard deviation of 1. From this, any other normal distribution can be derived through a simple linear transformation: μ + σ * Noise(x, NOISE_NORMAL), with the desired mean μ and the desired standard deviation σ.

The exponentially distributed random numbers are derived from the uniformly distributed random numbers using the transformation method. The generated random numbers have a lambda of 1. You can generate any other exponential distribution from this through division: Noise(x, NOISE_EXPONENTIAL) / , with the desired lambda .

Both transformation methods, among others, are described in [2].

Available in

FlexPro Basic, Professional, Developer Suite

Examples

Noise(1)

Results in 0.8499 (random)

x = (1000, 0.1 s, 0.01 s)
Signal(0.5 V + 0.5 V * Noise(x), x)
 

Generates a signal with 1000 uniformly distributed random numbers within the interval [0, 1] V and with an X component from 0 s to 10 s.

3. + 2. * Noise(1#100, NOISE_NORMAL)

Generates a data series with 100 normally distributed random numbers with a mean of 3 and a standard deviation of 2.

See Also

Signal Analysis Object

References

[1] "William H. Press et al.": Numerical Recipes in C, Second Edition. http://www.agner.org/random/theory,2001.

[2] "William H. Press et al.": Numerical Recipes in C, Second Edition, page 274. "Cambridge University Press",1992.ISBN 0-552-43108-5.

Share article or send as email:

You might be interested in these articles