Index Ai Academy
Foundation · Foundation mathProbability

Combining events: and, or, independent

About 42 minLooking ahead: some prerequisites aren't done yet

Why this matters

Real questions rarely involve one event. Will it rain and will the trail flood? Will the first or the second attempt succeed? Two rules handle most of them: "or" adds (carefully), and "and" multiplies, when the events don't affect each other. A tree diagram keeps the bookkeeping straight when they do. The "and" rule has a sobering consequence for AI systems that act in many steps: an agent that gets each step right 95% of the time finishes a ten-step task only about 60% of the time. This lesson builds both rules, draws the trees, checks them by simulation, and works out exactly that.

  • Find the chance of "A or B": add, then subtract the overlap so it isn't counted twice
  • Find the chance of "A and B" for independent events by multiplying
  • Draw a probability tree: multiply down each branch, add the branches that make an event, with and without replacement
  • Work out how reliable a multi-step agent is when every step can fail, by hand, in a plot and with PyTorch
Quick check
Have a guess before you start. Two fair coins are tossed. What is the chance both land heads?

The math: "or" adds, "and" multiplies

Purpose. Chances of several things together.

"Or". For a die, P(even or above 4): the outcomes are 2, 4, 5 and 6, so 4/6. Adding P(even) = 3/6 and P(above 4) = 2/6 gives 5/6: too big, because 6 is in both and got counted twice. Subtract the overlap:

P(A or B)=P(A)+P(B)−P(A and B)P(A \text{ or } B) = P(A) + P(B) - P(A \text{ and } B)

In plain words: add the two, then take away what they share, so nothing is counted twice.

When A and B can't happen together (mutually exclusive), the overlap is 0 and the chances simply add.

The picture. Sort the die's six faces into two circles: even on the left, above 4 on the right. The 6 belongs to both, so it sits where the circles overlap. Step through the three pictures and watch which faces each chance counts.