Erlang distribution有两个参数:自然数 k(形状参数)和实数 lambda(速率参数)。你怎么能从 Erlang 分布中随机抽取一个大小为 n 的样本,使用 R 而不使用外来包?
最佳答案
这个问题的诀窍是注意 the Erlang distribution是 the Gamma distribution 的特例.从 Gamma 分布采样在 stats package 中实现.
以下函数从标准 R 向量中的 Erlang(k, lambda) 分布返回大小为 n 的样本:
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.
关于r - 来自 R 中 Erlang 分布的样本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49313314/