Generate colored noise signal
DSP System Toolbox / Sources
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]. The type of colored noise the block generates depends on the
Noise 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
Port_1 — Colored noise signal
scalar | vector | matrix
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.
Noise color — Color of the generated noise
pink (default) |
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 to
white— Generates white noise (flat power spectral density). This option is equivalent to setting Power of inverse frequency to
brown— Generates brown noise. Also known as red or Brownian noise. This option is equivalent to setting Power of inverse frequency to
blue— Generates blue noise. Also known as azure noise. This option is equivalent to setting Power of inverse frequency to
purple— Generates violet (purple) noise. This option is equivalent to setting Power of inverse frequency to
custom— Specify the power density of the noise using the Power of inverse frequency parameter.
Power of inverse frequency — Inverse power spectral density component
1 (default) | scalar in the range
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 is
1. When Power of inverse
frequency is greater than
0, the block
generates lowpass noise, with a singularity (pole) at
= 0. These processes exhibit long
memory. When Power of inverse frequency is less than
0, 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 –α.
To enable this parameter, set Noise color to
Guarantee the output is bounded (+/-1) — Set output bounds to +1 and −1
off (default) |
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 to
white, 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
When you do not select the parameter, the internal random source is Gaussian. The output is not bounded.
Number of output channels — Number of output channels
1 (default) | positive integer
Number of output channels, specified as a positive integer scalar. This parameter defines the number of columns in the generated signal.
Output data type — Output data type
double (default) |
Data type of the output specified as
Number of samples per output channel — Samples per frame of output
1024 (default) | positive integer
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.
Output sample time (s) — Sample time of the output
1 (default) | positive scalar
Sample time of the output signal, specified as a positive scalar in seconds.
Initial seed — Initial seed of random number generator
67 (default) | positive integer
Initial seed of the random number generator algorithm, specified as a real-valued positive integer scalar.
Simulate using — Type of simulation to run
Interpreted execution (default) |
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.
Colored Noise Processes
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 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 .
Special examples of 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 . 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.
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
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 .
 Beran, J., Feng, Y., Ghosh, S., and Kulik, R. Long-Memory Processes: Probabilistic Properties and Statistical Methods. Springer, 2013.
 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.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2015a