本文整理汇总了Python中streamhist.StreamHist.median方法的典型用法代码示例。如果您正苦于以下问题:Python StreamHist.median方法的具体用法?Python StreamHist.median怎么用?Python StreamHist.median使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类streamhist.StreamHist
的用法示例。
在下文中一共展示了StreamHist.median方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exact_median
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import median [as 别名]
def test_exact_median():
points = range(15) # Odd number of points
h = StreamHist(maxbins=17)
h.update(points)
assert h.median() == 7
points = range(16) # Even number of points
h = StreamHist(maxbins=17)
h.update(points)
assert h.median() == 7.5
示例2: test_median_mean
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import median [as 别名]
def test_median_mean():
points = 10000
h = StreamHist()
for p in make_uniform(points):
h.update(p)
assert about(h.median(), 0.5, 0.05)
h = StreamHist()
for p in make_normal(points):
h.update(p)
assert about(h.median(), 0, 0.05)
assert about(h.mean(), 0, 0.05)
示例3: test_freeze
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import median [as 别名]
def test_freeze():
points = 100000
h = StreamHist(freeze=500)
for p in make_normal(points):
h.update(p)
assert about(h.sum(0), points/2.0, points/50.0)
assert about(h.median(), 0, 0.05)
assert about(h.mean(), 0, 0.05)
assert about(h.var(), 1, 0.05)