python 求 gamma 分布,用(python)Scipy拟合伽玛分布

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 distribution... In the Scipy doc, it turns out that a fit method actually exists but I don't know how to use it :s.. First, in which format the argument "data" must be, and how can I provide the second argument (the parameters) since that's what I'm looking for?

解决方案

Generate some gamma data:

import scipy.stats as stats

alpha = 5

loc = 100.5

beta = 22

data = stats.gamma.rvs(alpha, loc=loc, scale=beta, size=10000)

print(data)

# [ 202.36035683 297.23906376 249.53831795 ..., 271.85204096 180.75026301

# 364.60240242]

Here we fit the data to the gamma distribution:

fit_alpha, fit_loc, fit_beta=stats.gamma.fit(data)

print(fit_alpha, fit_loc, fit_beta)

# (5.0833692504230008, 100.08697963283467, 21.739518937816108)

print(alpha, loc, beta)

# (5, 100.5, 22)

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值