# FFT of random binary data

I am trying to make sense of FFTs and binary data.

Say I have a series of random binary data, which is measured with a repetition rate of 400Hz (interval time of 0.0025s). I have a total of 12489 points, which corresponds to a total measurement time of about 31 seconds.

I would like to be able to learn more about what I would expect an FFT of this data to look like.

Some things I would like to understand the significance of:

• What should be the average amplitude of the data, post-FFT?
• what is the significance of the maximum amplitude of binary data that is not random, but consists of 1,0,1,0,1,0 data (12489 points). How can this help me find my y-scale?

## migrated from physics.stackexchange.comMar 25 '13 at 10:57

This question came from our site for active researchers, academics and students of physics.

• Thank you. Although y.size may be answered by some users here (I hope!) – ElizabethPor Mar 25 '13 at 0:13

I had a similar question myself, so I created a html demo to test this.

I think you may find it useful in understanding what the FFT is actually doing since you can also read and edit the source code.

https://seanwasere.gitlab.io/FFTBinary

This demo is doing FFT analysis of binary data. 1s and 0s

In my demo I have 1024 bits, and I convert them into an 8 bit wav, and then analyse it using the browsers inbuilt audio api fft analysis function. Firefox browser works best in my case.

The 8 bit wav is

• 1 channel
• samplerate 48000
• 1024 bits = 0.021333333333333332 seconds in length
• the 1s and 0s are actually converted behind the scenes to 256s and 128s

In the user interface there are 4 panels

• 1st is the FFT result of the binary data drawn as a spectrum graph,
• 2nd is the FFT result drawn as a waveform. It is essentially triangular spikes or squares, depending on the sequence 0,1,0 or 0,1,1,0.
• 3rd panel is a view of the actual binary data that was converted into the waveform before FFT analysis.
• 4th panel is your options, you can
• set to have a '1' every N bits by using modulus,
• and/or play random 1s and 0s which I call binary white noise.
• set the FFT buffer size, the lower numbers such as 128 give lower quality output but is much faster to compute.

The source code is MIT so you can play around with it.

The output will depend on the exact type of random law that creates the binary points.

For the mean and maximum amplitude of you sample signal, you can apply Parseval's identity that states that the energy of the input signal is preserved (up to a $2 \pi$ constant factor in 1D). The maximum peak is obtained in the case where there is only one non-null frequency in the analysis.

First: don't say FFT when you actually mean DFT (Discrete Fourier Transform) (FFT is just an algorithm that computes efficiently the DFT).

Second: the Fourier transform of random data (stochastic process) is rather tricky to work with/interpret. You should first try to understand the DFT for deterministic data.

Third: in most typical applications, you don't take the Fourier transform of the "full signal" (12489 samples=31 seconds), but rather segment it in short "frames" and take the DTF of each frame.

What should be the average amplitude of the data, post-FFT?

You must remember that the DFT is not real but a complex signal. If you are insterested only in magnitudes, of course you can take the (squared) absolute value of it. Now, if the signal is random, this is equivalent of getting a Periodogram, which is an estimate of the Spectral density of the signal. The "spectrum" (not random) of a random signal is the fourier transform, not of the signal itself, but of the autocorrelation function. Informally, it measures how much "energy" the signal has in each frequency band.

So, the answer of your question is not simple. The only simple property that could help is is the Parseval theorem: this says that the mean squared value of the spectogram equals the mean squared value of the signal ("total energy"), properly normalized.

Another property (for deterministic signals) is that the zero frequency value of the DFT is the mean value of the signal, properly normalized.

what is the significance of the maximum amplitude of binary data that is not random, but consists of 1,0,1,0,1,0 data (12489 points).

Such a signal has almost all its enery at the highest frequency (plus a zero-frequency component, given by its mean value =1/2. Hence, its DFT will be practically zero everywhere except at frequency zero, and at k=N/2 (wchich corresponds to maximum frequency).

• +1 especially for that first sentence but, alas, you are fighting a battle that was lost a long time ago in the signal processing community. – Dilip Sarwate Mar 25 '13 at 19:41

In the general case when the data are random, the Wiener-Khinchin theorem tells you what the amplitude of the power spectrum should be, given it's autocorrelation function.

In your case, the data is essentially a 200 Hz sinusoid sampled at 400 Hz, i.e.: $$x[n] = x(n T_s) = 0.5\cos(2\pi (200)t) + 0.5 \bigg|_{t = n T_s} = 0.5\cos(\pi n) + 0.5$$

In this case in the spectrum you will see a DC component (0 Hz) and a 200 Hz component.

The amplitude of the DC component will be 12489/2, because you are just summing up 0.5 12489 times. The amplitude of the 200 Hz component observed will depend on the FFT length. If you zero pad to an even integer greater than 12489, the height will also be 12489/2 for the 200 Hz component.