# How can faux correlated data be generated for testing or training?

There are one or two questions here that ask how to assess data correlation. The data tends to be empirical.

Is there some tool or standardised technique for generating correlated data from scratch? Some way of generating a sequence with an exact amount of known correlation or autocorrelation? It would allow quantitative testing, training and assessment of correlation measurement tools. Or do people just wing it and knock something up Pythonic?

Remember that the power spectral density (PSD) of anything is the Fourier transform of the autocorrelation function of that process.

Hence, if you want a defined autocorrelation function (ACF), do its inverse Fourier transform, and you'll get a PSD that would represent a signal of given ACF.

Now, you can use all the beautiful methods of filter design to come up with a filter that, when applied to a white process (e.g. random numbers from a random number generator) will shape that process's PSD as desired!

So, that's kind of the general look at things: If you just want something like

"Each sample should be correlated much with the previous one, but only slightly with the one before"

then maybe understanding it as roughly

$$y[n] = 0.9x[n] - 0.1x[n-1]$$

would get you there quicker: $$(0.9, 0.1)$$ is actually the coefficient vector of a FIR filter that you can apply to your uncorrelated input vector $$x$$ and be done with it.

• So you wing it then? Nothing pre-made in the SP world? – Paul Uszak Nov 17 '18 at 0:30
• Not quite sure what you mean with "wing it". I think the first described procedure is pretty clear and well-structured. Are you expecting something different? – Marcus Müller Nov 17 '18 at 11:45