# Peak frequency of a signal depending on the length of the signal

Hello everyone!

I am generating a signal as a function of time. This is an irregular signal generated by using the superposition principle and random phase. Thus I actually have already all the frequency components of the signal. And from the frequency components I know that there is also a frequency which has the highest amplitude, implying that this is the peak frequency. For the sake of argument lets say the peak frequency is 0.2 Hz.

With these frequency components I generate the signal with random phases, which is 300s long. If I now transform the signal from time domain to frequency domain by applying the Fourier transformation I get all the frequency components again. From the results I can see that the peak frequency is 0.2 Hz - the same peak frequency as the signal was generated with.
But now when I only take the first 30 seconds of the signal, should the peak frequency still be 0.2 Hz? Or is 0.2 Hz the peak frequency for the whole signal (300s)?

I hope you understand my question :)
Thanks!

## Answers and Replies

Baluncore
Science Advisor
If I understand correctly:
You generate several frequency components with random phase;
the frequency components each have a constant amplitude over the 300 sec period;
you sum the frequency components to generate the signal in the time domain.

It does not matter which section of the time domain signal you sample and analyse with the FFT, it will have the same amplitude and power spectrum. The phase of the frequency components analysed by the FFT will be dependent on the position in time of the limited sample.

You almost understand me - what I meant is that I have frequency components, each with different amplitude. The highest amplitude is for 0.2Hz. Then I sum these components to generate the signal in the time domain.

Last edited:
Baluncore
Science Advisor
I think I understood you, I just did not express myself clearly.
The selected frequency components have different amplitudes, but the amplitude of the individual frequency components do not change during the synthesis process.

Considering that FFT synthesis is the inverse of FFT analysis, it should not matter which section of time you analyse. My answer holds.

300 seconds at 0.2Hz gives 60 cycles, so there is some room to reduce the sample time.
For short samples noise will increase. There will also be sampling differences due to windowing end effects.
You must sample sufficient signal to resolve and separate the components.

Okay, this makes sense. Because at every time instant I sum all the frequency components and the peak frequency is always the same. And thus when taking the FFT for a certain length of the signal, the peak frequency should be the same.

This is what I am experiencing, the shorter the sample the more noise I have and the harder it is to detect the peak frequency. But what do you mean that there is some room to reduce the sample time?

Baluncore
Science Advisor
What window function do you apply before your FFT analysis?
You must sample at twice the highest frequency present or you will get aliasing. The step, where the end of the time window wraps around to meet the beginning, has high frequency information that may cause problems. The ends of the time window you analyse need to be tapered by multiplying the signal by a window function to reduce the high frequency noise. The windowing will broaden the analysed peaks, because multiplication in the time domain is a convolution in the frequency domain.

This is not a problem with a synthetic signal having integer frequencies because the ends of all the superposed sinusoids line up. But when fractional frequencies are present, or you take a section only of the synthesised signal, there will be a step.

So long as you have half a dozen cycles in your sample you should get an accurate peak. But if you have two similar frequencies present they may begin to merge and corrupt your amplitude estimate. If you only have two cycles present, the window function will broaden the frequency of 2 and spread it from DC to 4.

• 1 person
sophiecentaur
Science Advisor
Gold Member
2020 Award
@Fluidman117
I am not sure what you really mean by "peak frequency"
Can you confirm that you mean the frequency of the main peaks in amplitude of the resulting time domain signal?
To be sure that you can identify these peaks, (which will be due to the 'beats' between the various components) you may (I think) need to take a length of resulting signal samples that is greater than the reciprocal of the integer step size of the specification of the input frequency components. (i.e. the frequency resolution of your synthesiser algorithm).
I don't think there is a way round this if you are generating your 'random' levels and frequencies over a shorter time with an algorithm because you may well get the same answer each time and 'miss' the possible maximum. In practice, it may not be that bad but, if you think in terms of truly random noise, there is no defined peak amplitude as the distribution is open ended.

@Baluncore
Before I didn't use any window function at all, but later tried the Hanning window, which reduced the peak at higher frequencies. This gave me slightly improved results. But thanks for the insight!

@sophiecentaur
I have an amplitude spectrum, in which y-axis is the amplitude and x-axis is frequency. Then I have different frequency components each with its own amplitude. And the frequency component that has the highest amplitude is the peak frequency in this case.
I don't exactly understand what do you mean by 'there is no defined peak amplitude as the distribution is open ended?

sophiecentaur
Science Advisor
Gold Member
2020 Award
@Baluncore
Before I didn't use any window function at all, but later tried the Hanning window, which reduced the peak at higher frequencies. This gave me slightly improved results. But thanks for the insight!

@sophiecentaur
I have an amplitude spectrum, in which y-axis is the amplitude and x-axis is frequency. Then I have different frequency components each with its own amplitude. And the frequency component that has the highest amplitude is the peak frequency in this case.
I don't exactly understand what do you mean by 'there is no defined peak amplitude as the distribution is open ended?

If you take a truly noise like (random) signal, there is no limit to its peak value. There is a probability distribution. If you look in the frequency domain, there will be a continuum of components and they can add together, once in a long time, to produce an enormous peak. Given infinitely long, the peak amplitude is not limited. In a pseudo random signal, the peak value will occur once per repeat cycle and the repeat period is the reciprocal of the smallest frequency step size. (Not directly relevant to your basic problem, perhaps)

I understand that, after synthesising a waveform with (pseudo) random frequency components you are doing a discrete Fourier transform of a time-windowed portion of the resulting amplitude samples. The window was, initially, a rectangular window and later an alternative shape. Windowing in time is, essentially, modulating the original waveform (AM of each of the original frequency components) and it will produce sidebands on each of those components, which can modify the component values at other frequencies. The grossest distortion is with a rectangular window and that, I think, will produce the biggest variation in your output spectrum. Windowing with a well behaved shape would produce a frequency spectrum that is more like the original for all positions of the window in time because the modulation products are reduced. That is one way of looking at what is happening.
It seems to me that the 'softer' the window, the more likely it is that the peak frequency is the same (0.2Hz) as you started with.

Baluncore
Science Advisor
sophiecentaur said:
I understand that, after synthesising a waveform with (pseudo) random frequency components you are doing a discrete Fourier transform of a time-windowed portion of the resulting amplitude samples.
The amplitude and frequency of the frequency components was fixed. Only the phase was random.

The “peak frequency” being considered by Fluidman117 is not in the time domain. It is in the frequency domain following FFT analysis. It was synthesised deliberately by superposition in the time domain, with fixed amplitude frequencies, but random phase.

sophiecentaur
Science Advisor
Gold Member
2020 Award
The amplitude and frequency of the frequency components was fixed. Only the phase was random.

The “peak frequency” being considered by Fluidman117 is not in the time domain. It is in the frequency domain following FFT analysis. It was synthesised deliberately by superposition in the time domain, with fixed amplitude frequencies, but random phase.

Yes. The 'fixed amplitudes' of the components are presumably not all equal (0.2Hz being the maximum?). If he is taking a subset of the full set of samples and then doing an FFT, then the FFT is of an amplitude modulated version of the original time domain signal.
The 'spectral peak' would not necessarily be unchanged for all possible waveforms - e.g., where the spectrum is relatively flat around the peak and sidebands due to the windowing could increase a nearby component amplitude.
I often think that some diagrams would help a lot in this sort of discussion.