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


Python Catalog.get_observed_frequencies方法代码示例

本文整理汇总了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)
开发者ID:gabriel951,项目名称:pibic,代码行数:32,代码来源:stats.py


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