- 指数分布(Exponential distribution)解决的问题是:要等到一个随机事件发生,需要经历多久时间。
- 伽马分布(Gamma distribution)解决的问题是:要等到n个随机事件都发生,需要经历多久时间。
- 泊松分布(Poisson distribution)解决的问题是:在特定时间内发生n个事件的概率。
The Gamma Distribution
Description
Density, distribution function, quantile function and random generation for the Gamma distribution with parameters shape
and scale
.
Usage
dgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE) pgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) qgamma(p, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rgamma(n, shape, rate = 1, scale = 1/rate)
Arguments
x, q | vector of quantiles. |
p | vector of probabilities. |
n | number of observations. If |
rate | an alternative way to specify the scale. |
shape, scale | shape and scale parameters. Must be positive, |
log, log.p | logical; if |
lower.tail | logical; if TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x]. |
Gamma分布中的参数α称为形状参数(shape parameter),
shape: α ;rate: β;# β称为逆尺度参数。
1. 生成gamma分布的随机数rgamma函数
num = 100
shape=1
rate = 5
rgamma(num,shape,rate)
2.概率密度dgamma函数
x <- seq(0,2,0.01)
dgamma(x, shape, rate)
plot(x,dgamma(x, shape, rate))
3.累积概率pgamma函数
pgamma(0.5,shape=shape,rate=rate)
4.qgamma函数(pgamma的反函数)
qgamma(0.95,shape=shape,rate=rate)