R语言Γ(gamma)分布

本文介绍了伽玛分布的基本概念,包括其形状参数和逆尺度参数的作用,以及rgamma函数用于生成随机数、dgamma函数计算概率密度、pgamma函数计算累积概率和qgamma函数的反函数的应用实例。通过实例演示了如何在实际问题中使用伽玛分布进行事件等待时间的建模。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 指数分布(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 length(n) > 1, the length is taken to be the number required.

rate

an alternative way to specify the scale.

shape, scale

shape and scale parameters. Must be positive, scale strictly.

log, log.p

logical; if TRUE, probabilities/densities p are returned as log(p).

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值