# Generate noise with arbitrary covariance

I am doing a time series change detection experiment. One of the experiments includes generating some artificial data for model evaluation.

I came across a problem in generating noise data with some arbitrary covariance at every 100 time steps.

While randn from Matlab allows me to generate the value, I am never able to figure how to change the covariance of the data. Is there any example that I can refer to?

• There is no such thing as the covariance of the data unless your data has only two items: covariance is a pair-wise property. For time series purposes, you need the covariance function which tells you the covariance between all $\binom{n}{2}$ pairs of the $n$ items. And no, you cannot choose an arbitrary function and say "That's the covariance function I want to achieve" because covariance functions must satisfy certain properties, and if your choice does not meet the criteria, then nobody can tell you how to achieve your heart's desire. – Dilip Sarwate Dec 30 '13 at 19:03

If you want a Gaussian vector $X$ with $E(X)=0$ and $E(X\,X^T)=C$, then find a decomposition $C=AA^T$, for instance a Cholesky decomposition, compute a vector $U$ with standard normal uncorrelated random numbers as components and set $X=AU$.