📚 Math in Society
⇩ Download ▾

12.3 Working with Events

Complementary Events

Now let us examine the probability that an event does not happen. As in the previous section, consider the situation of rolling a six-sided die and first compute the probability of rolling a six: the answer is P(six)=16. Now consider the probability that we do not roll a six: there are 5 outcomes that are not a six, so the answer is P(not a six)=56. Notice that

P ( six ) + P ( not a six ) = 1 6 + 5 6 = 6 6 = 1

This is not a coincidence. Consider a generic situation with n possible outcomes and an event E that corresponds to m of these outcomes. Then the remaining nm outcomes correspond to E not happening, thus

P ( not  E ) = n m n = n n m n = 1 m n = 1 P ( E )

Probability of two independent events

The prior example was looking at two independent events.

When two events are independent, the probability of both occurring is the product of the probabilities of the individual events.

If you look back at the coin and die example from earlier, you can see how the number of outcomes of the first event multiplied by the number of outcomes in the second event multiplied to equal the total number of possible outcomes in the combined event.

In the last example, the events were mutually exclusive, so P(A or B)=P(A)+P(B).

Conditional Probability

Often it is required to compute the probability of an event given that another event has occurred.

Notice from the last example that P(B|A) is not equal to P(A|B).

These kinds of conditional probabilities are what insurance companies use to determine your insurance rates. They look at the conditional probability of you having accident, given your age, your car, your car color, your driving history, etc., and price your policy based on that likelihood.

# The book's speeding-ticket survey. CHANGE any of the four counts and re-run.
ticket_red,    no_ticket_red    = 15, 135
ticket_notred, no_ticket_notred = 45, 470

red    = ticket_red + no_ticket_red
notred = ticket_notred + no_ticket_notred
ticket = ticket_red + ticket_notred
total  = red + notred

print("%-12s %10s %13s %8s" % ("", "Ticket", "No ticket", "Total"))
print("-" * 46)
print("%-12s %10d %13d %8d" % ("Red car", ticket_red, no_ticket_red, red))
print("%-12s %10d %13d %8d" % ("Not red", ticket_notred, no_ticket_notred, notred))
print("%-12s %10d %13d %8d" % ("Total", ticket, total - ticket, total))
print()

p_red    = red / total
p_ticket = ticket / total
p_both   = ticket_red / total
print("P(red)                = %3d/%d = %.4f" % (red, total, p_red))
print("P(ticket)             = %3d/%d = %.4f" % (ticket, total, p_ticket))
print("P(red AND ticket)     = %3d/%d = %.4f" % (ticket_red, total, p_both))
print("P(red OR ticket)      = P(red) + P(ticket) - P(both) = %.4f"
      % (p_red + p_ticket - p_both))
print()
print("P(ticket | red)       = %3d/%-3d = %.4f   <- only the RED CAR row"
      % (ticket_red, red, ticket_red / red))
print("P(red | ticket)       = %3d/%-3d = %.4f   <- only the TICKET column"
      % (ticket_red, ticket, ticket_red / ticket))
print("Same numerator, different denominator. P(A|B) is not P(B|A).")
print()

# Independence check. For a 2x2 table the events are independent exactly when
# (ticket & red) x (no ticket & not red) == (no ticket & red) x (ticket & not red).
print("If colour and tickets were INDEPENDENT, P(red AND ticket) would equal")
print("   P(red) x P(ticket) = %.4f, i.e. %.1f people, not the %d observed."
      % (p_red * p_ticket, p_red * p_ticket * total, ticket_red))
print("   P(ticket) overall = %.4f   vs   P(ticket | red) = %.4f"
      % (p_ticket, ticket_red / red))
print("   cross-products: %d x %d = %s  vs  %d x %d = %s   (equal => independent)"
      % (ticket_red, no_ticket_notred, "{:,}".format(ticket_red * no_ticket_notred),
         no_ticket_red, ticket_notred, "{:,}".format(no_ticket_red * ticket_notred)))
print()
print("Set ticket_red to %d and re-run: the cross-products very nearly line up, the"
      % round(no_ticket_red * ticket_notred / no_ticket_notred))
print("two rates match, and knowing the colour tells you nothing about the ticket.")
print("Even as it stands, this is a SURVEY: it cannot tell you that the paint")
print("caused the ticket, only that the two turned up together more often.")

Adapted from Math in Society by David Lippman, hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 3.0. Changes were made. License: CC-BY-SA-3.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.