Law of Total Probability and Counting

Why the concept of counting and law of total probability is important?


Law of Total Probability and Counting

This blog post focuses on the fundamental concepts of counting and the law of total probability. The Law of Total Probability is particularly important by considering all possible scenarios or "partitions" that could lead to an event taking place. Counting on the other hand is another concept (asked in a lot of interviews) allows us to assess various probabilites that involve counting procedures.

Law of Total Probability

Intuition: Imagine you are a trying to calculate the probability of an NBA player scoring a basket. A simple way to tackle this problem is to divide scoring a basket into free throws, 2-pointers and 3-pointers. We divided the 3 sub-types or events, now we calculate the probability of each sub-type and add them up. In the standard law of total probability, the events have to be disjoint. A player cannot shoot a 2-pointer and a 3-pointer at the same time.

Assume we have several disjoint events within B having accured we can break down the probability of an event A as follows:

P(A)=i=1nP(ABi)P(Bi)P(A) = \sum_{i=1}^{n} P(A | B_i)P(B_i)

where B1,B2,...,BnB_1, B_2, ..., B_n are disjoint events.

The probability of an event A occuring given that event B has occured is denoted as P(AB)P(A | B). This is also known as conditional probability and is an extension of the Bayes' theorem. Checkout my blog post on Conditional Probability and Bayes' Theorem for more details.

In our example, let the events be:

  • AA = Scoring a basket
  • B1B_1 = Scoring a free throw
  • B2B_2 = Scoring a 2-pointer
  • B3B_3 = Scoring a 3-pointer

The probability of scoring a basket is given by:

P(A)=P(AB1)P(B1)+P(AB2)P(B2)+P(AB3)P(B3)P(A) = P(A | B_1)P(B_1) + P(A | B_2)P(B_2) + P(A | B_3)P(B_3)

Where:

  • P(AB1)P(A | B_1) is the probability of scoring given that it's a free throw attempt (free throw percentage)
  • P(AB2)P(A | B_2) is the probability of scoring given that it's a 2-point attempt (2-point field goal percentage)
  • P(AB3)P(A | B_3) is the probability of scoring given that it's a 3-point attempt (3-point field goal percentage)
  • P(B1)P(B_1) is the probability of taking a free throw
  • P(B2)P(B_2) is the probability of taking a 2-point shot
  • P(B3)P(B_3) is the probability of taking a 3-point shot

Let's take Stephen Curry's free throw percentage, 2 point field goal percentage and 3 point field goal percentage along with free throw attempts, 2 point attempts and 3 point attempts from the 2024-2025 NBA season.

Shot TypeAttempts per GamePercentageP(Bi)P(B_i)P(ABi)P(A|B_i)
Free Throw4.393.3%0.1940.933
2-Point6.744.8%0.3020.448
3-Point11.239.7%0.5040.397

Note: P(Bi)P(B_i) is calculated by dividing each attempt type by total attempts (4.3 + 6.7 + 11.2 = 22.2)

Now we can calculate the overall probability of Steph Curry scoring on any given shot attempt:

P(A)=(0.933×0.194)+(0.448×0.302)+(0.397×0.504)=0.181+0.135+0.200=0.516P(A) = (0.933 × 0.194) + (0.448 × 0.302) + (0.397 × 0.504) = 0.181 + 0.135 + 0.200 = 0.516

This means Steph Curry has a 51.6% chance of scoring on any given shot attempt, accounting for all types of shots and their frequencies.

While this doesn't account for the type of shot being taken (because layups are not something curry would miss), it's an example to understand the concept of the law of total probability.

Counting

Counting is something we all learn from a very young age. We learn to count objects, numbers etc. In probability, counting shows up in two main ways:

  • If order of selection matters, we use permutations
  • If order of selection does not matter, we use combinations

In interviews, counting can be asked in one form or another. "How many ways can 5 people be seated in a row of 5 chairs?"

Permutations more simply put would be the arrangement of things where order matters.

As a basic principle, the number of ways you can arrange nn objects is n!n!.

My 3 favorite basketball players are Steph Curry, Lebron James, and Giannis Antetokounmpo. Let's say they're siting on stage having a podcast together. We can arrange them in 3! = 6 ways.

  • (Steph, Lebron, Giannis)
  • (Steph, Giannis, Lebron)
  • (Lebron, Steph, Giannis)
  • (Lebron, Giannis, Steph)
  • (Giannis, Steph, Lebron)
  • (Giannis, Lebron, Steph)

Permutations

The formula for permutations where you are selecting kk from nn objects is:

P(n,k)=n(n1)(n2)...(nk+1)=n!(nk)!P(n, k) = n * (n-1) * (n-2) * ... * (n-k+1) = \frac{n!}{(n-k)!}

Combinations

Combinations on the other hand would be selecting kk from nn objects where order does not matter.

The formula for combinations is:

C(n,k)=n!k!(nk)!C(n, k) = \frac{n!}{k!(n-k)!}

Let's use the same basketball players example but for combinations. If I want to pick 2 players out of the 3 (Steph, Lebron, Giannis) to play a 2v1 game, the order doesn't matter - picking (Steph, Lebron) is the same as picking (Lebron, Steph). Using the combination formula:

C(3,2)=3!2!(32)!=621=3C(3, 2) = \frac{3!}{2!(3-2)!} = \frac{6}{2 * 1} = 3

The three possible combinations are:

  • Steph and Lebron
  • Steph and Giannis
  • Lebron and Giannis

Permutations vs Combinations Example

Again since basketball is my favorite sport let's consider a basketball tournament where 10 teams participate. Let's solve two different scenarios:

  1. Permutation: Arranging the top 3 teams for Gold, Silver, and Bronze medals

    • Order matters (1st, 2nd, 3rd are different)
    • P(10,3)=10!(103)!=720P(10, 3) = \frac{10!}{(10-3)!} = 720 possible arrangements
  2. Combination: Selecting 3 teams for a special exhibition match

    • Order doesn't matter (just need any 3 teams)
    • C(10,3)=10!3!(103)!=120C(10, 3) = \frac{10!}{3!(10-3)!} = 120 possible selections

The Law of Total Probability helps us break down complex probability problems into simpler parts, as we saw with the basketball scoring example. Understanding when to use permutations vs combinations is crucial for solving counting problems - remember that permutations care about order (like ranking or arranging), while combinations don't (like selecting or choosing).

Thanks for reading!

Follow for more and feel free to contact me!