Scipy Normaltest how is it used?

前端 未结 2 1959
忘了有多久
忘了有多久 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 11:48

    First i found out that scipy.stats.normaltest is almost the same. The mstats library is used for masked arrays. Arrays where you can mark values as invalid and not taken into the calculation.

    import numpy as np
    import numpy.ma as ma
    from scipy.stats import mstats
    
    x = np.array([1, 2, 3, -1, 5, 7, 3]) #The array needs to be larger than 20, just an example
    mx = ma.masked_array(x, mask=[0, 0, 0, 1, 0, 0, 0])
    z,pval = mstats.normaltest(mx)
    
    if(pval < 0.055):
        print "Not normal distribution"
    

    "Traditionally, in statistics, you need a p-value of less than 0.05 to reject the null hypothesis." - http://mathforum.org/library/drmath/view/72065.html

提交回复
热议问题