CH2.3 - Conditional Probability and Independence

This section covers conditional probability and independence. Conditional probability is the probability of an event given that another event has occurred. Independence is when the occurrence of one event does not affect the probability of another event.


Example

Example

This probability is an Intersection and joint probability, think of multiply, but only if you can answer the following question.


Independence

Question

Are the events Independent of each other?

Independent - the outcome of one event does not effect the probability of the other event

Here are some examples of independent events:

Independent Events

  • spin a roulette wheel twice
  • flip a coin twice
  • rolling two dice
  • sampling with replacement

Going back to the question, lets look at the possible answers.

Option 1: Yes

Option 2: No

Lets tackle a practice problem now.


Practice Problem

Problem

Mobile telephones perform handoffs as they move from call to cell. During a call, a telephone either performs zero handoffs (0), one handoff (H1), or more than one handoff (H2). IN addition, each call is either long (L), if it last more then three minutes, or brief (B). We have the following table that represents the data, a sample of 100 calls:

H0H1H2Row Total
L10102040
B40101060
Col Total502030n=100

Research Question: Are lengths and handoffs Independent of Each Other?

  1. Marginal Distributions

Length

Probability of a Long Call Probability of a Brief Call

Handoffs

Probability of Zero Handoffs Probability of One Handoff Probability of More than One Handoff

  1. Conditional Distributions

Condition in a level for one categorical variable given the level of another categorical variable.

Calculating for the following probabilities:

  • Probability of Zero Handoffs given a Long Call

P ( * | L)

  • Probability of Zero Handoffs given a Brief Call

P ( * | B)

  • Probability of a Long Call given Zero Handoffs

P ( * | H0)

  • Probability of a Brief Call given Zero Handoffs

P ( * | H1)

  • Probability of a Long Call given More than One Handoff

P ( * | H2)

Bringing it all together, let’s calculate the following:

Final Calculations

Segmented Bar Chart with Matplotlib

import micropip
await micropip.install("matplotlib")
await micropip.install("numpy")
 
import numpy as np
import matplotlib.pyplot as plt
 
# define the data
# bar Chart
N = 3
ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars
 
p1 = plt.bar(ind, (0.25, 0.67, 0.67), width, color='r')
p2 = plt.bar(ind, (0.25, 0.17, 0.17), width, color='b', bottom=(0.25, 0.67, 0.67))
p3 = plt.bar(ind, (0.5, 0.17, 0.17), width, color='g', bottom=(0.5, 0.17, 0.17))
 
# add some text for labels, title and axes ticks
plt.ylabel('Probability')
plt.title('Probability by Length and Handoff')
plt.xticks(ind, ('H0', 'H1', 'H2'))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.legend((p1[0], p2[0], p3[0]), ('L', 'B', 'H2'))
 
# Display the chart
plt.show()

Either:

Conditionals are not similar to marginals, there is an association between the two, and thus, not independent.

Or:

Conditionals are Similar to Marginals, there is no association between the two, and thus, independent.


Showing Mathematically: are two events independent

Lets find a random combination from that table and determine if they are independent.

Question

Are L and H0 independent of each other?

Therefore, is


Example - Independence

Example

If you own two cars, what is the probablity that:

  • neither will need repair?
  • both will need repair?
  • at least one car will need repair?

Probability table

Xp(x)
0.72
1.17
2.07
≥ 3.04
  1. Neither will need repair

Correct Answer

  1. Both will need repair

Correct Answer

  1. At least one car will need repair

Correct Answer

Example - Independence

Classic exmaple: Balls in Urn to Demonstrate Tree Diagrams, Conditional Probability, Joint Probability, and Independence.

Example

10 balls in an urn, 3 are orange, 5 are red, and 2 are blue. Draw two balls without replacement.

Mermaid Tree Diagram

The following tree diagram is a visual representation of the problem.

graph LR
    Start["Start (10 balls)"]

    Start --> O1["Orange (3/10)"]
    Start --> R1["Red (5/10)"]
    Start --> B1["Blue (2/10)"]

    O1 --> O2["Orange (2/9)"]
    O1 --> R2["Red (5/9)"]
    O1 --> B2["Blue (2/9)"]

    R1 --> O3["Orange (3/9)"]
    R1 --> R3["Red (4/9)"]
    R1 --> B3["Blue (2/9)"]

    B1 --> O4["Orange (3/9)"]
    B1 --> R4["Red (5/9)"]
    B1 --> B4["Blue (1/9)"]

From the tree diagram, we can calculate the following:

  1. Probability of Drawing an Orange Ball

Correct Answer

  1. Probability of Drawing a Red Ball

Correct Answer

  1. Probability of Drawing a Blue Ball

Correct Answer