当前位置: 首页>>代码示例>>Python>>正文


Python TimeSeries.std方法代码示例

本文整理汇总了Python中timeseries.TimeSeries.std方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.std方法的具体用法?Python TimeSeries.std怎么用?Python TimeSeries.std使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timeseries.TimeSeries的用法示例。


在下文中一共展示了TimeSeries.std方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_procs

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [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
开发者ID:Elena-Zhao,项目名称:cs207project,代码行数:34,代码来源:test_procs.py

示例2: test_kernelcorr

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [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)
开发者ID:207leftovers,项目名称:cs207project,代码行数:9,代码来源:test_corr.py

示例3: test_maxcorr

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [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)
开发者ID:207leftovers,项目名称:cs207project,代码行数:11,代码来源:test_corr.py

示例4: proc_main

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [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))]
开发者ID:Elena-Zhao,项目名称:cs207project,代码行数:40,代码来源:corr.py

示例5: test_std2

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [as 别名]
 def test_std2(self):
     t1 = TimeSeries([1, 2, 3], [10, 100, 1000])
     t2 = TimeSeries([4, 6, 8], [100, 1000, 10])
     self.assertEqual(t1.std(), t2.std())
开发者ID:CS207Project,项目名称:cs207project,代码行数:6,代码来源:test_TimeSeries.py

示例6: test_std1

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import std [as 别名]
    def test_std1(self):
        t1 = TimeSeries([1], [10])

        with self.assertRaises(ValueError):
            t1.std()
开发者ID:CS207Project,项目名称:cs207project,代码行数:7,代码来源:test_TimeSeries.py


注:本文中的timeseries.TimeSeries.std方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。