# NormalMix: Mixture of normal distributions In extraDistr: Additional Univariate and Multivariate Distributions

## Description

Density, distribution function and random generation for the mixture of normal distributions.

## Usage

 ```1 2 3 4 5``` ```dmixnorm(x, mean, sd, alpha, log = FALSE) pmixnorm(q, mean, sd, alpha, lower.tail = TRUE, log.p = FALSE) rmixnorm(n, mean, sd, alpha) ```

## Arguments

 `x, q` vector of quantiles. `mean` matrix (or vector) of means. `sd` matrix (or vector) of standard deviations. `alpha` matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1. `log, log.p` logical; if TRUE, probabilities p are given as log(p). `lower.tail` logical; if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]. `n` number of observations. If `length(n) > 1`, the length is taken to be the number required. `p` vector of probabilities.

## Details

Probability density function

f(x) = α * f1(x; μ, σ) + … + α[k] * fk(x; μ[k], σ[k])

Cumulative distribution function

F(x) = α * F1(x; μ, σ) + … + α[k] * Fk(x; μ[k], σ[k])

where sum(α[i]) == 1.

## Examples

 ```1 2 3 4 5 6 7 8``` ```x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)) hist(x, 100, freq = FALSE) curve(dmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", add = TRUE) hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))) plot(ecdf(x)) curve(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", lwd = 2, add = TRUE) ```

extraDistr documentation built on Sept. 7, 2020, 5:09 p.m.