| sampler.mixture | R Documentation |
Returns a function that draws samples from the mixture by first selecting a component according to the mixing weights, then sampling from the selected component.
## S3 method for class 'mixture'
sampler(x, ...)
x |
A |
... |
Additional arguments (not used). |
A function function(n = 1, ...) returning a numeric
vector of length n.
m <- mixture(list(normal(0, 1), normal(5, 1)), c(0.5, 0.5))
s <- sampler(m)
set.seed(42)
s(6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.