EM_mix: EM_mix

Description Usage Arguments Value Examples

View source: R/StatComp.R

Description

EM Algorithm for two-component Gaussian Mixture

Usage

1
EM_mix(mu1, sigma1, mu2, sigma2, p, N, rv)

Arguments

mu1

the mean of Y1

sigma1

the variance of Y1

mu2

the mean of Y2

sigma2

the variance of Y2

p

the probability of the mixture distribution

N

the number of samples

rv

the random number from mixed normal distribution

Value

the maximum likelihood estimation of the mean, variance and the mixed probablity

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
rv_mix<-function(N,p){
u1<-rnorm(N,0,1)
u2<-rnorm(N,2,1)
j<-runif(N)
k<-as.integer(j>p)
u<-k*u1+(1-k)u2
return (u)
}

p<-0.6
N<-1000
set.seed(2335)
rv<-rv_mix(N,p)
p_0<-0.5
mu1<-0.5
mu2<-1.5
sigma1<-sigma2<-sd(rv)
EM_mix(mu1,sigma1,mu2,sigma2,p_0,N,rv)

## End(Not run)

echo33-1211/StatComp21093 documentation built on Dec. 23, 2021, 11:15 p.m.