Probability & Statistic in Machine Learning(I)
- Published time
What is probability?#
Ex: If there are ten child, three of them know how to play soccer. Find the probability that a child picked at randoms play soccer.
Ans:
Complement of Probability#
According to the previous example. Fine the probability of child NOT playing soccer.
Ans:
Sum of Probability#
Consider the joint event. Kids can play as many sports as they want. What is the probability that childs play soccer or basketball?
Ans:
Independence#
Product Rule
Condition Probability#
Product Rule
Bayes Theoram#
Monty hall problem#
Define the events:
- ๐ธ1ย = the car is behind door 1
- ๐ธ2ย = the car is behind door 2
- ๐ธ3ย = the car is behind door 3
Or, in a more concise way:ย ๐ธ๐ย = the car is behind doorย ๐ย forย ๐=1,2,3.
Note that these events areย mutually exclusive, in other words, you cannot have a car simuntaneously in two doors, because of the rules of the game. This means that,
๐(๐ธ1 โฉ ๐ธ2)=0,ย ๐(๐ธ1 โฉ ๐ธ3)=0ย andย ๐(๐ธ2 โฉ ๐ธ3) = 0.
You can say it also by writing that ๐(๐ธ๐ โฉ ๐ธ๐) = 0ย forย ๐โ ๐.
Another fact, due to the rules of the game, is thatย the car is behind one of the three doors, so ๐(๐ธ1 โช ๐ธ2 โช ๐ธ3)=1.
This is, in fact, theย sample space, orย universe,ย ฮฉ, because it is the set of all possible outcomes.
Let's suppose you've chosenย door number 1. Since there is an equal chance of the car being behind one of the three doors, we know that ๐(๐ธ1) = 1/3.
By theย complement rule, we know thatย ๐(๐ธ๐1) = 1โ๐(๐ธ1) = 1โ1/3 = 2/3
Since the universe is given byย ๐ธ1โช๐ธ2โช๐ธ3ย (the car is behind door 1 OR door 2 OR door 3), thenย ๐ธ๐1 = ๐ธ2โช๐ธ3, thereforeย ๐(๐ธ2โช๐ธ3)= 2/3. You can have a visual idea in the image below.
Now that you chose door 1, the Host then opens door 3, revealing a goat and asks you if you want to switch doors. If you don't switch, the probability of winning remainsย 13ย because this is your initial choice. If youย doย switch, then, you can notice that the Hostย gave you an additional information. They showed to you that door 3 does not have a car, which means that ๐(๐ธ3)=0.
Now you are mostly done, because as you know,ย 2/3=๐(๐ธ2 โช ๐ธ3)=๐(๐ธ2)+๐(๐ธ3)โ๐(๐ธ2 โฉ ๐ธ3). You already know thatย ๐(๐ธ2 โฉ ๐ธ3)=0, because they are mutually exclusive events (the car is behind in onlyย oneย of the three doors), and the Host gave you a very importante piece of additional information:ย ๐(๐ธ3)=0. With this, you can easily conclude that:
๐(๐ค๐๐|๐ ๐ค๐๐ก๐โ)=๐(๐ธ2)=2/3.
In other words, the probability that the car is behind door 2,ย given thatย it is not behind door 3 isย 2/3โ0.67ย as you have just seen in your simulations!
Consider a more complex situation
Now, the game is:
- There areย ๐ doors, and you must choose one door.
- Host opensย ๐ doors and revealing goats.
- You may or may not change your previously chosen door.
The question is: is it always better to switch doors? Will it depend onย ๐?
To answer this question analyticaly, first define the following events:
- ๐ธ๐=ย the car is behind door i. In this case,ย ๐=1,โฆ,๐.
Again, theย ๐ธ๐'s are independent from each other, because there is onlyย 1ย car available.
Note that, since the Host never opens the same door the player chose and also never opens the winning door, there is an upper bound forย ๐, which isย ๐โ2, so 0โค๐โค๐โ2.
Two facts can be assumed:
- The player chooses door 1
- The host opens doors 2,โฆ,๐+1
This is because we can always rename the doors to get this result. For instance, if the player chooses door numberย 10, we can rename it as doorย 1ย and doorย 1ย will become doorย 10. This is just to avoid getting too complex on indices notations. In math terminology, it is usually said that we can do thisย without loss of generality, since it will not affect the final result.
Now that there areย ๐ย doors, the probability that the car is behind doorย 1ย isย 1/๐, i.e.,
๐(๐ธ1)=1/๐.
By the complement rule, the probability that the car isย notย behind doorย 1ย is:
๐(๐ธ๐1)=1โ๐(๐ธ1)=1โ1/๐=๐โ1/๐.
Note that
๐ธ๐1 = ๐ธ2โช๐ธ3โชโฆโช๐ธ๐.
There is a notation to simplify the right hand side equation above, we can write it as:
This works in the same fashion as a summation symbol, but the opeartion being performed is set union.
So, we know that
Now we can answer the question: What is the probability of winning, given that we switch doors?
Let's take a look on the following image:
If the player switches to a random available door, then they must choose one of theย ๐+2,๐+3,โฆ,๐โ1,๐. Therefore, the probability of picking the car is:
The probability ofย not picking the carย in doorย 1ย (๐(๐ธ๐1)=๐โ1/๐)ย times the probability of picking the carย now, which isย 1๐โ๐โ1ย because this is the number of remaining doors.
So, the final probability is given by
It can be rewriten in the following manner:
And the equality only holds whenย ๐=0. This means that the host does not open any door.
Therefore,ย it is always better to switch doors. This may sound counterintuitive at first, but think that switching doors you are using theย new piece of informationย that the host gave you, whereas if you choose not to switch, you will be ignoring this new information.
Prior and Posterior#
P(A|B)๏ผPosterior
P(A)๏ผPrior
P(B|A)๏ผLikelihood
Probability in ML#
Example Problem: Face generation
- Generate a group of pixels such that resulting image lools like a human face
- Goal: generate images such P(face | pixels ) is high
Random Variables#
Why random variables๏ผ
Random variables allow us to model the whole experiment at once.
Event: A set of outcomes
Random variables: A function mapping outcomes to real numbers
Probability Distribution#
- Binomial Distribution
- Bernoulli Distribution
- Uniform Distribution
- Gussian(Normal) Distribution
- Chi-Squared Distribution
Discrete Probability Distribution#
PMF (Probability Mass Function)#
For a discrete random variable , the PMF is defined as:
Properties of PMF:
1. Non-negativity
2. Normalization (Completeness)
The sum of all probabilities must equal 1:
Proof:
Since must take on one of its possible values, all possible outcomes form the sample space:
These events are mutually exclusive (disjoint), so by the law of total probability:
Continuous Probability Distribution#
PDF (Probability Density Function)#
For a continuous random variable , the PDF is denoted as . Unlike PMF, the PDF does not represent the probability at a point. Instead, it describes the relative likelihood of values.
Key Properties:
1. Non-negativity
2. Normalization (Total Probability)
The total area under the curve equals 1:
Proof:
The probability that takes any value in its range must be 1:
3. Probability over an Interval
For any interval :
CDF (Cumulative Distribution Function)#
The CDF is a universal concept defined for both discrete and continuous random variables:
For Discrete Random Variables:
For Continuous Random Variables:
Properties of CDF:
1. Monotonicity
If , then:
Proof:
If , then the event is a subset of :
2. Boundary Conditions
3. Relationship between CDF and PDF
For a continuous random variable, the PDF is the derivative of the CDF:
Proof:
By the Fundamental Theorem of Calculus:
4. Probability Calculation using CDF
For any interval :
Proof:
Sampling from a Normal Distribution#
Use the CDF as shown in the following illustration:
This inverse-CDF approach works well when is easy to evaluate, but it is not the only way to sample from a distribution. In a later post, we will cover more general sampling methods โ such as importance sampling, rejection sampling, and MCMC โ which are needed when the target distribution's CDF is hard to invert, or when we only know the PDF up to a normalizing constant.
