Homepage > MCMC

Normal Mixture

Let $ f(x; \mu, \sigma)$ be the normal density function with mean $ \mu$ and standard deviation (SD) $ \sigma$. Given parameters $ \mu_1$, $ \sigma_1$, $ \mu_2$, $ \sigma_2$, and $ 0 < \gamma < 1$, the ``normal mixture'' density is defined as

$\displaystyle g(x; \mu_1, \sigma_1, \mu_2, \sigma_2, \gamma)
= \gamma f(x; \mu_1, \sigma_1) + (1-\gamma) f(x; \mu_1, \sigma_1)
$

The mixture of two normal distribution will be a bimodal distribution, and the two peaks may be approximated by the respective mean $ \mu_1$ and $ \mu_2$.
> source("nm.r")
> x = seq(0,1,by=0.01)
> plot(x, nm(x), type="l", xlab="x", ylab="PDF", main="Normal mixture")

Programming note. The function ``nm()'' is defined in the source file nm.r and written in the form

nm = function(x, p=c(0.3, 0.2, 0.8, 0.1, 0.4)){
  p[5] * dnorm(x, p[1], p[2]) + (1-p[5]) * dnorm(x, p[3], p[4])
}
It is executed by
> y = mn(0.2)
The argument ``p'' is optional, and given ``c(0.3, 0.2, 0.8, 0.1, 0.4) when omitted. The function returns the value
  p[5] * dnorm(x, p[1], p[2]) + (1-p[5]) * dnorm(x, p[3], p[4])
in which dnorm() returns the normal density value.


© TTU Mathematics