PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Statistics & Math/Snapchat

Calculate Posterior Probability Using Bayes' Theorem Example

Last updated: Jun 24, 2026

Quick Overview

This question evaluates understanding of Bayes' theorem and probabilistic reasoning for computing posterior probabilities in binary classification, emphasizing priors, likelihoods, and conditional probability.

  • easy
  • Snapchat
  • Statistics & Math
  • Data Scientist

Calculate Posterior Probability Using Bayes' Theorem Example

Company: Snapchat

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Technical Screen

##### Scenario Interviewers want to test your understanding of Bayes’ theorem using a straightforward numerical example (e.g., medical-test or spam-detection toy problem). ##### Question Walk through a complete Bayes-theorem calculation: 1) clearly define prior P(H) and likelihoods P(E|H), P(E|¬H); 2) write the full formula; 3) compute the posterior P(H|E) and report the final numeric answer. ##### Hints State assumptions, show every step, then simplify to one decimal/fraction.

Quick Answer: This question evaluates understanding of Bayes' theorem and probabilistic reasoning for computing posterior probabilities in binary classification, emphasizing priors, likelihoods, and conditional probability.

Related Interview Questions

  • Compute posterior spam risk from flags - Snapchat (Medium)
  • Derive logistic regression and thresholds - Snapchat (hard)
  • Explain median vs mean for L1/L2 - Snapchat (medium)
  • Compute expectations and test fairness for coin flips - Snapchat (easy)
  • How to Update Bayesian Model for Concept Drift? - Snapchat (medium)
|Home/Statistics & Math/Snapchat

Calculate Posterior Probability Using Bayes' Theorem Example

Snapchat logo
Snapchat
Jul 12, 2025, 6:59 PM
easyData ScientistTechnical ScreenStatistics & Math
27
0

Bayes' Theorem: Spam-Flag Posterior

You are evaluating a simple classifier that flags messages as spam. From historical data you know the spam prevalence and the classifier's performance (true-positive and false-positive rates). A message has just been flagged. Compute the probability that it is actually spam.

You are given:

  • Prior spam rate: 2% of all messages are spam.
  • True-positive rate: if a message is spam, the classifier flags it 90% of the time.
  • False-positive rate: if a message is not spam, the classifier still flags it 5% of the time.

Produce a complete, step-by-step Bayes-theorem solution:

  1. Define the events, the prior P(H)P(H)P(H) , and the likelihoods P(E∣H)P(E\mid H)P(E∣H) and P(E∣¬H)P(E\mid \neg H)P(E∣¬H) .
  2. Write the full posterior formula.
  3. Compute the posterior P(H∣E)P(H\mid E)P(H∣E) and report the final numeric answer.

Show every step, state your assumptions, and simplify the final answer to a clear fraction and a one-decimal-place percentage.

Constraints & Assumptions

  • The three given numbers — prior P(H)=0.02P(H)=0.02P(H)=0.02 , P(E∣H)=0.90P(E\mid H)=0.90P(E∣H)=0.90 , P(E∣¬H)=0.05P(E\mid \neg H)=0.05P(E∣¬H)=0.05 — are treated as exact.
  • "Flagged" is a single binary event EEE ; the two classes (spam / not spam) are mutually exclusive and exhaustive, so P(¬H)=1−P(H)=0.98P(\neg H)=1-P(H)=0.98P(¬H)=1−P(H)=0.98 .
  • A "spam" message and a flag are well-defined; no abstention, no third class, no time dependence in the rates.

Clarifying Questions to Ask

  • Is the 2% the unconditional prior over all messages, or already conditioned on some pre-filter? (It changes the base rate that drives the answer.)
  • Is the 5% figure the false-positive rate P(E∣¬H)P(E\mid\neg H)P(E∣¬H) , or is it the specificity ? (If specificity, then P(E∣¬H)=1−specificityP(E\mid\neg H)=1-\text{specificity}P(E∣¬H)=1−specificity .)
  • Are the rates stable across message types/time, or should I expect them to drift (motivating later calibration)?
  • What is the downstream cost of a false positive vs. a missed spam — i.e. is the relevant target the posterior, or a threshold chosen to balance those costs?

What a Strong Answer Covers

  • Correct mapping of the three given numbers to P(H)P(H)P(H) , P(E∣H)P(E\mid H)P(E∣H) , P(E∣¬H)P(E\mid\neg H)P(E∣¬H) , and explicit derivation of P(¬H)P(\neg H)P(¬H) .
  • Right inferential direction: computes P(H∣E)P(H\mid E)P(H∣E) and explains why it differs sharply from the 90% true-positive rate.
  • Law of total probability used to build the denominator P(E)P(E)P(E) , not an unjustified value.
  • Arithmetic that lands on the exact fraction and its decimal/percentage form.
  • Interpretation of the base-rate effect: articulates why a strong detector yields a modest posterior when spam is rare.
  • Optional but valued: a natural-frequency cross-check confirming the algebra.

Follow-up Questions

  • The product team wants the flagged set to be at least 80% truly spam (precision ≥0.80\ge 0.80≥0.80 ). Holding the prior fixed, what false-positive rate would you need, and is that realistic?
  • If the true spam prevalence doubled to 4%, what happens to the posterior, and which input has more leverage on it — the prior or the false-positive rate?
  • How would you extend this from a single posterior to a full precision–recall trade-off as you sweep the classifier's decision threshold?
  • The classifier outputs a continuous score, not a hard flag. How would you reason about P(spam∣score=s)P(\text{spam}\mid\text{score}=s)P(spam∣score=s) , and how would you check that the scores are calibrated ?
Loading comments...

Browse More Questions

More Statistics & Math•More Snapchat•More Data Scientist•Snapchat Data Scientist•Snapchat Statistics & Math•Data Scientist Statistics & Math

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.