已知機率下的參數估計
在混合模型中進行參數估計並不容易。不過,如果已經知道每個群集的隸屬機率,要估計各群集的平均數與比例就不那麼困難了。
在這個練習中,你會使用由兩個 Gaussian 分佈生成的資料集 gaussian_sample_with_probs。它原本只有 x 這一欄,但這裡同時提供了每個群集的機率(prob_cluster1 與 prob_cluster2)。目標是先估計參數,接著將估計出的混合模型視覺化。
本練習屬於課程
R 中的混合模型
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Estimation of the means
___ <- ___ %>%
summarise(mean_cluster1= sum(___*prob_cluster1)/sum(prob_cluster1),
mean_cluster2 = sum(x*___)/sum(___))
means_estimates
# Estimation of the proportions
props_estimates <- ___ %>%
summarise(props_cluster1 = ___(prob_cluster1),
props_cluster2 = 1 - ___)
props_estimates