# Play with a Gaussian Random Set in the Frequency Domain to Obtain Desired Effect in the Time Domain

Please assume we have a set of 100 random numbers obeying Gaussian PDF in time-domain. Let's index them 1-100.

Within a time-accurate simulation, I apply four operations on this dynamic set every time-step:

1. Use the entire set for some mathematical operation
2. Then, remove, say, the last 10 numbers of the set (indices:91-100)
3. Shift the remaining 90 numbers forward from the indices:1-90 to 10-100
4. Generate 10 new Gaussian random numbers and put them into the emptied indices:1-10. And the entire set should still obey Gaussian PDF.

I want to obtain these time-domain changes via performing some operations in the frequency domain.

However, I do not know how I should play with the frequency-domain counterpart of the set, so that I obtain the same (or similar) results as if performing time-domain operations above.

The obscure form of the question:

One can generate random samples of Gaussian distribution directly in the frequency domain as explained here, and exemplified with a Python snippet here.

Let assume we generate a one-dimensional set consisting of uniformly-spaced 100 Gaussian random samples, $X(f)$.

I want to manipulate the set as such its time-domain counterpart, i.e. $x(t)$, is:

1. Index-shifted by N positions in a circular manner,
2. Then, (only) its first N elements being replaced by new N random samples.

For the first item, this gives the answer. For the second, however, I am perplexed.

Could you please tell us how to insert this new N random samples directly into the existing set in the frequency domain, so that we can avoid possibly(?) redundant FFTs otherwise?

• I still don't understand what you want to do. Could you try be clearer?
– Royi
Jun 4 '18 at 19:54
• @Royi My apologies, I wanted to generalise my question, so it becomes obscure. I now do clarify my question. Jun 4 '18 at 20:12

You're asking to do a localized operation in time using the Frequency Domain.

It's going to be not elegant, really.

Here what you can do:

1. Define the input signal in frequency domain as $X \left[ k \right]$.

2. Multiply by Linear Phase in Frequency Domain to apply circular shift in time domain.
This means samples 1-90 will become 11-100 and 91-100 will become 1-10. Lets' call this multiplied signal $\hat{X} \left[ k \right]$.

3. Pre calculate the DFT of a signal which is 1 for the first 10 samples and then zero for samples 11-100. Lets call it $H \left[ k \right]$. This is basically a windows on the first 10 samples. In order to extract the 10 first samples in time domain we would multiply by it. In the frequency domain it means we will apply Convolution. The result of the convolution will be a frequency domain signal which is equivalent of the DFT of only the 10 first samples padded with 90 zeros. Keep this result on side. Let's Call it $Y \left[ k \right] = \hat{X} \left[ k \right] \ast H \left[ k \right]$.
4. Generate noise on frequency domain which is with the properties needed of generate what's needed on time domain. Convolve the generated noise with $H \left[ k \right]$ which will again extract a signal which is equivalent to only 10 first samples in time domain. From this signal, lets call it $Z \left[ k \right]$ subtract the signal $Y \left[ k \right]$.
5. Add the result to $\hat{X} \left[ k \right]$. Now the signal $\hat{X} \left[ k \right] + Z \left[ k \right] - Y \left[ k \right]$ is what you're after.

Pay attention that doing this in Fourier domain might be much less efficient than doing it in time domain.
As you need to apply convolution twice instead of doing 2 DFT's.