rvmix {rv} | R Documentation |
Generates a random variable from a mixture of given random variables.
rvmix(n=1, prob=NULL, index=NULL, components=list())
n |
number of independent draws to output |
prob |
probabilities of the components (or weights, will be normalized) |
index |
(optional) index random variable, giving the distribution of indices |
components |
a list of the component random variables |
If an index is given, prob
is ignored.
A random variable.
Jouni Kerman kerman@stat.columbia.edu http://www.stat.columbia.edu/~kerman
Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York.
comp <- list(rvnorm(mean=0), rvnorm(mean=10)) # Normal components of a mixture distribution rvmix(prob=c(95,5), components=comp) # 5 per cent comes from N(10,1)