colored_noise, a FORTRAN90 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.
CORRELATION, a FORTRAN90 code which contains examples of statistical correlation functions.
NORMAL, a FORTRAN90 code which computes elements of a sequence of pseudorandom normally distributed values.
PINK_NOISE, a FORTRAN90 code which computes a "pink noise" signal obeying a 1/f power law.
SDE, a FORTRAN90 code which illustrates the properties of stochastic differential equations, and common algorithms for their analysis, by Desmond Higham;
SFTPACK, a FORTRAN90 code which implements the "slow" Fourier transform, intended as a teaching tool and comparison with the fast Fourier transform.
STOCHASTIC_RK, a FORTRAN90 code which applies a Runge-Kutta scheme to a stochastic differential equation.
UNIFORM, a FORTRAN90 code which computes elements of a uniform pseudorandom sequence.