CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Math / Probability by Simulation

And, Or: Overlaps Count Once

Lesson 4 of 11 · 7 min · Free, no account needed

What you will learn

  • A and B is the overlap: the cells in both events.
  • A or B is every cell in at least one of them. Plain adding counts the overlap twice.
  • So P(A or B) = P(A) + P(B) − P(A and B). With no overlap, plain adding works.

Start the lesson

How the lesson goes

  1. A 6 on the first die OR a double: just add 6 + 6?

    How many of the 36 cells fit? Drag the pin to your bet.

  2. Paint both events.

    First paint every cell with a 6 on the first die, then every double. Drag across the cells.

    The bottom row has 6 cells and the diagonal has 6, but they share the 6-6 cell. Painted cells: 6 + 6 − 1 = 11, so P = 11/36.

  3. Tap the cells that are in BOTH events.

    Blue is A, yellow is B, split cells are both. Tap each cell that fits A and B.

    A and B means both are true at once, so only cells inside both painted areas count. A double has an even total, so it can never total 7.

  4. And, or, and the overlap

    A and B: both happen. It is the overlap of the two painted areas.

    A or B: at least one happens. It is everything painted, counted once.

    P(A or B) = P(A) + P(B) − P(A and B): 6/36 + 6/36 − 1/36 = 11/36.

  5. Game: overlap hunter.

    Paint each A or B as fast as you can. The card shows the count to aim for.

  6. Make a pair where plain adding works.

    Pick event A and event B so that they never happen together.

    If two events share no cells they can't happen together, so the overlap is 0 and P(A or B) = P(A) + P(B).

  7. Your pair, as code. What will it print?

    The loops walk all 36 cells and count the ones where your A or your B is true. Drag the pin, then Run.

    An if with or is true when at least one side is true, so each cell is counted once. With no overlap, that is A's cells plus B's cells.

  8. Paint: a total of 10 OR a double.

    Paint every cell that fits, then Check.

    Total 10 has 3 cells and doubles have 6. 5-5 is in both, so A or B has 3 + 6 − 1 = 8 cells.

  9. Twist: tap Not.

    The doubles are painted. Not paints everything else.

Previous lesson: Counting the Outcomes · Next lesson: Independent or Not? · Part of the course: Probability by Simulation

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab