# Calculating the instantaneous period of a wave

I have a set of data which represents slightly imperfect waves of varying amplitudes and periods. I wish to calculate the instantaneous period of the wave around any point within this data set - simply finding the local minima and maxima representing each individual wave and calculating the frequency of these is not precise enough for my needs.

Is there a known algorithm that can achieve this? Even better, an existing implementation of this algorithm? I am currently programming in R, but am willing to switch if needed.

n.b. if this is the wrong StackExchange site for this question, please direct me to a better one.

The instantaneous frequency of a wave is defined as $f(t) = \frac{1}{2\pi}\frac{d\phi}{dt}$ where $\phi$ is the instantaneous phase. See the Wikipedia page on Instantaneous Frequency.

Presumably you have discrete data, in which case you need to estimate $\phi$ and its derivative numerically.

This isn't an entirely meaningful measure, since it doesn't make very much sense to ascribe a frequency to a non-periodic function, but nonetheless there does seem to be a convention for it.

Let me close by saying that I don't consider this a TCS problem. It is firmly in signal processing territory, and so I wouldn't consider here the ideal venue for such questions.

There is no such thing as the instantaneous period of a wave. The Heisenberg uncertainty principle guarantees this. Oh you can find a set of estimated frequencies for a given window over the signal, but that is frequencies for the whole window, not for that instant. You need to figure out what size of time-frequency window satisfies your needs and then calculate something the Fourier transform for that window over the entire signal (and maybe search the resulting frequencies for the peak).

Two things to remember, the larger the window, the higher the frequency resolution (how many frequencies you can see), but the smaller the time resolution (when something happened--and this is a bit hard to explain as it's been a few years since I've had to learn and deal with it extensively so I may not be saying it right).

Another factor is that amplitude (multiplication in the time domain) is convolution in the frequency domain. To remove some artifacts of that you may have to do some filtering (that is, convolution in the time domain or multiplication in the frequency domain.) It might even make sense to filter with one widow size then do analysis with another window size. There's a lot of finicky business when it comes down to signal sampling.

Edit:

Ok, this "Heisenberg uncertainty principle" with regard to signal sampling is not some random thing I pulled out of my ear one day. It is, AFAIK, a well established concept within Wavelet literature. (Wavelets involve a whole family of mathematical non-Fourier techniques to analyze a signal) "The World According to Wavelets: The Story of a Mathematical Technique in the Making" by Barbra Burke Hubbard (ISBN 1-56881-072-5) devotes at least one (if not two) chapters to the subject and has a proof in the Appendices.

According to her, (I'm going to have to paraphrase as my attempts to translate to Mathjax/TeX/LaTeX are failing, please also forgive as it's been years since I've looked at this anyway) For every $f(t)$ ($t$ a real number) such that the integral (from negative infinity to positive infinity) of $|f(t)|^2$ with respect to $t$ equals $1$, the product of the variance of $t$ and the variance of $\tau$ (the variable of $\hat f$) is at least $1/(16*\pi^2)$, and then gives a large, explicit inequality to state what exactly she means with further non mathematical explanation throughout the chapter.

I will make no attempt to explain further, partially for fear I'd likely mess up. But if you want, you can read that and/or its references and see that, yes, the Heisenberg uncertainty principle does indeed apply here.

• This has absolutely nothing to do with the Heisenberg uncertainty principle. – Joe Fitzsimons Jun 4 '12 at 0:35
• JayC and @DavidCary: I'm not suggesting I haven't seen this claim before, simply that it is wrong. The Heisenberg uncertainty principle is a statement about the existence of non-commuting observables in quantum mechanics. People sometimes like to draw an analogy signal processing, but in signal processing the observables do commute. The analogy is used because signals aren't necessarily of a defined frequency or position, which is similar to the quantum case where the quantum state is not an eigenstate of the measurement. – Joe Fitzsimons Jun 6 '12 at 4:01
• But it is only that, an analogy. In particular you can make both position and frequency measurements of a classical waveform without disturbing it. Thus [p,x]=0, counter to the quantum case. By the way, the -1 didn't come from me, as I thought the rest of the answer was okay. – Joe Fitzsimons Jun 6 '12 at 4:02
• @JayC: There is something called the Gabor limit in signal processing, which is a consequence of some theorems related to the uncertainty principle, but not a direct consequence of the uncertainty principle itself, which say that you can't simultaneously localize the value of a function and its Fourier transform. The consequence for signal processing is that you can't simultaneously filter tightly in both position and frequency domains. The filtering is mathematically similar to the effect of a projective measurement in quantum mechanics, and so you see similar results. – Joe Fitzsimons Jun 8 '12 at 16:37
• However, even given the above, you use the Heisenberg uncertainty principle above is in the context of measurement, which is not the same as filtering. A classical measurement does not apply a projection operator (like a filter based on the output), unlike quantum measurements, thus the measurements commute and so there is no uncertainty principle. It may be true that there is a relationship between variances which looks similar to the quantum case, but this would no longer bare any reasonable relationship to the original Heisenberg uncertainty principle. – Joe Fitzsimons Jun 8 '12 at 16:44