简体   繁体   English

如何使用 rgamma 对 r 中的 gamma 进行采样?

[英]How to use rgamma to sample gamma in r?

If I want to sample Gamma(238, 10), why the code is如果我想采样 Gamma(238, 10),为什么代码是

   theta <- rgamma(1000,238)/10

but not但不是

  theta <- rgamma(1000,238, 10)

? ?

The third argument to rgamma is rate , an inverse multiplicative scale parameter, so actually these two ways are equivalent: rgamma的第三个参数是rate ,一个逆乘法尺度参数,所以实际上这两种方式是等价的:

theta_1 <- rgamma(10000, 238, 10)
theta_2 <- rgamma(10000, 238) / 10

hist(theta_1)


hist(theta_2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM