Function generator for sampling from a mvn (multivariate normal) object.

# S3 method for mvn
sampler(x, ...)

Arguments

x

The mvn object to sample from

...

Additional arguments to pass to the generated function that will be fixed during all calls.

Value

A function that samples from the mvn distribution. It accepts as input: - n: number of samples to generate. Defaults to 1. - mu: a vector denoting the population mean. Defaults to the mean of x (an mvn object) - sigma: a matrix denoting the covariance of observations. Defaults to the variance-covariance of x. - p: probability region to sample from. Defaults to 1, which corresponds to the entire distribution. sample_mvn_region method. It's used when p is less than 1. - ...: any additional parameters to pass to rmvnorm or sample_mvn_region which can be different during each call.