Exercise

Visualizing Univariate Gaussian Mixture Model

Since you fitted the model into fit_mix_example and extracted the parameters into comp_1, comp_2 and comp_3 (as well as the proportions), let's now plot the corresponding clusters with the density histogram.

To facilitate this last purpose, the fun_prop() function has been defined in the environment. This function provides the density values for a Gaussian distribution, like dnorm, but is extended to also accept the proportions.

Instructions

100 XP
  • Plot the density histogram together with the density of each cluster. Remember that the data frame is called mix_example.
  • Use the function stat_function() with the argument fun equals fun_prop to draw the density distribution for each cluster.