# Generate random walk from a power spectrum

I want to be able to generate a model timeseries from a given power spectrum. The power spectrum is measured from other data and hence has no fit parameters and is empirical. How does one go about generating simulated timeseries from such a PSD?

It is easy to go from signal to PSD (e.g. scipy.signal.periodogram) but what about the other way?

With DRWs you can simply generate iteratively by adding a Gaussian deviate to the previous datapoint but what do you do if the power spectrum is not analytical?

To go from a signal to a power spectrum, the Fourier Transform algorithm (or its discrete version) provides a classic method. The Inverse Fourier Transform will do the reverse.

One thing to watch for - when you generate a power spectrum from a signal, each component of the spectrum should have an amplitude AND A PHASE. You may have missing information if you only have the amplitude of the frequency components, and don't know their phase.

To generate model timeseries, you might have to iterate over randomly chosen phase values for each component of the spectrum, to generate a population of potential solutions to the signal.

If you have two separate amplitude power spectra, observed at different times, then it is possible to iteratively recover the missing phase information by transforming back and forth between signal and frequency space, and at each step when you reach frequency space, updating the amplitude estimates based on the observations. The resulting phase estimates will eventually converge on the correct solution, given sufficiently little noise in the observations. The Gerchberg-Saxton and Fienup algorithms are of interest here.