Draws n independent samples from a Gaussian mixture.
Arguments
- n
Number of samples (positive integer scalar).
- g
A gmm (or gmm_fit) object.
Value
A numeric matrix of dimension n by p.
Examples
g <- gmm(weights = c(0.5, 0.5),
means = list(c(-1, 0), c(1, 0)),
covariances = list(diag(2), diag(2)))
x <- rgmm(50L, g)
dim(x)
#> [1] 50 2