Learn R Programming

ks (version 1.8.11)

dmvnorm.mixt: Multivariate and univariate normal mixture distribution

Description

Random generation and density values from normal mixture distribution.

Usage

dmvnorm.mixt(x, mus, Sigmas, props)
rmvnorm.mixt(n=100, mus=c(0,0), Sigmas=diag(2), props=1, mixt.label=FALSE)

dnorm.mixt(x, mus=0, sigmas=1, props=1) rnorm.mixt(n=100, mus=0, sigmas=1, props=1, mixt.label=FALSE)

Arguments

n
number of random variates
x
matrix of quantiles
mus
(stacked) matrix of mean vectors (>1-d) or vector of means (1-d)
Sigmas
(stacked) matrix of variance matrices (>1-d)
sigmas
vector of standard deviations (1-d)
props
vector of mixing proportions
mixt.label
flag to output numeric label indicating mixture component. Default is FALSE.

Value

  • Normal mixture random vectors and density values.

Details

rmvnorm.mixt and dmvnorm.mixt are based on the rmvnorm and dmvnorm functions from the mvtnorm library.

See Also

rmvt.mixt, dmvt.mixt, dnorm.mixt, rnorm.mixt

Examples

Run this code
## bivariate 
mus <- rbind(c(-3/2,0), c(3/2,0))
Sigmas <- rbind(diag(c(1/16, 1)), rbind(c(1/16, 1/18), c(1/18, 1/16)))
props <- c(2/3, 1/3)
x <- rmvnorm.mixt(1000, mus, Sigmas, props)
dens <- dmvnorm.mixt(x, mus, Sigmas, props)

##univariate
x <- rnorm.mixt(1000, mus=c(-1,1), sigmas=c(0.5, 0.5), props=c(1/2, 1/2))
dens <- dnorm.mixt(x, mus=c(-1,1), sigmas=c(0.5, 0.5), props=c(1/2, 1/2))

Run the code above in your browser using DataLab