Joint Probability
Explore the fundamentals of joint probability, covering calculation methods for independent, mutually exclusive, and non-mutually exclusive events. Understand these concepts through practical examples involving random variables and real-world scenarios to build a solid foundation for probability and statistics in data science.
Random variable
A random variable is a function that assigns a real number to each value in the sample space. This is produced as a result of a random experiment, like tossing a coin or throwing a dice.
Example 1
When we flip a coin twice, there are four possible outcomes: both heads, heads and tails, tails and heads, or both tails. The value of x below represents the number of heads from each outcome of these four outcomes:
| Sample Space | x |
|---|---|
| HH | 2 |
| HT | 1 |
| TH | 1 |
| TT | 0 |
Example 2
Random variable Y represents the number of times we roll “5” when rolling a six-sided dice six times. Therefore, the possible values of this random variable Y, can be anything from 0 (we never roll “5”) to6 (we roll “5” every time).
Joint probability
This refers to the probability of two or more simultaneous events and is used in many areas of data science, especially when dealing with textual data, where we need to find the probability of words occurring together. The joint probability of two events is denoted as follows:
P(A and B) = P (A B)
Where and are probabilities of events and , respectively.
Probability for independent events
If one event is independent of the other, the events are said to be independent, and their joint probability is calculated as follows:
P(A and B) = P(A, B) = P (A B) = P(A) * P(B)
Where and are probabilities of events and , respectively.
Example
A jar contains three red, five green, two blue, and six yellow marbles. A marble is chosen from the jar at random. After replacing it, a second marble is chosen. What is the probability of choosing a green and then a yellow marble?
Solution
From the above question, we can deduce the below things from the above question:
- Number of red marbles = 3
- Number of green marbles = 5
- Number of blue marbles = 2
- Number of yellow marbles = 6
- Total marbles = 16
- Let A be the event that the green marble is drawn.
- Let B be the event that the yellow marble is drawn.
- Let C be the event that the blue marble is drawn.
- Let D be the event