为什么“ X”现在是以下R代码的这五个伽马分布的混合物?
我尝试从伽马分布的以下混合模型中进行采样:
R代码如下:
可以将算法转化为矢量化方法。
步骤1:生成一个随机示例k_1,...,k_n
vector k
中的整数,其中p(k)=θ_k
, k = 1,...,5。
步骤2:设定速率= 1/k。
n <- 5000
k <- sample(1:5, size=n, replace=TRUE, prob=(1:5)/15)
rate <- 1/k
x <- rgamma(n, shape=3, rate=rate)
我的问题是,为什么x
现在是这五个伽玛分布的混合物?在混合模型的表达中,似乎我们还需要系数theta_k
?
I try to sample from the following mixture models of gamma distribution:
The R code is as follows:
The algorithm can be translated into a vectorized approach.
Step 1: Generate a random sample k_1,...,k_n
of integers in a vector k
,where P(k)=θ_k
, k=1,...,5.
Step 2: Set rate=1/k.
n <- 5000
k <- sample(1:5, size=n, replace=TRUE, prob=(1:5)/15)
rate <- 1/k
x <- rgamma(n, shape=3, rate=rate)
My question is why x
is now the mixture of these five gamma distributions? In the expression of the mixture model, it seems that we also need coefficient theta_k
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是将来自伽马混合物分布的样品与预期混合物密度进行比较的两种方法。这应该有助于了解f_x是伽马分布混合物的累积分布函数。
评论:
1:5
。aes(y = ..密度..)
将直方图表示为正确归一化的密度,以便我们可以将值与混合物密度dmix
进行比较。Here are two ways to compare samples from a Gamma mixture distribution with the expected mixture density. This should help understand how F_X is the cumulative distribution function of a mixture of Gamma distributions.
Comments:
1:5
.aes(y = ..density..)
to express the histogram as a properly normalised density so that we can compare values with the mixture densitydmix
.