Probability Tutorial for Data Science
1. Introduction to Probability
Probability measures the likelihood of an event occurring and is used in data science for making predictions based on data.
2. Basic Probability Formula
The probability of an event A occurring is given by:
P(A) = A / S
Where:
- P(A) is the probability of event A occurring.
- A is the number of favorable outcomes.
- S is the total number of possible outcomes.
3. Card Types
Suits |
Card Types |
Hearts |
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King |
Diamonds |
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King |
Clubs |
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King |
Spades |
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King |
4. Conditional Probability Examples with Cards
Example 1
Question: What is the probability of drawing a King given that the card drawn is a Heart?
Given that a Heart is drawn, there are 13 Hearts in total. Among these, there is only 1 King.
Answer: P(King | Heart) = 1 / 13
Example 2
Question: What is the probability of drawing a Queen given that the card drawn is a black card?
There are 26 black cards in total (13 Spades and 13 Clubs). Among these, there are 2 Queens (one in Spades and one in Clubs).
Answer: P(Queen | Black) = 2 / 26 = 1 / 13
Example 3
Question: What is the probability of drawing a red card given that the card is a face card?
There are 6 red face cards (Jack, Queen, King of Hearts and Diamonds) out of a total of 12 face cards (4 in each suit).
Answer: P(Red | Face Card) = 6 / 12 = 1 / 2
Example 4
Question: What is the probability of drawing an Ace given that the card is a Diamond or a Heart?
There are 2 Aces (one in Hearts and one in Diamonds) out of 26 cards (13 Hearts and 13 Diamonds).
Answer: P(Ace | Diamond or Heart) = 2 / 26 = 1 / 13
Example 5
Question: What is the probability of drawing a red card given that it is a numbered card (2 through 10)?
There are 18 red numbered cards (9 in Hearts and 9 in Diamonds) out of 36 numbered cards (9 in each suit).
Answer: P(Red | Numbered Card) = 18 / 36 = 1 / 2
Example 6
Question: What is the probability of drawing a King given that the card drawn is not a Spade?
There are 39 cards that are not Spades. Among these, there are 3 Kings (one in Hearts, one in Diamonds, one in Clubs).
Answer: P(King | Not Spade) = 3 / 39 = 1 / 13
Example 7
Question: What is the probability of drawing a face card given that the card is from the Clubs suit?
There are 3 face cards in the Clubs suit out of a total of 13 Clubs cards.
Answer: P(Face Card | Clubs) = 3 / 13
Example 8
Question: What is the probability of drawing a card numbered 5 given that the card is a red card?
There are 2 cards numbered 5 in red (one in Hearts and one in Diamonds) out of 26 red cards.
Answer: P(Number 5 | Red Card) = 2 / 26 = 1 / 13
Example 9
Question: What is the probability of drawing a Jack given that the card is a Heart?
There are 13 Hearts, and among these, there is 1 Jack.
Answer: P(Jack | Heart) = 1 / 13
Example 10
Example 10
Question: What is the probability of drawing a red card given that the card is a numbered card (2 through 10)?
There are 18 red numbered cards (9 in Hearts and 9 in Diamonds) out of a total of 36 numbered cards (9 in each suit).
Answer: P(Red | Numbered Card) = 18 / 36 = 1 / 2
5. Conditional Probability Examples with Dice
Example 1
Question: What is the probability of rolling a number greater than 4 given that an even number is rolled?
Even numbers on a dice are 2, 4, and 6. Out of these, only 6 is greater than 4.
Answer: P(Number > 4 | Even Number) = 1 / 3
Example 2
Question: What is the probability of rolling a 3 given that the roll is odd?
Odd numbers on a dice are 1, 3, and 5. Out of these, only 3 is the favorable outcome.
Answer: P(Rolling 3 | Odd Roll) = 1 / 3
Example 3
Question: What is the probability of rolling a number less than 4 given that the roll is a multiple of 2?
Multiples of 2 on a dice are 2, 4, and 6. Numbers less than 4 are 1, 2, and 3. Among the multiples of 2, only 2 is less than 4.
Answer: P(Number < 4 | Multiple of 2) = 1 / 3
Example 4
Question: What is the probability of rolling a 6 given that the roll is greater than 3?
Numbers greater than 3 on a dice are 4, 5, and 6. Among these, only 6 is the favorable outcome.
Answer: P(Rolling 6 | Greater than 3) = 1 / 3
Example 5
Question: What is the probability of rolling a 1 or a 2 given that the roll is less than 5?
Numbers less than 5 are 1, 2, 3, and 4. Favorable outcomes (1 or 2) are 2 out of these 4 numbers.
Answer: P(Rolling 1 or 2 | Less than 5) = 2 / 4 = 1 / 2