In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces python how to achieve EM algorithm related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will gain something after reading this python how to achieve EM algorithm article, let's take a look at it.
Title of the thesis:
What is the expectation maximization algorithm?
This is the picture in the paper:
The following explains how these numbers were obtained.
Step1 pure chips rely on guessing
Suppose the probability of coin A facing up is 0.6, and the probability of coin B facing up is 0.5.
Step2 does the experiment.
Five rounds of experiments were carried out, and each round was thrown 10 times. All the experimental results are as follows:
The results of each round of experiments are analyzed in turn.
The result of the first round: 5 times up, 5 times down. If coin An is selected, the probability of this result is: Pa = 0.6 ^ 5 * 0.4 ^ 5; if coin B is selected, the probability is: Pb = 0.5 ^ 5 * 0.5 ^ 5; the probability of choosing coin An is: Za = Pa/ (Pa+Pb), and the probability of choosing coin B is: Zb = 1-Za.
Do the math:
Pa = 0.6 "5" 0.4 "5"
Pb = 0.5 "5" 0.5 "5"
Za = Pa/ (Pa+Pb)
Zb = 1-Za
Results:
In [11]: Za
Out [11]: 0.44914892610093643
In [12]: Zb
Out [12]: 0.5508510738990635
It is rounded up to 0.45, 0.55. The difference is the probability of choosing coin An and coin B.
The probability of choosing coin An is 0.45, tossing the coin 10 times, and the expected value of the total number of positive and negative occurrences is 0.45 * 10, that is, 4.5 times. The results of the first round of experiments are as follows: 5 positive and 5 negative, so the expected value of the number of positive appearances is 4.5 * (5 prime 10), that is, 2.25 times, and 2.25 times negative.
In the same way, coin B. The probability of choosing coin B is 0.55, tossing the coin 10 times, and the expected total number of positive and negative occurrences is 0.55 * 10, that is, 5.5 times. The results of the first round of experiments are as follows: 5 positive and 5 negative, so the expected value of the number of positive appearances is 5.5 * (5 prime 10), that is, 2.75 times, and 2.75 times negative times.
Similarly, from the second round to the fifth round of experiments, the probability of coin An and the expected value of the corresponding number of positive and negative sides are selected, and the probability of coin B and the expected value of the corresponding number of positive and negative sides are selected.
After the analysis of all the experiments from the first round to the fifth round, the following results are obtained: the left table is the probability distribution of selected coins An and B (that is, the probability distribution of hidden variables); the table on the right is the expected distribution of positive and negative occurrence times of coins An and B in 10 toss experiments (that is, the probability distribution of observable variables).
Step3 likelihood estimation
Throughout the five rounds of summing up 50 coin tosses, the probability of coins An and B appearing on the front can be calculated.
The number of times coin An appears on the front:
2.2 + 7.2 + 5.9 + 1.4 + 4.5 = 21.2
The number of times the reverse side of coin An appears:
2.2 + 0.8 + 1.5 + 2.1 + 1.9 = 8.5
Get coin B in the same way
Get the results in the graph of the paper (the accuracy of the decimal point, a little deviation, it doesn't matter, just understand it)
At this point, we get an estimate of the probability of the occurrence of coins An and B, this time based on experiments, rather than pure fragmentation as at the beginning (0.6, 0.5).
Complete an iteration of the distribution parameters.
Step4 iterations 10 times
After 10 iterations, the parameters are updated as follows, corresponding to the Step4 in the paper.
This is the end of the article on "how python implements the EM algorithm". Thank you for reading! I believe you all have a certain understanding of "how python implements the EM algorithm". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.