First off let me explain that I understand that frequency makes no sense for a single sample. What I am actually talking about is the power spectrum within a short time window around a specific sample.

I have a time varying discrete signal: $\ s(t_i), i=0...199 $ with sampling dt = 10 ms.

I want to find the power of a specific frequency: 15 Hz at time sample j = 100.

This is how I would solve this:

I understand that I must extract a subset of the signal in a window around j = 100 and multiply it with a window function to avoid "ringing".

I therefore extract the subset j=93..107 and multiply it with a -/+ 2 standard deviations gaussian kernel.

Any advice on the size of the window?

Next I zero-pad the subset to 512 samples in order to achieve some "spectral interpolation" and take the FFT.

Finally I locate the complex number corresponding to f=15 Hz and take the absolute value.

Actually I would repeat this procedure for j = 7...192 to find the power of f=15 Hz at each sample.

However reading about the Short Time Fourier Transform got me confused:

they seem to break the data to be transformed into overlapping chunks, window the data within each chunk, take the FFT and then somehow adding the results together!?

Is this just a matter of performance? As a first solution I would prefer a simple but slow approach (such as mine).

  • 2
    $\begingroup$ I think that the term "frequency" has no sense for a single time sample as the term "duration" has no meaning for single frequency sample. But you might be interested in the concept of "instant frequency" which still applies to a sample series, not single sample. $\endgroup$
    – mbaitoff
    Jan 31, 2013 at 14:18
  • $\begingroup$ Maybe this is just a bit sloppy languange on my part and what I should ask is: How do I find the power of a specific frequency within a window centered around a specific sample of a discrete time varying signal? This is a bit long for a question title though. $\endgroup$
    – Andy
    Jan 31, 2013 at 14:28
  • 5
    $\begingroup$ @Andy: What you're doing is the short-time Fourier transform. Any time you take a small window ("a short amount of time") from a larger signal and then calculate its Fourier transform, you're using the STFT. There are some cases where you might overlap consecutive windows, but that's not a requirement. Also, you don't necessarily need to add or average the results together; it depends on what you want. If you sum multiple transforms together, you're sacrificing time resolution in order to perhaps smooth out some noise in the spectrum. $\endgroup$
    – Jason R
    Jan 31, 2013 at 15:01
  • $\begingroup$ @Jason R: thanks! That is reassuring. Then I'll just keep doing this :-). $\endgroup$
    – Andy
    Jan 31, 2013 at 15:06

1 Answer 1


I realize this doesn't answer the detail of what you're asking, but I believe it answers the question in the title:

See Rick Lyons's writeup here for using the Goertzel algorithm to get the signal level at a specific frequency.

You can then follow up the equations:

enter image description here


$$ \hat{p}(n) = | y(n) |^2 $$

and use $\hat{p}(n)$ as your "instantaneous power" at frequency $\omega =2\pi m/N$ --- which is sort of like Lyons's eq. 13.83:

enter image description here

(though he's evaluating this one at the "end" of his DFT length).

  • 1
    $\begingroup$ Great answer. The linked page goes into full details, but 2 benefits of using Goertzel over FFT for a single specific frequency are: 1. It's MUCH faster. 2. You can have flexibility in setting the frequency. I learned Goertzel in the context of DTMF decoding where the primary benefit was freedom of frequency selection, but even for 8 frequencies it was faster than FFT. Finally, if you need to detect the dominant frequency without having a list of target frequencies in advance, you can use AMDF or ASMDF autocorrelation algorithms, but these are slower than Goertzel. $\endgroup$
    – jimhark
    Oct 19, 2016 at 22:15

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.