Learn R Programming

gmgm (version 1.1.2)

sampling: Sample a Gaussian mixture model

Description

This function samples a Gaussian mixture model.

Usage

sampling(gmm, data_x = NULL, n = 1)

Value

A numeric matrix containing the samples.

Arguments

gmm

An object of class gmm.

data_x

A data frame or numeric matrix containing observations of the explanatory variables if conditional sampling is performed. Its columns must explicitly be named after the explanatory variables. If NULL (the default), joint sampling is performed.

n

A non-negative integer corresponding to the number of samples. If conditional sampling is performed, this argument is ignored.

See Also

density, expectation

Examples

Run this code
set.seed(0)
data(gmm_body, data_body)
sampl_1 <- sampling(gmm_body, n = 500)
sampl_2 <- sampling(gmm_body,
                    data_body[, c("WEIGHT", "FAT", "HEIGHT", "AGE")])

Run the code above in your browser using DataLab