Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Endpoint detection

  1. Jul 13, 2004 #1
    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. jcsd
  3. Jul 13, 2004 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  4. Jul 13, 2004 #3
    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
     
  5. Jul 13, 2004 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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 [itex]<x>[/itex].

    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 ([itex]\sigma[/itex]) as

    [tex]\sigma = \sqrt{<x^2> - <x>^2}[/tex]

    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
     
  6. Jul 14, 2004 #5
    When I take an FFT I get a mirror reflection opposite the peaks. Do I take these as well when calculating the mean?
    Also, when I calculate the standard deviation it gave me this number:
    0 +5.8949e+004i
    What does this mean?
    do I add this to the mean to find out what is considered a peak?
    Or did I do something wrong?


    Thanks
    Jay
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?