本文整理汇总了Python中catalog.Catalog.get_observed_frequencies方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog.get_observed_frequencies方法的具体用法?Python Catalog.get_observed_frequencies怎么用?Python Catalog.get_observed_frequencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类catalog.Catalog
的用法示例。
在下文中一共展示了Catalog.get_observed_frequencies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_chi_square
# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_observed_frequencies [as 别名]
def do_chi_square(self, catalog_file, alpha, seconds):
"""
receives a catalog file, a significance level and a number of seconds
do a hyphotesis test to detect whether the catalog is poissonian or not, under the significance level
H0 -> catalog is poissonian
H1 -> catalog is not poissonian
prints the p-value and the significance level
"""
# get observed frequencies
catalog = Catalog()
observed_frequencies = catalog.get_observed_frequencies(catalog_file, seconds)
# print if the observed frequencies are too low
for x in observed_frequencies:
if x < 5:
print("Warning: the number of occurrences appear to be too low!")
break
# get the number of restrictions
restrictions = 1 # 1 restriction, since lambda - rate of occurrence - is estimated from the parameters
# perform chi square test
result = chisquare(observed_frequencies, ddof=restrictions)
# get the p_value
p_value = result[1]
# print results showing the p value and the significance level
print("the p_value was: ", p_value)
print("the significance level was: ", alpha)