2

I used numpy fft.fft to analyze some time series data (black) and generate a plot like the following:

enter image description here

From the FFT data (in red) i calculated mean frequency by multiplying x*y for each data point and dividing by the number of data points. Is this correct? or am i misunderstanding what the y-axis means.

if this is incorrect, how are mean and median frequency calculated, or are those not useful metrics?

Thank you for your time and consideration.

Bobby M
  • 159
  • 1
  • 2
  • 9

1 Answers1

0

First of all you probably want to do this in terms of power not amplitude, so I would square the y axis. Also, to calculate the mean you multiply x*y at each data point, add them up, and at the end you divide by the total power, so the sum of all the y values.

Bootstrap
  • 103
  • 7
  • hi, thanks for your response, to clarify, are you suggesting to square the y axis for display purposes or are you saying i should square the y-axis before doing the mean calculation that you describe. also, is median frequency a useful thing to calculate? if so can you suggest where i might find how to calculate that? thanks – Bobby M Aug 29 '17 at 15:29
  • I would square it for display and for calculating the mean. By squaring it you put your data into Watts which is a useful unit. I can't say for sure, but I'm not sure how useful mean or median frequency are, what are you trying to use them for? – Bootstrap Aug 29 '17 at 16:45
  • I am a biologist, and i have two groups of zero-mean time course data (like the black plot in my figure). I am interested in quantifying, what my eyes show, which is that in one group, there is more high frequency fluctuation than in the other group. – Bobby M Aug 29 '17 at 20:27
  • Ah ok. Mean/median frequency would be a decent metric for that. Another one I think would be good is would be to express the fraction of the total power in the band you are interested. For example, if you think for one signal there is more energy between 30-60 Hz, you could find the total power in that region and normalize it by dividing by the total power of the signal and see if one signal has a higher ratio than the other. Also, I looked closer at your plot and the frequency axis seems wrong, the values are really small. Also I wouldn't use log scale for the frequency axis – Bootstrap Aug 30 '17 at 00:14
  • You have answered my immediate question about calculating mean frequency. so i have marked your answer correct. This has raised further questions for me though, so i have started a new question https://stackoverflow.com/questions/45966038/getting-counterintuitive-results-with-numpy-fft-when-calculating-mean-frequency thanks for your help. – Bobby M Aug 30 '17 at 17:03