I am trying to calculate the fundamental frequency (pitch) from autocorrelation method. Below is the figure of the signal I have.enter image description here

The autocorrelation that I calculated by the following code in python is given in the picture below:

        N = len(kiri) #here kiri is the input signal shown in the above pic
        r = np.zeros(nlags) #
        for lag in range(nlags):
            for nl in range(N - lag):
                r[lag] += kiri[nl] * kiri[nl + lag]

autocorrelation output

Now what I want to know is that, is the autocorrelation supposed to have zero crossings in all cases of input signals? if yes, then does that mean the abouve autocorrelation result is wrong ?

When I try to use the above autocorrelation results to calculate pitch using Mcleod Pitch Method, the NSDF function does not have zero crossings hence unable to calculate pitch. (link for reference of this method is in the comments)

Is this autocorrelation calculation method correct ? Or since the input signal itself is not exactly a periodic signal, the autocorrelation won't have zero crossings ?

Please help.

  • \$\begingroup\$ cs.otago.ac.nz/tartini/papers/A_Smarter_Way_to_Find_Pitch.pdf \$\endgroup\$
    – Kanmani
    Sep 14, 2017 at 6:18
  • 6
    \$\begingroup\$ Your signal has a DC offset. That can cause problems with correlation. Your signal looks like noise to me. Pure white noise has but a single correlation at zero time. Maybe your real signal is very slow, and you only have a small section of the wave (causing the apparent DC offset) along with some noise. \$\endgroup\$
    – JRE
    Sep 14, 2017 at 11:21
  • \$\begingroup\$ This question should be in signal processing forum, you’d have much better insights \$\endgroup\$
    – PDuarte
    Aug 21, 2018 at 11:53

2 Answers 2


Yes, the autocorrelation can have zero crossings. A negative autocorrelation value means that the two signals are anti-correlated, i.e. they have similar magnitude, but opposite sign.

If you want to find the pitch, I would recommend reading "Spectral Analysis of Signals", by Petre Stoica and Randolph Moses, it reviews the most common methods and their properties.


Maybe error in somewhere! If a non-zero signal hasn't DC ie. its average value=0 then its autocorrelation function should have zero crossings. I do not know an exception, but that of course is not a proof.

Addendum: Test your autocorrelator. Input a sinewave and see, if there occur alternate plus and minus peaks at delays which are multiples of a half period.

You probably can subtract the average from your signal without substantial overhead to the calculations. Then the average surely is zero.

  • 1
    \$\begingroup\$ The average value of this signal looks non zero to me \$\endgroup\$ Sep 14, 2017 at 11:01
  • \$\begingroup\$ There is a zero crossing, way at the left on the graph. \$\endgroup\$ Sep 14, 2017 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.