Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Mixture Models in R

Cursus bekijken

Oefeninstructies

  • Start with the guess that one of the clusters has a mean of 0 and the other 100. Use the functions expectation and maximization to create a list, new_values.
  • Save these values into the vector means_init. Consider the proportions are equal in the vector props_init.
  • Go through 10 iterations.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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")
}
Code bewerken en uitvoeren