Table of contents
1. Background
The picture below is the background content of this article. Little B has an 80% probability of playing mobile games and a 20% probability of playing computer games during his leisure time. Both games have a card drawing process. The probability of drawing a gold card in the mobile game is 5%, and the probability of drawing a gold card in the client game is 15%. It is known that Little B drew the gold card today, so did he draw it on his mobile phone or on his computer?
2. Total probability formula
In the above question, we first consider the probability that Little B draws the gold card. Suppose the probability of playing computer is P ( c ) P(c)P ( c ) , the probability of playing on the mobile phone isP ( p ) P(p)P ( p ) , the probability of drawing a gold card isP ( v ) P(v)P(v):
- If Little B is a gold card drawn on the computer, then its probability is P ( c ) P ( v ∣ c ) P(c)P(v|c)P ( c ) P ( v ∣ c ) is the probability of playing on the computer multiplied by the probability of drawing a gold card on the computer.
- If Little B is the gold card drawn on the mobile phone, then its probability is P ( p ) P ( v ∣ p ) P(p)P(v|p)P ( p ) P ( v ∣ p ) is the probability of playing on the mobile phone multiplied by the probability of drawing a gold card on the mobile phone.
The above two formulas respectively calculate the probability of getting a gold card on the mobile phone and the gold card on the computer, then the sum of the two is the probability of little B getting a gold card, that is: P ( v ) = P ( c ) P ( v ∣ c ) + P ( p ) P ( v ∣ p ) P(v)=P(c)P(v|c)+P(p)P(v|p)P(v)=P(c)P(v∣c)+P ( p ) P ( v ∣ p ) . This isthe total probability formula, which simply means the probability of the event occurring under all possible circumstances.
It is more intuitive to use a graph, as shown in the figure below, which is a square with a length and width of 1, and its area represents the possibility of all events occurring. Playing computers takes up 20% of the area, and playing mobile phones accounts for 80% of the area; playing computers and getting gold cards takes up 15% of the area for playing computers; playing mobile phones and getting gold cards takes up the area for playing mobile phones 5% of the area.
Then the probability of drawing a gold card is:
3. Bayes’ formula
After knowing the total probability formula, it is easy to understand the Bayesian formula. The Bayesian formula is based on the fact that we already know the result, that is, when we know that B has already drawn a gold card, inversely deduce that B is the probability of getting a gold card by playing with a computer and the probability of getting a gold card by playing with a mobile phone Probability.
Then the probability of getting a gold card when playing computer games can be expressed graphically as:
The mathematical formula is:
P ( c ∣ v ) = P ( c ) P ( v ∣ c ) P ( v ) P(c|v)=\ frac{P(c)P(v|c)}{P(v)}P(c∣v)=P(v)P(c)P(v∣c)
In the same way, the probability of getting a gold card by playing with a mobile phone can be expressed graphically:
expressed as a mathematical formula:
P ( p ∣ v ) = P ( p ) P ( v ∣ p ) P ( v ) P(p|v) =\frac{P(p)P(v|p)}{P(v)}P(p∣v)=P(v)P(p)P(v∣p)
Here P ( p ∣ v ) P(p|v)P ( p ∣ v ) andP ( c ∣ v ) P(c|v)P ( c ∣ v ) is called the posterior probability (posterior), that is, we know the result and the probability of the inversion process happening;P ( c ) P(c)P ( c ) andP ( p ) P(p)P ( p ) is called the prior probability (prior), that is, we don't know the following situation for the time being, the possibility of the event happening before we know it;P ( v ∣ c ) P(v|c)P ( v ∣ c ) andP ( p ∣ c ) P(p|c)P ( p ∣ c ) is called likelihood, that is, the possibility of an event occurring in a certain situation.