DEV Community

Cover image for Counting in Probability: A Dev's 2x2 Cheat Sheet
moonwalker
moonwalker

Posted on

Counting in Probability: A Dev's 2x2 Cheat Sheet

I enjoy probability and statistics, but counting problems often confuse me - especially with questions of replacement and order in experiments.

Here's a 2X2 matrix that handles these 4 possibilities:

Selection Type \ Order Order Matters Order Doesn't Matter
With Replacement n^r C(n+r-1,r)
Without Replacement P(n,r) = n!/(n-r)! C(n,r) = n!/(r!(n-r)!)

Where:

  • n = total items to choose from
  • r = items being chosen
  • P(n,r) denotes Permutation
  • C(n,r) denotes Combination

To classify any counting problem, ask two questions:

  • Can I use the same item again?
  • Does sequence matter?

Examples:

  1. Candy jar

    Allows replacement - can pick a candy, return it, and pick it again

  2. Deck of cards

    No replacement - once drawn, a card stays out of the deck

  3. Password

    Allows replacement - can reuse letters, and order matters

  4. Committee

    No replacement - each person picked once, order doesn't matter

Top comments (0)