示例#1
0
 def test_autocorr(self):
     """correctly compute autocorrelation"""
     s = [1,1,1,1]
     X, periods = auto_corr(s, llim=-3, ulim=None)
     exp_X = array([1,2,3,4,3,2,1], dtype=float)
     self.assertEqual(X, exp_X)
             
     auto_x, auto_periods = auto_corr(self.sig, llim=2, ulim=50)
     max_idx = list(auto_x).index(max(auto_x))
     auto_p = auto_periods[max_idx]
     self.assertEqual(auto_p, self.p) 
示例#2
0
 def test_autocorr(self):
     """correctly compute autocorrelation"""
     s = [1,1,1,1]
     X, periods = auto_corr(s, llim=-3, ulim=None)
     exp_X = array([1,2,3,4,3,2,1], dtype=float)
     self.assertEqual(X, exp_X)
             
     auto_x, auto_periods = auto_corr(self.sig, llim=2, ulim=50)
     max_idx = list(auto_x).index(max(auto_x))
     auto_p = auto_periods[max_idx]
     self.assertEqual(auto_p, self.p) 
示例#3
0
 def test_hybrid_returns_all(self):
     """correctly returns hybrid, ipdft and autocorr statistics"""
     ipdft_pwr, ipdft_prd = ipdft(self.sig, llim=2, ulim=50)
     auto_x, auto_periods = auto_corr(self.sig, llim=2, ulim=50)
     hybrid_x, hybrid_periods = hybrid(self.sig, llim=None, ulim=50)
     hybrid_ipdft_autocorr_stats, hybrid_periods = hybrid(self.sig,
                     llim=None, ulim=50, return_all=True)
     self.assertEqual(hybrid_ipdft_autocorr_stats[0], hybrid_x)
     self.assertEqual(hybrid_ipdft_autocorr_stats[1], ipdft_pwr)
     self.assertEqual(hybrid_ipdft_autocorr_stats[2], auto_x)
     
     ipdft_pwr, ipdft_prd = ipdft(self.sig, llim=10, ulim=10)
     auto_x, auto_periods = auto_corr(self.sig, llim=10, ulim=10)
     hybrid_x, hybrid_periods = hybrid(self.sig, llim=10, ulim=10)
     hybrid_ipdft_autocorr_stats, hybrid_periods = hybrid(self.sig,
                     llim=10, ulim=10, return_all=True)
     self.assertEqual(hybrid_ipdft_autocorr_stats[0], hybrid_x)
     self.assertEqual(hybrid_ipdft_autocorr_stats[1], ipdft_pwr)
     self.assertEqual(hybrid_ipdft_autocorr_stats[2], auto_x)
示例#4
0
 def test_hybrid_returns_all(self):
     """correctly returns hybrid, ipdft and autocorr statistics"""
     ipdft_pwr, ipdft_prd = ipdft(self.sig, llim=2, ulim=50)
     auto_x, auto_periods = auto_corr(self.sig, llim=2, ulim=50)
     hybrid_x, hybrid_periods = hybrid(self.sig, llim=None, ulim=50)
     hybrid_ipdft_autocorr_stats, hybrid_periods = hybrid(self.sig,
                     llim=None, ulim=50, return_all=True)
     self.assertEqual(hybrid_ipdft_autocorr_stats[0], hybrid_x)
     self.assertEqual(hybrid_ipdft_autocorr_stats[1], ipdft_pwr)
     self.assertEqual(hybrid_ipdft_autocorr_stats[2], auto_x)
     
     ipdft_pwr, ipdft_prd = ipdft(self.sig, llim=10, ulim=10)
     auto_x, auto_periods = auto_corr(self.sig, llim=10, ulim=10)
     hybrid_x, hybrid_periods = hybrid(self.sig, llim=10, ulim=10)
     hybrid_ipdft_autocorr_stats, hybrid_periods = hybrid(self.sig,
                     llim=10, ulim=10, return_all=True)
     self.assertEqual(hybrid_ipdft_autocorr_stats[0], hybrid_x)
     self.assertEqual(hybrid_ipdft_autocorr_stats[1], ipdft_pwr)
     self.assertEqual(hybrid_ipdft_autocorr_stats[2], auto_x)
示例#5
0
def getPeriodAutoCorr(values):
    pwr, period = auto_corr(values)
    max_pwr, max_period = sorted(zip(pwr, period))[-1]
    return max_period