In [1]:
from _corr import ccor


Generating LALR tables
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-1-676030bade8b> in <module>()
----> 1 from _corr import ccor

/Users/yuhantang/CS207/TimeSeries/procs/_corr.py in <module>()
      6 import sys
      7 #sys.path.append("/Users/yuhantang/CS207/TimeSeries/procs")
----> 8 from .interface import *
      9 
     10 def createfromlist(l):

SystemError: Parent module '' not loaded, cannot perform relative import

In [3]:
import sys
sys.path.append("/Users/yuhantang/CS207/TimeSeries/procs")

In [4]:
from _corr import ccor


---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-4-676030bade8b> in <module>()
----> 1 from _corr import ccor

/Users/yuhantang/CS207/TimeSeries/procs/_corr.py in <module>()
      6 import sys
      7 #sys.path.append("/Users/yuhantang/CS207/TimeSeries/procs")
----> 8 from .interface import *
      9 
     10 def createfromlist(l):

SystemError: Parent module '' not loaded, cannot perform relative import

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]:
128

In [68]:
start = time.time()
for i in range(10000):
    _corr.ccor(ts1,ts2)
print('Test Time is %.2f'%(time.time() - start))


Test Time is 5.25

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))


Test Time is 3.00

In [ ]:


In [ ]: