Colored Noise - Generate colored noise signal - Simulink (original) (raw)
Generate colored noise signal
Libraries:
DSP System Toolbox / Sources
Description
The Colored Noise block generates a colored noise signal with a power spectral density of 1/|f|α over its entire frequency range. The inverse power spectral density component, α, can be any value in the interval [-2 2]
. The type of colored noise the block generates depends on theNoise color option you choose in the block dialog box. When you set Noise color to custom
, you can specify the power density of the noise through the Power of inverse frequency parameter.
Examples
Generate two-channels of pink noise from the Colored Noise block and compute the power spectrum based on a running average of 50 PSD estimates.
The Colored Noise block generates two-channels of pink noise with 1024 samples. The Spectrum Analyzer computes modified periodograms using a Hamming window and 50% overlap. The running average of the PSD uses 50 spectral averages.
Ports
Output
Colored noise output signal. The size and data type of the signal depend on the values of the Number of output channels, Number of samples per output channel, and Output data type parameters.
Data Types: single
| double
Parameters
Color of the noise the block generates. You can set this parameter to:
pink
— Generates pink noise. This option is equivalent to setting Power of inverse frequency to1
.white
— Generates white noise (flat power spectral density). This option is equivalent to setting Power of inverse frequency to0
.brown
— Generates brown noise. Also known as red or Brownian noise. This option is equivalent to setting Power of inverse frequency to2
.blue
— Generates blue noise. Also known as azure noise. This option is equivalent to settingPower of inverse frequency to-1
.purple
— Generates violet (purple) noise. This option is equivalent to settingPower of inverse frequency to-2
.custom
— Specify the power density of the noise using the Power of inverse frequency parameter.
Inverse power spectral density component, α, specified as a real-valued scalar in the interval [-2 2]
. The inverse exponent defines the power spectral density of the random process by 1/|f|α. The default value of this property is1
. When Power of inverse frequency is greater than 0
, the block generates lowpass noise, with a singularity (pole) at_f_= 0
. These processes exhibit long memory. When Power of inverse frequency is less than0
, the block generates highpass noise with negatively correlated increments. These processes are referred to as antipersistent. In a log-log plot of power as a function of frequency, processes generated by the Colored Noise block exhibit an approximate linear relationship, with the slope equal to –α.
Dependencies
To enable this parameter, set Noise color tocustom
.
Select the parameter to make the output bounded between +1 and −1.
When you select the parameter, the internal random source that generates the noise is uniform. If Noise color is set towhite
, there is no color filter applied to the output of the random source. The output is uniform noise of amplitude between +1 and −1. If Noise color is set to any other option, then a coloring filter is applied to the output of the random source, followed by a gain that ensures the absolute maximum output never exceeds 1
.
When you do not select the parameter, the internal random source is Gaussian. The output is not bounded.
Number of output channels, specified as a positive integer scalar. This parameter defines the number of columns in the generated signal.
Data type of the output specified as double
orsingle
.
Number of samples in each frame of the output signal, specified as a positive integer scalar. This parameter defines the number of rows in the generated signal.
Sample time of the output signal, specified as a positive scalar in seconds.
Initial seed of the random number generator algorithm, specified as a real-valued positive integer scalar.
Specify the type of simulation to run. You can set this parameter to:
Interpreted execution
–– Simulate model using the MATLAB® interpreter. This option shortens startup time.Code generation
–– Simulate model using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The C code is reused for subsequent simulations as long as the model does not change. This option requires additional startup time but provides faster subsequent simulations.
Block Characteristics
Data Types | double | single |
---|---|
Multidimensional Signals | No |
Variable-Size Signals | No |
More About
Many phenomena in diverse fields, such as hydrology and finance, produce time series with PSD functions that follow a power law of the form
where α is a real number in the interval [-2,2] and L(f) is a positive, slowly-varying or constant function. Plotting the PSD of such processes on a log-log plot displays an approximate linear relationship between the log frequency and log PSD with slope equal to -α
It is often convenient to plot the PSD in dB as a function of the frequency on a base-2 logarithmic scale. The slope of the plot is then dB/octave. Rewriting the preceding equation, you obtain
with the slope in dB/octave given by
If α > 0, S(f) goes to infinity as the frequency, f, approaches 0. Stochastic processes with PSDs of this form exhibit long memory. Long-memory processes have autocorrelations that persist for a long time as opposed to decaying exponentially like many common time-series models. If α<0, the process is antipersistent and exhibits negative correlation between increments [1].
Special examples of 1|f|α processes include:
- α = 0 — White noise, where L(f) is a constant proportional to the process variance.
- α = 1 — Pink, or flicker noise. Pink noise has equal energy per octave. See Measure Pink Noise Power in Octave Bands for a demonstration. The power spectral density of pink noise decreases 3 dB per octave.
- α = 2 — brown noise, or Brownian motion. Brownian motion is a nonstationary process with stationary increments. You can think of Brownian motion as the integral of a white noise process. Even though Brownian motion is nonstationary, you can still define a generalized power spectrum, which behaves like 1|f|2. Accordingly, power in a brown noise decreases 6 dB per octave.
- α = −1 — blue noise. The power spectral density of blue noise increases 3 dB per octave.
- α = −2 — violet, or purple noise. The power spectral density of violet noise increases 6 dB per octave. You can think of violet noise as the derivative of white noise process.
Algorithms
The figure shows the overall process of generating the colored noise.
The random stream generator produces a stream of white noise that is either Gaussian or uniform in distribution. A coloring filter applied to the white noise generates colored noise with a power spectral density (PSD) function given by:
When α, the inverse frequency power, equals 0, no coloring filter is applied to the output of the random stream generator. If the bounded option is enabled, the output is uniform white noise with amplitude between +1 and −1. If the bounded output is not enabled, the output is a Gaussian white noise and the values are not bounded between +1 and −1. If α is set to any other value, then a coloring filter is applied to the output of the random stream generator. If the bounded output option is enabled, a gain_g_ is applied to the output of the coloring filter to ensure that the absolute maximum output never exceeds 1
.
For details on colored noise processes and how the value of α affects the PSD of the colored noise, see Colored Noise Processes.
When the inverse frequency power α is positive, the colored noise is generated using an auto regressive (AR) model of order 63. The AR coefficients are:
Pink and brown noises are special cases, which are generated from specially tuned SOS filters of orders 12 and 10, respectively. These filters are optimized for better performance.
When the inverse frequency power α is negative, the colored noise is generated using a moving average (MA) model of order 255. The MA coefficients are:
Purple noise is generated from a first order filter, B = [1 −1].
The coloring filters applied (except pink, brown, and purple) are detailed on pp. 820–822 in[2].
References
[1] Beran, J., Feng, Y., Ghosh, S., and Kulik, R. Long-Memory Processes: Probabilistic Properties and Statistical Methods. Springer, 2013.
[2] Kasdin, N.J. "Discrete Simulation of Colored Noise and Stochastic Processes and 1/fα Power Law Noise Generation". Proceedings of the IEEE®. Vol. 83, No. 5, 1995, pp. 802–827.
Extended Capabilities
Version History
Introduced in R2015a