Python testing if my data follows a lognormal distribution

前端 未结 1 1210
借酒劲吻你
借酒劲吻你 2021-01-18 21:05

Hi I have a distribution of results that is positively skewed so I want to test if it is a good fit to a log-normal distribution or a Gumbell distribution.

I have us

相关标签:
1条回答
  • 2021-01-18 21:25

    You can simply use scipy.stats.lognorm.fit to fit your data to a lognormal distribution. This will give you a tuple

    (0.60845558877160033, 0.27409944344131409, 1.8037732130179509)
    

    which represents shape, location, and scale respectively. If you want the more common parameters of mu and sigma, you can obtain them like so

    shape, location, scale = scipy.stats.lognorm.fit(listofdata)
    mu, sigma = np.log(scale), shape
    

    You can use the scipy.stats.gumbel_l.fit function similarily for that respective distribution, which will return the location and scale.

    As far as how to test goodness of fit for each distribution, one possibility would be to use the Kolmogorov-Smirnov test with scipy.stats.kstest.

    0 讨论(0)
提交回复
热议问题