colored_noise, a Python code which generates sequences that simulate 1/f^alpha power law noise. This includes white noise (alpha = 0), pink noise (alpha = 1) and brown noise or Brownian motion (alpha = 2), but also values of alpha between 0 and 2.

The original code listing by Kasdin referenced a number of functions from the Numerical Recipes code (FOUR1, FREE_VECTOR, GASDEV, RAN1, REALFT, VECTOR). Numerical Recipes is a proprietary code whose components cannot be freely distributed. Moreover, the referenced functions have some peculiarities of implementation (the FFT is not normalized; the FFT data must be a power of 2 in order; the code uses single precision real arithmetic).

In the code presented here, references to Numerical Recipes functions have been replaced by references to, and the source code of, nonproprietary code. In particular, the Fourier transform is implemented by a "slow Fourier transform" method, and by simple uniform and normal random number generators. You are welcome to make an efficient code by replacing these routines. The purpose of this posting is primarily to demonstrate the method.


The computer code and data files described and made available on this web page are distributed under the MIT license


colored_noise is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

brownian_motion_simulation, a Python code which simulates Brownian motion in an M-dimensional region.

normal, a Python code which computes elements of a sequence of pseudorandom normally distributed values.

pink_noise, a Python code which computes a "pink noise" signal obeying a 1/f power law.

sftpack, a Python code which implements the "slow" Fourier transform, intended as a teaching tool and comparison with the fast Fourier transform.

uniform, a Python code which computes elements of a uniform pseudorandom sequence.


  1. Martin Gardner,
    White and brown music, fractal curves and one-over-f fluctuations,
    Scientific American,
    Volume 238, Number 4, April 1978, pages 16-32.
  2. Jeremy Kasdin,
    Discrete Simulation of Colored Noise and Stochastic Processes and 1/f^a Power Law Noise Generation,
    Proceedings of the IEEE,
    Volume 83, Number 5, 1995, pages 802-827.
  3. Edoardo Milotti,
    1/f noise: a pedagogical review,
  4. Sophocles Orfanidis,
    Introduction to Signal Processing,
    Prentice-Hall, 1995,
    ISBN: 0-13-209172-0,
    LC: TK5102.5.O246.
  5. William Press,
    Flicker Noises in Astronomy and Elsewhere,
    Comments on Astrophysics,
    Volume 7, Number 4, 1978, pages 103-119.
  6. Miroslav Stoyanov, Max Gunzburger, John Burkardt,
    Pink Noise, 1/f^alpha Noise, and Their Effect on Solutions of Differential Equations,
    International Journal for Uncertainty Quantification,
    Volume 1, Number 3, pages 257-278, 2011.

Source Code:

COLORED_NOISE_TEST01 generates a sequence of 9 sets of data, for ALPHA = 0.00 to ALPHA = 2.00, each time computing a sequence of 128 values, and using the same sequence of random numbers. This makes the effect of ALPHA very clear.

COLORED_NOISE_TEST02 generates 5 plots, with ALPHA = 0.0, 0.5, 1.0, 1.5 and 2.0, showing 5 realizations, and the average of 200.

Last revised on 12 September 2018.