Apply the two steps
Since you have created the functions expectation
and maximization
, you can now apply the EM algorithm to a data frame.
The objective in this exercise is to find two Gaussian clusters in the data gaussian_sample
. Assume both sd
are equal to 10.
Este exercício faz parte do curso
Mixture Models in R
Instruções do exercício
- Start with the guess that one of the clusters has a mean of
0
and the other100
. Use the functionsexpectation
andmaximization
to create a list,new_values
. - Save these values into the vector
means_init
. Consider the proportions are equal in the vectorprops_init
. - Go through 10 iterations.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
means_init <- c(0, 100)
___ <- c(0.5, 0.5)
# Iterative process
for(i in 1:___){
___ <- maximization(___(gaussian_sample, means_init, props_init, c(10, 10)))
means_init <- new_values[[1]]
props_init <- ___[[2]]
cat(c(i, means_init, props_init), "\n")
}