I have around 1000 different time series, and for each one of them I want to automatically determine if there is any seasonality in the time series.

Given the assumption that there is seasonality present, it is easy to determine periodicity from FFT or PSD.

But how do you automatically decide that there is no seasonality or periodicity in the signal based on FFT or PSD?

def psd_time_series(y):
   yAC = np.correlate(Y-np.mean(Y), Y-np.mean(Y), mode='full')
   yAC = yAC/np.max(yAC) # not necessary, but scales large values
   fft_yAC= np.fft.fft(yAC)
   freqs = np.arange(0,len(fft_yAC))/len(fft_yAC)
   psd = 10*np.log10(np.abs(fft_yAC)/max(np.abs(fft_yAC))
   return psd,freqs

def determine_if_seasonal(psd):
    ### part I need help with

def detect_seasonality(y):

   psd,freqs = psd_time_series(y)
   seasonality = ... #### do some check of PSD to determine if seasonal

   if seasonality:
       periodicity = round(1/freqs[psd.argsort()[::-1]][0])
       periodicity = None
   return periodicity

What would be a way of automatically determining that a single spike or Gaussian noise does not have seasonality based on the FFT or PSD of the time series? Is there any rule of thumb for the threshold of the magnitude of PSD? The prominence of peaks? Height of peaks?

For example, a PSD plot of a single spike might look like

enter image description here

FFT of a single spike

enter image description here

Or PSD of Gaussian noise might look like

![enter image description here

FFT of Gaussian noise

enter image description here

Or PSD of an actual signal with periodicity might look like

enter image description here

FFT of the same signal

enter image description here

Appreciate any input or insights.

  • $\begingroup$ your ffts clearly have very different lengths. Do the FFT of white noise (gaussianness doesn't matter, whiteness matters, and those are different things!) that has the same length as your signals, and you will have an answer quite apparent. $\endgroup$ Sep 27, 2021 at 10:08

1 Answer 1


... it is easy to determine periodicity from FFT or PSD ...

If you are assuming data corrupted by random noise, you can't say definitively that there is periodicity. You can only assign a confidence that there really is periodicity. That confidence may be very, very high (i.e., it's September, I'm in a temperate region of the Northern hemisphere and it's raining -- based on my own life experiences and weather reports going back to the 19th century, I'm very confident that this is a normal occurrence around here). But it could all be random -- if rare -- chance.

... But how do you automatically decide that there is no seasonality or periodicity ...

Just as you can't determine periodicity, you can't determine lack thereof. What you can do is assign some numerical threshold to the amount of periodicity in some piece of data and -- assuming you know the degree to which the data is corrupted by random noise -- you can assign a confidence to the hypothesis that there is, in fact, no periodicity.

Search on "confidence interval testing". You'll find that there's a bit of controversy surrounding exactly how it's used in the social sciences these days, and the means of misuse can extend to the physical sciences. So understand how it works, and be careful!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.