Endpoint detection

1. Jul 13, 2004

Hi all,
I am trying to write a code that can determine peaks in a signal. What I am doing is recording a signal then running an fft to calculate the fundamental frequency and the overtones (consonant and dissonant harmonics). The problem is that some of the peaks are very small but are always distinguishable by looking at the plotted results. Has anyone had any experience with writing a code that could distinguish peaks from noise.

Thanks
Jay

2. Jul 13, 2004

chroot

Staff Emeritus
Compute the mean and standard deviation of the values in the bins. Then it should be easy to recognize peaks that are say, two standard deviations greater than the mean.

- Warren

3. Jul 13, 2004

Thanks for your reply, but unfortunately I am not that educated in these terms. Could you really spell it out for me...I don't know what is the "mean" and "standard deviation(although I can guess at this)" of values in the "bins".
Sorry to make you elaborate, but I am kinda new to this stuff.

Thanks
Jay

4. Jul 13, 2004

chroot

Staff Emeritus
When you take an FFT, the resulting array of numbers is often referred to as an array of "bins," since each number actually indicates the power in a small range of frequencies. You can just call them numbers if you like.

The arithmetic mean of the array is simply the average value. Add all the bins and divide by the number of bins to get the mean. I will denote the values in the bins as x, and the mean of those values as $<x>$.

The standard deviation is a measure of the spread in the data. Since most of the bins contain nothing but noise and have roughly the same value, the data generally has a small spread. Calculate the standard deviation ($\sigma$) as

$$\sigma = \sqrt{<x^2> - <x>^2}$$

In words, take the mean of the squares of all the bins, subtract the square of the mean of the bins, and take the square root of it all. The resulting number represents how much a typical bin differs from the mean. Any bin that contains significantly more power than the mean plus this typical difference -- say, a bin whose value is several standard deviations above the mean -- is probably a peak.

- Warren

5. Jul 14, 2004