Scipy Normaltest how is it used?

前端 未结 2 1962
忘了有多久
忘了有多久 2020-12-23 11:43

I need to use normaltest in scipy for testing if the dataset is normal distributet. But I cant seem to find any good examples how to use scipy.stats.normaltest.

My d

2条回答
  •  自闭症患者
    2020-12-23 12:03

    In [12]: import scipy.stats as stats
    
    In [13]: x = stats.norm.rvs(size = 100)
    
    In [14]: stats.normaltest(x)
    Out[14]: (1.627533590094232, 0.44318552909231262)
    

    normaltest returns a 2-tuple of the chi-squared statistic, and the associated p-value. Given the null hypothesis that x came from a normal distribution, the p-value represents the probability that a chi-squared statistic that large (or larger) would be seen.

    If the p-val is very small, it means it is unlikely that the data came from a normal distribution. For example:

    In [15]: y = stats.uniform.rvs(size = 100)
    
    In [16]: stats.normaltest(y)
    Out[16]: (31.487039026711866, 1.4543748291516241e-07)
    

提交回复
热议问题