Created
January 31, 2014 14:01
-
-
Save jameslyons/8732536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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