In [1]:
from _corr import ccor
In [3]:
import sys
sys.path.append("/Users/yuhantang/CS207/TimeSeries/procs")
In [4]:
from _corr import ccor
In [38]:
from interface import *
from timeseries import TimeSeries as ts
import numpy as np
import time
In [25]:
from procs import _corr
In [53]:
ts1 = ts(range(0,128),range(0,128))
ts2 = ts(np.random.randint(0,10000,size = 128),np.random.randint(0,10000,size = 128))
In [70]:
len(ts2.values())
Out[70]:
In [68]:
start = time.time()
for i in range(10000):
_corr.ccor(ts1,ts2)
print('Test Time is %.2f'%(time.time() - start))
In [66]:
import numpy.fft as nfft
def ccor(ts1, ts2):
"given two standardized time series, compute their cross-correlation using FFT"
#your code here
#print(type(ts1))
#print(type(ts1.values()))
f1 = nfft.fft(ts1.values())
f2 = nfft.fft(ts2.values())
#print(f1)
ccor_value = nfft.ifft(f1 * np.conj(f2)).real
return 1/len(ts1) * ccor_value
In [71]:
start = time.time()
for i in range(100000):
ccor(ts1, ts2)
print('Test Time is %.2f'%(time.time() - start))
In [ ]:
In [ ]: