Probability with Events and Sample Spaces

Explore probability concepts including union, intersection, complement, conditional probability, and independence using visual representations of events within a sample space

Probability with Events and Sample Spaces

Probability theory provides a mathematical framework for reasoning about uncertainty. At its foundation are events and sample spaces.

Sample Space Basics

A sample space (denoted S) is the set of all possible outcomes of an experiment. An event is a subset of the sample space -- a collection of outcomes we are interested in.

Setting Up Our Events

Consider two events A and B within our sample space. Set their probabilities:

  • P(A) = 0.5 -- the probability that event A occurs
  • P(B) = 0.4 -- the probability that event B occurs
  • P(A ∩ B) = 0.15 -- the probability that both occur together

Events in Sample Space

Events in Sample Space

SAP(A) = 0.500BP(B) = 0.400P(A ∩ B) = 0.150
P(A)= 0.500
P(B)= 0.400
P(A ∩ B)= 0.150

The sample space S has total probability 1 (representing certainty). Each event occupies a portion of this space proportional to its probability.

Union and Intersection

The Intersection: P(A ∩ B)

The intersection of A and B (written A ∩ B) represents outcomes where both events occur simultaneously:

P(A∩B)=0P(A \cap B) = {\cmv{computed}{probIntersectionConstrained}}

This is shown as the overlapping region of the two events. Try dragging 0.15 to zero to make the events mutually exclusive, or increase it to see more overlap.

The Union: P(A ∪ B)

The union of A and B (written A ∪ B) represents outcomes where at least one of the events occurs. We calculate this using the Addition Rule:

P(A∪B)=P(A)+P(B)−P(A∩B)P(A \cup B) = P(A) + P(B) - P(A \cap B)

Why subtract P(A ∩ B)? Because adding P(A) + P(B) counts the intersection twice. Subtracting once corrects this double-counting.

For our values:

P(A∪B)=0+0−0=0P(A \cup B) = {\cmv{computed}{probA}} + {\cmv{computed}{probB}} - {\cmv{computed}{probIntersectionConstrained}} = {\cmv{computed}{probUnion}}

Union P(A ∪ B)

Union P(A ∪ B)

SAP(A) = 0.500BP(B) = 0.400P(A ∩ B) = 0.150
P(A)= 0.500
P(B)= 0.400
P(A ∩ B)= 0.150

Events A and B can occur together. The overlap region has probability 0.15.

Complement

The complement of event A (written A′A' or AcA^c) represents all outcomes where A does not occur:

P(A′)=1−P(A)=1−0=0P(A') = 1 - P(A) = 1 - {\cmv{computed}{probA}} = {\cmv{computed}{probAComplement}}

Similarly, P(B′)=1−0=0P(B') = 1 - {\cmv{computed}{probB}} = {\cmv{computed}{probBComplement}}. The complement is useful because sometimes it is easier to calculate what doesn't happen than what does.

The probability that neither A nor B occurs is the complement of the union:

P(neither)=1−P(A∪B)=1−0=0P(\text{neither}) = 1 - P(A \cup B) = 1 - {\cmv{computed}{probUnion}} = {\cmv{computed}{probNeither}}

Conditional Probability

Conditional probability answers: "What is the probability of A, given that B has occurred?" We restrict our sample space to only outcomes where B occurred, then ask what fraction of those also have A.

P(A∣B)=P(A∩B)P(B)=00=0P(A|B) = \frac{P(A \cap B)}{P(B)} = \frac{{\cmv{computed}{probIntersectionConstrained}}}{{\cmv{computed}{probB}}} = {\cmv{computed}{probAGivenB}}

Similarly:

P(B∣A)=P(A∩B)P(A)=00=0P(B|A) = \frac{P(A \cap B)}{P(A)} = \frac{{\cmv{computed}{probIntersectionConstrained}}}{{\cmv{computed}{probA}}} = {\cmv{computed}{probBGivenA}}

The picture shows what "restricting the sample space" means. On the left, S is cut into a strip for B (width P(B)) and a strip for "not B". Inside each strip, A fills the bottom part. Once we know B occurred, only the B strip is left, and A's share of that strip, its height, is P(A∣B)P(A|B). On the right the same space is cut by A instead, so the height of B inside the A strip is P(B∣A)P(B|A). The purple rectangle is A∩BA \cap B in both panels: the same area, but a different height, because the B strip and the A strip have different widths. That is exactly why P(A∣B)P(A|B) and P(B∣A)P(B|A) differ.

Conditioning Zooms In: Given B (left), Given A (right)

P(A|B) = 0.375P(B|A) = 0.3Bnot BAnot A000.51Strip widths: P(B), 1 - P(B) (left) and P(A), 1 - P(A) (right)Share of the stripA and BA onlyB onlyNeither

If we know B occurred, there is a 37.50% chance A also occurred. If we know A occurred, there is a 30% chance B also occurred. Notice that P(A∣B)≠P(B∣A)P(A|B) \neq P(B|A) in general -- adjust 0.5 and 0.4 to make them asymmetric and see this clearly.

Independence

Events A and B are independent if knowing one occurred does not change the probability of the other:

P(A∩B)=P(A)×P(B)P(A \cap B) = P(A) \times P(B)

In the picture above, independence means A fills the same height in the B strip and in the "not B" strip, both equal to P(A) (the thin line across the left panel): knowing whether B happened does not change A's share. For our events to be independent, we need P(A)×P(B)=0×0=0P(A) \times P(B) = {\cmv{computed}{probA}} \times {\cmv{computed}{probB}} = {\cmv{computed}{productAB}}. The current intersection is 0.15, so the difference from independence is 0.0500.

The events show negative dependence -- they tend to occur together less than expected by chance.

To make the events exactly independent, set 0.15 = 0.2000. To make them mutually exclusive, set it to 0. Watch how the conditional probabilities and the visualization respond.

Events in Sample Space

Events in Sample Space

SAP(A) = 0.500BP(B) = 0.400P(A ∩ B) = 0.150
P(A)= 0.500
P(B)= 0.400
P(A ∩ B)= 0.150

Try it in Code

# Probability: union, intersection, conditional, independence
p_a = 0.5
p_b = 0.4
p_intersection = 0.15

p_union = p_a + p_b - p_intersection
p_a_given_b = p_intersection / p_b
p_b_given_a = p_intersection / p_a
independent = abs(p_intersection - p_a * p_b) < 0.01

print(f"P(A union B) = {p_union:.4f}")
print(f"P(A') = {1 - p_a:.4f}, P(B') = {1 - p_b:.4f}")
print(f"P(A|B) = {p_a_given_b:.4f}, P(B|A) = {p_b_given_a:.4f}")
print(f"Independent? {'Yes' if independent else 'No'} (P(A)*P(B) = {p_a * p_b:.4f})")

What to explore next

You might also like