rmix: rmix

rmixR Documentation

rmix

Description

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

Usage

rmix(p, rdens, n = NULL)

Arguments

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

Author(s)

Marcin Imielinski


mskilab/skitools documentation built on Aug. 31, 2023, 1:13 p.m.