Main Content

Generate colored noise signal

The `dsp.ColoredNoise`

System object™ generates a colored noise signal with a power spectral density (PSD) of 1/|*f*|^{α} over its entire frequency range. The inverse frequency power,
*α*, can be any value in the interval `[-2 2]`

. The type
of colored noise the object generates depends on the Color you
choose. When you set `Color`

to `'custom'`

, you can
specify the power density of the noise through the InverseFrequencyPower property.

The size and data type properties of the generated signal depend on SamplesPerFrame, NumChannels, and the OutputDataType properties.

This object uses the default MATLAB^{®} random stream, `RandStream`

. Reset the default stream for
repeatable simulations.

To generate colored noise signal:

Create the

`dsp.ColoredNoise`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

creates a colored
noise object, `cn`

= dsp.ColoredNoise`cn`

, that outputs a noise signal one sample or frame at
a time, with a 1/|*f*|^{α} spectral characteristic over its entire frequency range. Typical values
for *α* are *α* = 1 (pink noise) and
*α* = 2 (brownian noise).

creates a colored noise object with each specified property set to the specified value.
Enclose each property name in single quotes. `cn`

= dsp.ColoredNoise(`Name,Value`

)

`dsp.ColoredNoise('Color','pink');`

creates a colored noise object with the `cn`

= dsp.ColoredNoise(pow,samp,numChan,`Name,Value`

)`InverseFrequencyPower`

property set to *pow*, the `SamplesPerFrame`

property
set to *samp*, and the `NumChannels`

property set to
*numChan*.

`dsp.ColoredNoise(1,44.1e3,1,'OutputDataType','single');`

creates a colored noise object with the `cn`

= dsp.ColoredNoise(color,samp,numChan,`Name,Value`

)`Color`

property set to
*color*, the `SamplesPerFrame`

property set to
*samp*, and the `NumChannels`

property set to
*numChan*.

`dsp.ColoredNoise('pink',1024,2,'OutputDataType','single');`

To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

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:

$$S(f)=\frac{L(f)}{|f{|}^{\alpha}}$$

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:

$$\begin{array}{l}{a}_{0}=1,\\ {a}_{k}=(k-1-{\scriptscriptstyle \frac{\alpha}{2}})\frac{{a}_{k-1}}{k},\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=1,2,\dots ,63\end{array}$$

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:

$$\begin{array}{l}{b}_{0}=1,\\ {b}_{k}=\left(k-1+\frac{\alpha}{2}\right)\frac{{b}_{k-1}}{k},\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=1,2,\cdots ,255\end{array}$$

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].

[1] Beran, J., Y. Feng, S. Ghosh, and R. Kulik,
*Long-Memory Processes: Probabilistic Properties and Statistical
Methods*. NewYork: 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.