Fitting a gamma distribution with (python) Scipy

后端 未结 5 1681
情歌与酒
情歌与酒 2020-12-09 02:24

Can anyone help me out in fitting a gamma distribution in python? Well, I\'ve got some data : X and Y coordinates, and I want to find the gamma parameters that fit this dis

5条回答
  •  感情败类
    2020-12-09 02:50

    1): the "data" variable could be in the format of a python list or tuple, or a numpy.ndarray, which could be obtained by using:

    data=numpy.array(data)
    

    where the 2nd data in the above line should be a list or a tuple, containing your data.

    2: the "parameter" variable is a first guess you could optionally provide to the fitting function as a starting point for the fitting process, so it could be omitted.

    3: a note on @mondano's answer. The usage of moments (mean and variances) to work out the gamma parameters are reasonably good for large shape parameters (alpha>10), but could yield poor results for small values of alpha (See Statistical methods in the atmospheric scineces by Wilks, and THOM, H. C. S., 1958: A note on the gamma distribution. Mon. Wea. Rev., 86, 117–122.

    Using Maximum Likelihood Estimators, as that implemented in the scipy module, is regarded a better choice in such cases.

提交回复
热议问题