本文整理汇总了Python中timeseries.TimeSeries.mean方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.mean方法的具体用法?Python TimeSeries.mean怎么用?Python TimeSeries.mean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timeseries.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.mean方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kernelcorr
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_kernelcorr():
t1 = TimeSeries([1, 2, 3, 4], [40, 50, 60, 70])
t2 = TimeSeries([1, 2, 3, 4], [40, 50, 60, 70])
standts1 = _corr.stand(t1, t1.mean(), t1.std())
standts2 = _corr.stand(t2, t2.mean(), t2.std())
#Kernel_corr should return a correlation of 1.0 since we use similar timeseries
assert(_corr.kernel_corr(standts1, standts2, mult=1) == 1.0)
示例2: test_procs
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_procs():
# check that standardization is successful
_, t1 = tsmaker(0.5, 0.1, 0.01) # ignore meta-data returned
t2 = random_ts(2)
standts1 = stand(t1, t1.mean(), t1.std())
standts2 = stand(t2, t2.mean(), t2.std())
assert np.round(standts1.mean(), 10) == 0.0
assert np.round(standts1.std(), 10) == 1.0
assert np.round(standts2.mean(), 10) == 0.0
assert np.round(standts2.std(), 10) == 1.0
# once more, with hard-coded data so we know what answers to expect
v1 = [2.00984793, 3.94985729, 0.51427819, 4.16184495, 2.73640138,
0.07386398, 1.32847121, 0.3811719, 4.34006452, 1.86213488]
v2 = [6.43496991, 10.34439479, 11.71829468, 3.92319708, 7.07694841,
6.7165553, 5.72293448, 4.79283759, 11.74512723, 11.74048488]
t1 = TimeSeries(np.arange(0.0, 1.0, 0.1), v1)
t2 = TimeSeries(np.arange(0.0, 1.0, 0.1), v2)
standts1 = stand(t1, t1.mean(), t1.std())
standts2 = stand(t2, t2.mean(), t2.std())
assert np.round(standts1.mean(), 10) == 0.0
assert np.round(standts1.std(), 10) == 1.0
assert np.round(standts2.mean(), 10) == 0.0
assert np.round(standts2.std(), 10) == 1.0
idx, mcorr = max_corr_at_phase(standts1, standts2)
assert idx == 2
assert np.round(mcorr, 4) == 0.5207
sumcorr = kernel_corr(standts1, standts2, mult=10)
assert np.round(sumcorr, 4) == 0.0125
示例3: test_maxcorr
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_maxcorr():
t1 = TimeSeries([1, 2, 3, 4], [40, 50, 60, 70])
t2 = TimeSeries([1, 2, 3, 4], [50, 60, 70, 40])
standts1 = _corr.stand(t1, t1.mean(), t1.std())
standts2 = _corr.stand(t2, t2.mean(), t2.std())
idx, mcorr = _corr.max_corr_at_phase(standts1, standts2)
#idx should be equal to one since the second ts is shifted by 1
assert(idx == 1)
assert(np.real(mcorr) == 4)
示例4: proc_main
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def proc_main(pk, row, arg):
'''
Calculates the distance between two time series, using the normalized
kernelized cross-correlation.
Note: used directly for augmented selects.
Parameters
----------
pk : any hashable type
The primary key of the database entry
row : dictionary
The database entry
Returns
-------
[damean, dastd] : list of floats
Mean and standard deviation of the time series data
'''
# recast the argument as a time series (type is lost due to serialization)
if isinstance(arg, TimeSeries):
argts = arg # for server-side testing
else:
argts = TimeSeries(*arg) # for live client-side operations
# standardize the time series
stand_argts = stand(argts, argts.mean(), argts.std())
# standardize each row of the data that has tripped the trigger
stand_rowts = stand(row['ts'], row['ts'].mean(), row['ts'].std())
# compute the normalized kernelized cross-correlation between the
# time series being upserted/selected and the time series argument
kerncorr = kernel_corr(stand_rowts, stand_argts, 5)
# use the normalized kernelized cross-correlation to compute the distance
# between the time series and return
return [np.sqrt(2*(1-kerncorr))]
示例5: test_mean
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_mean(self):
t1 = TimeSeries([1, 2, 3, 4], [40, 50, 60, 70])
self.assertEqual(t1.mean(),55.0)
示例6: test_emptyMean
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_emptyMean(self):
t2 = TimeSeries([], [])
with self.assertRaises(ValueError):
t2.mean()
示例7: test_mean
# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import mean [as 别名]
def test_mean(self):
x = TimeSeries([1, 2, 3, 4],[1, 4, 9, 16])
self.assertTrue ( x.mean() == 7.5)