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


Python statistics.median_high方法代码示例

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


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

示例1: get_avg

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def get_avg(metrics: List):
        return median_high(metrics) 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:4,代码来源:average_strategies.py

示例2: test_even_ints

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def test_even_ints(self):
        # Test median_high with an even number of ints.
        data = [1, 2, 3, 4, 5, 6]
        assert len(data)%2 == 0
        self.assertEqual(self.func(data), 4) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_statistics.py

示例3: test_even_fractions

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def test_even_fractions(self):
        # Test median_high works with an even number of Fractions.
        F = Fraction
        data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), F(4, 7)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_statistics.py

示例4: test_even_decimals

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def test_even_decimals(self):
        # Test median_high works with an even number of Decimals.
        D = Decimal
        data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), D('4.4')) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_statistics.py

示例5: MEDIAN_HIGH

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def MEDIAN_HIGH(df, n, price='Close'):
    """
    High median of data
    Returns: list of floats = jhta.MEDIAN_HIGH(df, n, price='Close')
    """
    median_high_list = []
    if n == len(df[price]):
        start = None
        for i in range(len(df[price])):
            if df[price][i] != df[price][i]:
                median_high = float('NaN')
            else:
                if start is None:
                    start = i
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
    else:
        for i in range(len(df[price])):
            if i + 1 < n:
                median_high = float('NaN')
            else:
                start = i + 1 - n
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
    return median_high_list 
开发者ID:joosthoeks,项目名称:jhTAlib,代码行数:29,代码来源:statistic_functions.py

示例6: test_secint

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def test_secint(self):
        secint = mpc.SecInt()
        y = [1, 3, -2, 3, 1, -2, -2, 4] * 5
        random.shuffle(y)
        x = list(map(secint, y))
        self.assertEqual(mpc.run(mpc.output(mean(x))), round(statistics.mean(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x, mean(x)))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(stdev(x))), round(statistics.stdev(y)))
        self.assertEqual(mpc.run(mpc.output(pvariance(x))), round(statistics.pvariance(y)))
        self.assertEqual(mpc.run(mpc.output(pstdev(x))), round(statistics.pstdev(y)))
        self.assertEqual(mpc.run(mpc.output(mode(x))), round(statistics.mode(y)))
        self.assertEqual(mpc.run(mpc.output(median(x))), round(statistics.median(y)))
        self.assertEqual(mpc.run(mpc.output(median_low(x))), round(statistics.median_low(y)))
        self.assertEqual(mpc.run(mpc.output(median_high(x))), round(statistics.median_high(y))) 
开发者ID:lschoe,项目名称:mpyc,代码行数:17,代码来源:test_statistics.py

示例7: median_filter

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def median_filter(x, y, dx_window, filter=statistics.median_high):
    """
    Calculates the moving median-high of y values over a constant dx.

    :param x:
        x data.
    :type x: Iterable

    :param y:
        y data.
    :type y: Iterable

    :param dx_window:
        dx window.
    :type dx_window: float

    :param filter:
        Filter function.
    :type filter: callable

    :return:
        Moving median-high of y values over a constant dx.
    :rtype: numpy.array
    """

    xy = list(zip(x, y))
    _y = []
    add = _y.append
    for v in sliding_window(xy, dx_window):
        add(filter(list(zip(*v))[1]))
    return np.array(_y) 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:33,代码来源:utils.py

示例8: clear_fluctuations

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import median_high [as 别名]
def clear_fluctuations(times, gears, dt_window):
    """
    Clears the gear identification fluctuations.

    :param times:
        Time vector.
    :type times: numpy.array

    :param gears:
        Gear vector.
    :type gears: numpy.array

    :param dt_window:
        Time window.
    :type dt_window: float

    :return:
        Gear vector corrected from fluctuations.
    :rtype: numpy.array
    """

    xy = [list(v) for v in zip(times, gears)]

    for samples in sliding_window(xy, dt_window):

        up, dn = False, False

        x, y = zip(*samples)

        for k, d in enumerate(np.diff(y)):
            if d > 0:
                up = True
            elif d < 0:
                dn = True

            if up and dn:
                m = statistics.median_high(y)
                for v in samples:
                    v[1] = m
                break

    return np.array([y[1] for y in xy])


# noinspection PyUnusedLocal 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:47,代码来源:utils.py


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