R 中 Erlang 分布的样本
Sample from the Erlang distribution in R
Erlang distribution有两个参数:自然数k(形状参数)和实数lambda(速率参数) .您如何使用没有外来包的 R 从 Erlang 分布中随机抽取大小为 n 的样本?
这道题的诀窍是注意 the Erlang distribution is a special case of the Gamma distribution. Sampling from the gamma distribution is implemented in the stats package.
以下函数 returns 大小为 n 的样本,来自标准 R 向量中的 Erlang(k, lambda) 分布:
rgamma(n, shape=k, rate = lambda)
n
is the size of the sample.
shape
is the parameter k
. This is the shape parameter of the Erlang distribution (for Erlang, this must be a natural number >=1).
rate
is the rate parameter for the Erlang distribution.
Erlang distribution有两个参数:自然数k(形状参数)和实数lambda(速率参数) .您如何使用没有外来包的 R 从 Erlang 分布中随机抽取大小为 n 的样本?
这道题的诀窍是注意 the Erlang distribution is a special case of the Gamma distribution. Sampling from the gamma distribution is implemented in the stats package.
以下函数 returns 大小为 n 的样本,来自标准 R 向量中的 Erlang(k, lambda) 分布:
rgamma(n, shape=k, rate = lambda)
n
is the size of the sample.
shape
is the parameterk
. This is the shape parameter of the Erlang distribution (for Erlang, this must be a natural number >=1).
rate
is the rate parameter for the Erlang distribution.