Documentation |
The ColoredNoise object generates pink noise and other colored noise signals. The form of the PSD is 1/|f|^{α} with the exponent, α, a real number in the interval [-2,2].
To generate a colored noise signal:
Define and set up your colored noise generator. See Construction.
Call step to generate the colored noise signal according to the properties of dsp.ColoredNoise. The signal is an array with the number of rows given by the SamplesPerFrame property. The number of columns is given by the NumChannels property.
H = dsp.ColoredNoise returns a colored noise generator, H, with default settings. Calling step with the default property settings generates a pink noise signal.
H = dsp.ColoredNoise('PropertyName',PropertyValue, ...) returns a colored noise generator, H, with each specified property set to the specified value.
H = dsp.ColoredNoise(POW,SAMP,CHAN,'PropertyName',PropertyValue) returns a colored noise generator, H, with InverseFrequencyPower equal to POW, SamplesPerFrame equal to SAMP, and NumChannels equal to CHAN. Other specified properties are set to the specified values.
clone | Create colored noise generator with same property values |
getNumInputs | Number of expected inputs to step method |
getNumOutputs | Number of outputs of step method |
isLocked | Locked status for input attributes and nontunable properties |
release | Allow property value and input characteristics changes |
reset | Reset random number generator seed |
step | Generate colored noise signal |
Many phenomena in diverse fields such as hydrology and finance produce time series with power spectral density (PSD) functions that follow a power law of the form
$$S(f)=\frac{L(f)}{|f{|}^{\alpha}}$$
where α is a real number in the interval [-2,2] and $$L(f)$$ is a positive slowly-varying or constant function. Plotting the power spectral density of such processes on a log-log plot displays an approximate linear relationship between the log frequency and log PSD with slope equal to -α
$$\mathrm{ln}S(f)=-\alpha \mathrm{ln}\left|f\right|+\mathrm{ln}L(f).$$
It is often convenient to plot the PSD in dB as function of the log frequency to base 2 in order to characterize the slope in dB/octave. Rewriting the preceding equation, you obtain
$$10\mathrm{log}S(f)=-10\alpha \frac{\mathrm{ln}(2){\mathrm{log}}_{2}(f)}{\mathrm{ln}(10)}+10\frac{\mathrm{ln}(L(f))}{\mathrm{ln}(10)}$$
with the slope in dB/octave given by
$$-10\alpha \frac{\mathrm{ln}(2){\mathrm{log}}_{2}(f)}{\mathrm{ln}(10)}$$
If α>0, S(f) goes to infinity as the frequency, f, approaches 0. Stochastic processes with power spectral densities 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 $$\frac{1}{|f{|}^{\alpha}}$$ 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. Accordingly, 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 $$\frac{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.
dsp.ColoredNoise generates colored noise using a white noise input in an autoregressive model (AR) of order 63.
$$\sum _{k=0}^{63}{a}_{k}}y(n-k)=w(n)$$
where a_{0}=1 and w(n) is a zero-mean white noise process.
The AR coefficients for k≥1 are generated according to the following recursive formula with α the inverse PSD exponent
$${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 $$
The AR method used in dsp.ColoredNoise is detailed on pp. 820–822 in [2].
[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.