rmix | R Documentation |
sample N points from a mixture of k densities of a single functional form (eg norm, beta, multinomial) where n is either an integer vector of length k denoting how many samples to be drawn from each density (in which case N = sum(n)) or n is a scalar, in which case n points are drawn from each density and N = n*k.
p = params data frame whose named columns correspond to arguments to rdens (eg $n, $shape1, $shape2 for rbeta or $n, $mean, $sd for rnorm) rdens = function encoding random number generator for given density, that takes as input named columns of params n = either an nrow(p) integer vector or scalar denoting how many samples to draw from each density
n can also be just be a column of p
useful for plotting "smears" of points
Output is the rbind-ed output of individual rdens calls
rmix(p, rdens, n = NULL)
p |
k x p data frame of k parameter sets of rdens density functions, each column is a parameter value, each row is a parameter setting for a mixture component |
rdens |
R density specific random number generator function object (eg rnorm) |
n |
length k or legnth 1 integer specifying number of samples to draw from each mixture component |
Marcin Imielinski
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.