szcf-weiya / ESL-CN

The Elements of Statistical Learning (ESL)的中文翻译、代码实现及其习题解答。
https://esl.hohoweiya.xyz
GNU General Public License v3.0
2.43k stars 594 forks source link

Fig. 8.6 and Tab. 8.2: Example for EM #249

Closed szcf-weiya closed 2 years ago

szcf-weiya commented 2 years ago

it is summarized in https://esl.hohoweiya.xyz/notes/Mixture-Gaussian/index.html#em

szcf-weiya commented 2 years ago

in R

pi = 0.554590232459113
Finish!
mu1 = 4.65591280772299
mu2 = 1.0831618075166
sigma1^2 = 0.818793570810866
sigma2^2 = 0.811370618556585

image

the estimations are (slightly) different the original.

szcf-weiya commented 2 years ago

in Julia

a variant version that assumes the ratio of sigma1/sigma2 is also provided

julia> μ1
1.0831617392634196

julia> μ2
4.655912729215212

julia> σ1^2
0.8113705078083597

julia> σ2^2
0.8187936852297709

julia> w
0.5545902120768698

which is quite close to the above calculated by R.

pi log-likelihood
image image