r - 来自 R 中 Erlang 分布的样本

标签 r random statistics probability distribution

Erlang distribution有两个参数:自然数 k(形状参数)和实数 lambda(速率参数)。你怎么能从 Erlang 分布中随机抽取一个大小为 n 的样本,使用 R 而不使用外来包?

最佳答案

这个问题的诀窍是注意 the Erlang distributionthe 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 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.

关于r - 来自 R 中 Erlang 分布的样本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49313314/

相关文章:

r - 为具有不同观测数量的面板数据中的每年分配五分位数

r - 在 R 中创建绘图图表以在计数和百分比之间切换

python - 为给定的二维概率数组沿轴向量化 `numpy.random.choice`

ruby - 从 Ruby 数组计算四分位数平均值?

r - 如何在大型数据集的简单 'for'循环中使用ff包

css - 如何在 Shiny 中设置动态流体行高度

c - 如何使用 rand() 生成一个范围内的数字?

mysql - MariaDB 中的奇怪行为或 RAND : Single RAND delivers more than 1 result

r - 估计威 bool 密度参数(错误 : "...initial value in ' vmmin' is not finite")

java - 需要一个快速的 Java beta 分布随机数生成器