Python statistics 模块,pvariance() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用statistics.pvariance()

项目:jhTAlib    作者:joosthoeks    | 项目源码 | 文件源码
def PVARIANCE(df, n, price='Close', mu=None):
    """
    Population variance of data
    """
    pvariance_list = []
    i = 0
    while i < len(df[price]):
        if i + 1 < n:
            pvariance = float('NaN')
        else:
            start = i + 1 - n
            end = i + 1
            pvariance = statistics.pvariance(df[price][start:end], mu)
        pvariance_list.append(pvariance)
        i += 1
    return pvariance_list
项目:QUANTAXIS    作者:yutiansut    | 项目源码 | 文件源码
def pvariance(self):
        return statistics.pvariance(self.price)

    # ??
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    print(stats.mean(range(6)))
    print(stats.median(range(6)))
    print(stats.median_low(range(6)))
    print(stats.median_high(range(6)))
    print(stats.median_grouped(range(6)))
    try:
        print(stats.mode(range(6)))
    except Exception as e:
        print(e)
    print(stats.mode(list(range(6)) + [3]))
    print(stats.pstdev(list(range(6)) + [3]))
    print(stats.stdev(list(range(6)) + [3]))
    print(stats.pvariance(list(range(6)) + [3]))
    print(stats.variance(list(range(6)) + [3]))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_compare_to_variance(self):
        # Test that stdev is, in fact, the square root of variance.
        data = [random.uniform(-17, 24) for _ in range(1000)]
        expected = math.sqrt(statistics.pvariance(data))
        self.assertEqual(self.func(data), expected)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_compare_to_variance(self):
        # Test that stdev is, in fact, the square root of variance.
        data = [random.uniform(-17, 24) for _ in range(1000)]
        expected = math.sqrt(statistics.pvariance(data))
        self.assertEqual(self.func(data), expected)
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def pvariance(text):
    """
    Finds the population variance of a space-separated list of numbers.

    Example::

        /pvariance 33 54 43 65 43 62
    """
    return format_output(statistics.pvariance(parse_numeric_list(text)))
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def setup():
    commands.add(mean)
    commands.add(median)
    commands.add(median_low)
    commands.add(median_high)
    commands.add(median_grouped)
    commands.add(mode)
    commands.add(pstdev)
    commands.add(pvariance)
    commands.add(stdev)
    commands.add(variance)