如何估算伽玛距离的形状和比例.具有特定的均值和95%的分位数? [英] How can I estimate the shape and scale of a gamma dist. with a particular mean and a 95% quantile?
本文介绍了如何估算伽玛距离的形状和比例.具有特定的均值和95%的分位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在给定特定的平均值(或中位数)和特定的分位数(95%的分位数)的情况下,R中是否有任何方法可以计算伽玛分布的比例和形状?
Is there any way, in R, to calculate the scale and shape of a gamma distribution, given a particular value of mean (or median) and a particular quantile (the 95% quantile)?
例如,我有一个平均值= 130
和 95%的分位数= 300
分布的偏移量为 80
是否有任何方法可以获取满足这些条件的伽玛标尺和形状?
is there any way to obtain the scale and shape of a gamma that meet these criteria?
推荐答案
这是一种方法:
myfun <- function(shape) {
scale <- 130/shape
pgamma(300, shape, scale=scale) - 0.95
}
tmp <- uniroot( myfun, lower=2, upper=10 )
myshape <- tmp$root
myscale <- 130/tmp$root
qgamma(0.95, shape=myshape, scale=myscale)
integrate( function(x) x*dgamma(x,shape=myshape,scale=myscale),
lower=0, upper=Inf )
我不确定您所说的80偏移量是什么意思,如果那恰好是伽马变为非零的位置,则从130和300中减去80并执行与上述相同的操作.
I am not sure what you mean by offset of 80, if that is just where the gamma becomes non-zero then subtract 80 from 130 and 300 and do the same as above.
这篇关于如何估算伽玛距离的形状和比例.具有特定的均值和95%的分位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文