dmixnorm: Density for normal mixtures

Description Usage Arguments Details Value Author(s) References Examples

View source: R/dgp__rmixmorm.R

Description

Density for univariate and multivariate mixture normal distribution

Usage

1
dmixnorm(x, means, sigmas, weights, log = FALSE)

Arguments

means

A 'q-by-k' matrix. Mean value vector within each component in total k components.

sigmas

A 'q-by-q-by-k' array. Variance covariance matrix with in each component.

weights

A 'k'-length vector. The weight in each component.

n

An positive integer. Numbers of samples to be generated.

Details

Density from mixture of normals.

Value

An 'n-by-q' matrix

Author(s)

Feng Li, Central University of Finance and Economics.

References

Villani et al 2009

Examples

1
2
3
4
5
6
7
require("mvtnorm")
n <- 1
means <- matrix(c(-5, 0, 5), 1)
sigmas <- array(c(1, 1, 1), c(1, 1, 3))
weights <- c(0.3, 0.4, 0.3)
out <- rmixnorm(n, means, sigmas, weights)
out.density <- dmixnorm(out, means, sigmas, weights)

feng-li/flutils documentation built on Oct. 1, 2020, 9:09 p.m.