Exercise

Plot the estimated clusters

At this point, you have discovered the two cluster in the data frame gaussian_sample. In this exercise, you will visualize how the estimated clusters for the iteration 10 fit the data. The vectors means_iter10 and props_iter10 are already saved in the environment.

To this end, you will use the ggplot2 function called stat_function(), which lets you superimpose a function on top of an existing plot. The function you will use a created curve function called fun_gaussian() which takes as arguments the mean and the proportion of the Gaussian.

Instructions

100 XP

Plot the histogram in density mode of the variable x and add the estimated curves using stat_function() in combination with the function fun_gaussian().