Skip to content

Instantly share code, notes, and snippets.

@jameslyons
Created January 31, 2014 14:01
Show Gist options
  • Save jameslyons/8732536 to your computer and use it in GitHub Desktop.
Save jameslyons/8732536 to your computer and use it in GitHub Desktop.
# return the autocorrelation of x
function ac(x)
N = length(x)
# zero pad x
x = [x,zeros(N-1)]
R = irfft(abs(rfft([2,3,1,0,0])).^2, 2*N-1)
R[1:N]
end
x = [2,3,1]
print(ac(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment