1. Home
  2. Explore
  3. Computer Science
  4. Probability and Federalist Papers

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Probability and Federalist Papers

Speaker 1Speaker 2

Probability and Federalist Papers

6:17
0:00-6:17
  1. Anna

    Alright Corey, we've wrapped up single random variables – the normal distribution was the last big one. But now we're stepping into something much bigger: probabilistic models where we handle multiple random variables at once.

  2. Corey

    And just to make sure we're solid on normals before we dive in, they gave us that awesome review problem about Alibaba's Singles Day. You have to figure out how many servers to buy so the probability of dropping requests is less than 0.00001.

  3. Anna

    Right, that problem really tests your understanding of the CDF and its inverse. You start with the probability of no drops being greater than 0.99999, which means you need to find the number of requests R such that P(X < R) = 0.99999, where X is the number of requests. Then you use the normal CDF formula: P(X < R) = Phi((R - mean)/std).

  4. Corey

    And since you're solving for R, you need to invert Phi. The inverse Phi of 0.99999 is about 3.719. So you get R = mean + 3.719 * std. With mean = 1,000,000 and std = 10,000, that gives R ≈ 1,037,190 requests. Then divide by 10,000 requests per server, and you need 104 servers. That's a neat application of the normal distribution.

  5. Anna

    Exactly – and it's a good reminder that the CDF gives probabilities from inputs, while the inverse CDF gives inputs from probabilities. Now, shifting gears: we're going from one random variable to many. The most complete description of multiple random variables is their joint distribution.

  6. Corey

    For discrete random variables, that's the joint probability mass function. It gives the probability of every combination of outcomes. Like if you roll two dice, the joint PMF says P(X=1, Y=6) = 1/36. But for more interesting cases, like the survey data they showed – year in school and relationship status – the joint table tells you everything.

  7. Anna

    And from that joint table, you can answer any probability question. For example, the probability that someone is in a relationship is just the sum of probabilities across all years for that status. That's called marginalization – you sum over the other variable to get the distribution of one.

  8. Corey

    Fun fact: they called it marginal because before computers, they'd literally write the sums in the margins of the table. And it's really just the law of total probability in disguise. But here's the catch: joint tables grow exponentially with the number of variables.

  9. Anna

    Right, with 10 variables each taking 5 values, you'd need 5^10 entries. That's almost 10 million numbers – too many to estimate or store. So we need more efficient representations. That's where the multinomial distribution comes in.

  10. Corey

    The multinomial is the big sister of the binomial. Instead of two outcomes, it handles m outcomes. If you roll n dice with m sides, you get counts for each outcome. The joint PMF for those counts is a single formula: (n! / (c1! c2! ... cm!)) * p1^c1 * p2^c2 * ... * pm^cm, where the ci sum to n and the pi sum to 1.

  11. Anna

    This is way more efficient than a giant table. For 100 dice with 6 outcomes, you'd have 6 random variables, each taking values 0 to 100. A full table would have 101^6 entries – astronomically huge. But the multinomial PMF gives you the probability for any specific combination in one compact equation.

  12. Corey

    And just like the binomial is used for coin flips, the multinomial is used for text analysis. Think of a document as a roll of a giant die with one face for every word in the English language. The counts of words in a document follow a multinomial distribution.

  13. Anna

    Exactly. They gave the example of spam detection: if you have a spam email, the word probabilities are different from a normal email. The multinomial lets you compute the probability of seeing that exact set of word counts, given the author is a spammer.

  14. Corey

    That leads directly to the famous Federalist Papers problem. We have 85 essays written under the pseudonym Publius, but actually by Hamilton, Madison, and Jay. For essay 53, both Hamilton and Madison claimed authorship. So we need to figure out who really wrote it.

  15. Anna

    We have known texts from each author. From those, we can estimate the probability of each word given the author. For the unknown essay, we compute the likelihood using the multinomial: P(document | author) = multinomial formula. Then we want P(author | document), which is a job for Bayes' theorem.

  16. Corey

    We can set a prior P(Hamilton) = P(Madison) = 0.5. Then P(Hamilton | document) = P(document | Hamilton) * 0.5 / P(document). The denominator is messy, but we can avoid it by taking the ratio of the two posterior probabilities. If the ratio is greater than 1, Hamilton is more likely.

  17. Anna

    And the beautiful thing is that the multinomial coefficient and the prior cancel out in the ratio. So you just compare the product over words of P(word | Hamilton)^count to the product over words of P(word | Madison)^count. Whichever is larger wins.

  18. Corey

    But when they actually computed these probabilities for the unknown essay, both came out as exactly zero! How is that possible? The probabilities should not be zero.

  19. Anna

    That's the cliffhanger. The problem is that you're multiplying many small probabilities together – for a 2000-word document, you might be multiplying thousands of numbers between 0 and 1. That causes underflow in a computer's floating point representation. The true probability isn't zero, but the computer rounds it to zero.

  20. Corey

    So what's the fix? They hinted at it in the review: use log probabilities. Instead of multiplying, you add logs. That keeps the numbers in a range the computer can handle. And the ratio becomes a difference of log-likelihoods. We'll see that on Friday.

  21. Anna

    Right – logarithms turn products into sums, and computers are much better at summing moderate-sized numbers than multiplying tiny ones. That's a key trick for computational probability. So we'll come back to solve the Federalist Papers mystery next time. For now, we've laid the foundation: joint distributions, marginalization, the multinomial, and the need for smarter representations.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent