We generate n_k observations (k = 1, …, K) from each of K multivariate normal distributions. Let the kth population have a p-dimensional multivariate normal distribution, N_p(μ_k, Σ_k) with mean vector μ_k and positive-definite covariance matrix Σ_k.
a vector (of length K) of the sample sizes for each population
a vector or a list (of length K) of mean vectors
a symmetric matrix or a list (of length K) of symmetric covariance matrices.
seed for random number generation (If
The number of populations,
K, is determined from
the length of the vector of sample sizes, coden. The
mean vectors and covariance matrices each can be given in
a list of length
K. If one covariance matrix is
given (as a matrix or a list having 1 element), then all
populations share this common covariance matrix. The same
logic applies to population means.
named list containing:
whose rows are the observations generated and whose
columns are the
p features (variables)
A vector denoting the population from which the observation in each row was generated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Generates 10 observations from each of two multivariate normal populations # with equal covariance matrices. mean_list <- list(c(1, 0), c(0, 1)) cov_identity <- diag(2) data_generated <- simdata_normal(n = c(10, 10), mean = mean_list, cov = cov_identity, seed = 42) dim(data_generated$x) table(data_generated$y) # Generates 10 observations from each of three multivariate normal # populations with unequal covariance matrices. set.seed(42) mean_list <- list(c(-3, -3), c(0, 0), c(3, 3)) cov_list <- list(cov_identity, 2 * cov_identity, 3 * cov_identity) data_generated2 <- simdata_normal(n = c(10, 10, 10), mean = mean_list, cov = cov_list) dim(data_generated2$x) table(data_generated2$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.