Reputation: 1
I am trying to generate a bivariate sample from a mixture of two component distributions viz., normal and gamma distributions. I am using the 'copula' package for that.
The code I wrote is as follows-
library("copula")
mycop = normalCopula(param=c(0), dim=2, dispstr="ex")
mymvd = mvdc(
copula=mycop,
margins=c("norm", "norm"),
paramMargins=list(list(mean=-1, sd=0.5),list(mean=1, sd=0.5)))
This gave a bivariate sample from Normal(-1,1,0.5^2,0.5^2,0). The same code with exponential will lead give a bivariate sample from that distribution. But I don't know how to generate from w*BivariateNormal + (1-w)*BivariateGamma. Please help. I searched everywhere in yt but couldn't find anything. Thanks in advance.
Upvotes: 0
Views: 364
Reputation: 32888
In general, you sample from a mixture of two distributions by:
runif
in R), thenw
, orSimilarly, you sample from a mixture of multiple distributions by generating a uniform, or non-uniform random integer, then sampling from a distribution depending on the integer chosen.
Upvotes: 1