dnorm_mix: Normal Mixture Density

Description Usage Arguments Details Author(s) Examples

View source: R/dnorm_mix.R

Description

Gives the density value of a univariate Normal mixture.

Usage

1

Arguments

x

value or vector of values, to apply in the mixture probability density function.

pi

vector of mixture weights.

mean

vector of mixture means.

sd

vector of mixture standard desviations.

Details

Each component of the mixture has density

f_j(x) = 1/(√(2 * π) * σ_j) * exp(-(x - μ_j)/(2 * σ_j^(2))

where μ_j is the mean of the jth component and σ_j is the standard deviation of the jth component. j = 1, 2, ..., g.

Author(s)

CASTRO, M. O.; MONTALVO, G. S. A.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
f <- function(x){dnorm_mix(x, pi = c(0.5, 0.5), mean = c(4, 11), sd = c(2, 2))}
## Plot using graphics package
require(graphics)
curve(f, 0, 15)

require(ggplot2)
## Plot using ggplot2 package
ggplot(data.frame(x=c(0, 15)), aes(x)) +
  stat_function(fun=f, size = 1L, colour = "#0c4c8a") +
  theme_minimal()

## Integrate
integrate(f, "-Inf", "Inf")$value

matheuscastro43/mixGM documentation built on March 2, 2020, 12:19 a.m.