Probability Pitfall – Uniformity Assumption Tanked CTR
Top recommendations had CTR far below random from assuming equal likelihood.
20+ years shipping production code across the stack, with years spent interviewing engineers. Everything here is grounded in real deployments.
- ✓Solid grasp of fundamentals
- ✓Comfortable reading code examples
- ✓Basic production concepts
- Probability is a fraction of favourable outcomes over total equally likely outcomes
- OR means add probabilities (minus overlap); AND means multiply (adjust for dependency)
- The complement trick: P(at least one) = 1 - P(none) saves time on multi-case problems
- With replacement: independent draws; without replacement: reduce denominator after each draw
- Enumerate small sample spaces to sanity-check formulas in interviews
- Biggest mistake: confusing independent and dependent events — always verify replacement
Imagine you have a bag with 3 red marbles and 2 blue marbles. Probability is just your way of answering: 'If I grab one without looking, how likely is it to be red?' You count the outcomes you WANT, divide by ALL possible outcomes, and that fraction is your probability. Every casino game, weather forecast, and spam filter runs on exactly this idea — just with more marbles.
Probability questions show up in almost every tech and finance aptitude round — not because companies want mathematicians, but because these problems reveal how you reason under uncertainty. When an interviewer asks 'what are the odds of drawing two aces from a shuffled deck?', they're watching whether you break a problem into smaller pieces, whether you remember to account for replacement vs. no-replacement, and whether you catch your own errors. These are the same mental habits that make a good engineer.
The frustrating part is that most candidates memorise formulas without understanding the logic behind them. So when a question is slightly rephrased — a bag becomes a box, marbles become cards — they freeze. The formula didn't break; their mental model was never solid in the first place. This article fixes that by building probability from the ground up: what it means, why the rules are what they are, and when each rule applies.
By the end of this article you'll be able to set up any classic probability problem from scratch without hunting for the right formula, spot the three most common traps that cost candidates marks, and explain your reasoning out loud — which is exactly what interviewers are listening for.
Why Uniformity Assumption Is a Silent CTR Killer
Probability problems aptitude is the ability to reason about outcomes under uncertainty — specifically, to identify when a uniform distribution assumption is invalid. In practice, this means recognizing that not all outcomes are equally likely, even when a problem statement implies they are. The core mechanic is mapping real-world frequencies to probability spaces correctly, which often requires conditional probability or Bayes' theorem.
Key properties: uniform distributions are rare in production systems. User behavior, network latency, and hardware faults all follow skewed distributions (e.g., power-law, Poisson). Assuming uniformity when data is skewed leads to systematic underestimation of rare events and overestimation of common ones. For example, if you model click probability as uniform across 10 ad slots but slot 1 gets 80% of clicks, your expected CTR is off by 4x.
Use this when designing A/B tests, capacity planning, or any system that relies on probabilistic guarantees. It matters because real systems fail not from wrong math, but from wrong assumptions about the underlying distribution. A 5% error in probability estimation can cascade into 30% error in revenue or latency SLOs.
The Foundation: What Probability Actually Means (and Why It's a Fraction)
Probability is a number between 0 and 1 that measures how likely an event is. A probability of 0 means impossible. A probability of 1 means certain. Everything else lives in between.
The core formula is: P(Event) = (Number of favourable outcomes) / (Total number of equally likely outcomes).
The word 'equally likely' is doing serious heavy lifting there. If you roll a fair six-sided die, each face has the same chance — that's what makes the formula valid. If the die were weighted, the formula breaks immediately. Always ask: are my outcomes truly equally likely?
There are two fundamental rules everything else builds on. The Addition Rule handles OR situations: if you want event A or event B, you add their probabilities but subtract any overlap to avoid double-counting. The Multiplication Rule handles AND situations: if you want event A and then event B, you multiply — but only if the events are independent of each other. Understanding when to add and when to multiply is the single biggest skill in aptitude probability.
Replacement vs. No Replacement — The Question That Trips Everyone Up
Here's the single most common source of wrong answers in probability aptitude questions: forgetting whether the item goes back into the pool after each draw.
With replacement, every draw is independent. You draw a card, note it, put it back, shuffle. The deck is always 52 cards. The second draw has no memory of the first.
Without replacement, the draws are dependent. You draw a card and keep it. Now the deck has 51 cards — and crucially, the composition of the deck has changed. The probability for the second draw must be recalculated based on what's left.
This is called conditional probability. The probability of event B given that event A has already happened is written P(B | A), pronounced 'P of B given A'. The multiplication rule for dependent events becomes: P(A and B) = P(A) × P(B | A).
A classic interview question: 'What's the probability of drawing two Aces in a row from a shuffled deck, without replacement?' The answer is (4/52) × (3/51) — four aces available first, then only three aces left in a 51-card deck. Getting this right immediately shows the interviewer you understand dependency.
Combinatorics + Probability: Solving 'At Least One' and Multi-Event Problems
Once you're comfortable with single events, interviewers escalate to multi-event problems. The phrasing 'at least one' is a classic escalation — and it has a beautiful shortcut.
Calculating P(at least one success) directly means adding up many cases: exactly one, exactly two, exactly three... It's tedious. Instead, use the complement: P(at least one) = 1 - P(none at all). It's almost always faster.
Combinations (nCr) come into play when order doesn't matter — like choosing a committee from a group, or finding the probability that a hand of cards contains exactly two hearts. The formula nCr = n! / (r! × (n-r)!) counts the number of ways to choose r items from n without caring about order.
The key decision tree is: Does order matter? If yes, use permutations. If no, use combinations. For most probability problems involving draws or selections, order doesn't matter — you're choosing a group, not arranging a sequence. When you combine nCr with the core probability formula, you can solve the most complex-looking aptitude problems in four clean steps: count favourable combinations, count total combinations, divide, simplify.
Conditional Probability and Bayes' Theorem — When New Information Changes Everything
Conditional probability answers the question: "Given that something has already happened, how does that change the odds of something else?" It's written P(B|A) — the probability of event B given that event A has occurred. The multiplication rule for dependent events is P(A and B) = P(A) × P(B|A).
Bayes' Theorem takes this further. It lets you reverse the condition: if you know P(B|A) and the individual probabilities, you can compute P(A|B). The formula is: P(A|B) = [P(B|A) × P(A)] / P(B).
A classic example: A medical test for a rare disease is 99% accurate. If you test positive, what's the probability you have the disease? Most people say 99%. But if the disease affects 1 in 10,000 people, Bayes shows the actual probability is about 1%. The false positives drown out the true positives because the base rate is so low.
In interview problems, Bayes often appears as "there's a bag of red and blue marbles, and you draw one but don't look at it; based on a clue, what's the chance it's red?" The key is to update the sample space with the new information.
- Prior: P(A) — your initial belief before seeing evidence.
- Likelihood: P(B|A) — how likely the evidence is if your belief is true.
- Marginal: P(B) — total probability of the evidence under all possibilities.
- Posterior: P(A|B) — updated belief after seeing the evidence.
- The formula is symmetric: it works for any two events, not just medical tests.
Expected Value and Decision Making Under Uncertainty
Expected value (EV) is the average outcome you'd get if you repeated an experiment many times. It's calculated as the sum of each outcome multiplied by its probability: EV = Σ (value × probability).
For example, a game where you roll a die: if it's 6 you win $10, otherwise you lose $2. The expected value is (1/6 × $10) + (5/6 × -$2) = $1.67 - $1.67 = $0. So the game is fair — no advantage either way.
In interviews, EV problems often appear as "should you play this game?" or "what's the fair price for a ticket?" The key is to list all possible outcomes, their probabilities, and their values, then sum.
Expected value extends to decision trees — when you have choices with probabilistic outcomes, choose the one with the highest EV. But always consider risk: a game with high variance might be avoided even if EV is positive, if losing hurts too much.
Stop Simulating: How to Spot Symmetry Before You Brute-Force
Most junior engineers reach for a Monte Carlo simulation the second they see dice, cards, or random sticks. That's like debugging a segfault by re-reading the entire codebase. Stop.
The dice problem from every competitor page has a clean analytical shortcut: when you roll N fair dice, the probability that the sum is divisible by 6 is exactly 1/6. Always. For any N≥1. Why? Because no matter what the first N-1 dice sum to, the last die has exactly one face (out of six) that makes the total divisible by 6. The first N-1 dice are irrelevant to the conditional probability.
This is the symmetry argument that separates production-grade reasoning from guesswork. You don't enumerate 6^10 outcomes. You don't code a loop that runs a million iterations. You look for independence and uniform coverage modulo the divisor. If every residue class modulo 6 is equally likely after N rolls, the answer is 1/6.
Apply this on your next interview problem: whenever you see "divisible by K" in a uniform discrete setting, ask whether the last draw can always compensate. If yes, you're done.
Median of Three Uniforms — Don't Sort, Think Binomially
The moment someone says "median of three random draws," your reflex should be a binomial expansion, not a sorting algorithm. The competitor problem — three draws from Uniform(0,2), median > 1.5 — is a textbook case.
For the median of three numbers to exceed a threshold T, you need at least two of the three draws to be greater than T. That's a binomial condition with n=3 and p = P(draw > T). For Uniform(0,2), P(draw > 1.5) = 0.25. So you compute P(k≥2) = C(3,2)p²(1-p) + C(3,3)p³ = 3(0.0625)*(0.75) + 0.015625 = 0.140625 + 0.015625 = 0.15625.
Every engineer who reaches for a sort on three elements is wasting cycles. You don't need to sort. You don't need to simulate. You only need to count successes in a binomial trial. The median is just the second order statistic — and order statistics on small samples are almost always reducible to binomial counting.
This generalizes: the k-th order statistic exceeding a threshold requires at least n-k+1 successes. Memorize that. It's cheaper than a sort.
Conditional Probability and Bayes Theorem Problems
Conditional probability and Bayes' theorem are essential for updating beliefs when new information arrives. In interview contexts, you'll often see problems like: "A test for a disease is 99% accurate. If 1% of the population has the disease, what is the probability a person who tests positive actually has the disease?" This is a classic Bayes problem. Let P(D) = 0.01, P(positive|D) = 0.99, P(positive|no D) = 0.01. Then P(D|positive) = (0.990.01) / (0.990.01 + 0.010.99) = 0.0099 / 0.0198 = 0.5. So even with a 99% accurate test, a positive result only gives a 50% chance of having the disease when the disease is rare. Another common problem: "A bag has 3 red and 2 blue balls. You draw one ball and then another without replacement. Given the second ball is red, what is the probability the first was blue?" Use conditional probability: P(first blue | second red) = P(first blue and second red) / P(second red). P(first blue and second red) = (2/5)(3/4)=6/20=0.3. P(second red) = P(first red, second red) + P(first blue, second red) = (3/5)(2/4)+(2/5)(3/4)=6/20+6/20=12/20=0.6. So answer = 0.3/0.6=0.5. Bayes' theorem is particularly powerful in machine learning for naive Bayes classifiers, but in interviews, focus on clear step-by-step calculation. Always define events, write the formula, and compute carefully.
Probability with Combinations: Card, Ball, Dice Problems
Many probability problems involve counting outcomes using combinations. For example: "What is the probability of drawing a full house (3 of a kind + a pair) from a standard 52-card deck?" The number of ways to get a full house: choose the rank for the three (13 choices), choose 3 suits out of 4 for that rank (C(4,3)=4), choose a different rank for the pair (12 choices), choose 2 suits out of 4 for that pair (C(4,2)=6). Total full house hands = 134126 = 3744. Total 5-card hands = C(52,5)=2,598,960. Probability = 3744/2598960 ≈ 0.00144. Another common problem: "An urn has 5 red and 7 blue balls. You draw 3 balls without replacement. What is the probability of getting exactly 2 red balls?" Number of ways to choose 2 red from 5: C(5,2)=10. Number of ways to choose 1 blue from 7: C(7,1)=7. Total favorable = 107=70. Total ways to choose 3 from 12: C(12,3)=220. Probability = 70/220 ≈ 0.318. For dice problems: "If you roll two dice, what is the probability the sum is 7?" There are 6 outcomes that sum to 7 (1-6,2-5,3-4,4-3,5-2,6-1) out of 36 total, so probability = 6/36=1/6. When solving these, always identify whether order matters (permutations) or not (combinations). In card and ball problems without replacement, combinations are usually appropriate. Practice with problems like "probability of getting at least one ace in a 5-card hand" (use complement: 1 - C(48,5)/C(52,5)).
Expected Value Problems for Aptitude Tests
Expected value (EV) is a core concept for decision-making under uncertainty. In aptitude tests, you might see: "A game costs $5 to play. You roll a fair die. If you roll a 6, you win $20. Otherwise, you lose. What is the expected value of playing?" EV = (1/6)20 + (5/6)0 - 5 = 20/6 - 5 = 3.33 - 5 = -$1.67. So on average, you lose $1.67 per play. Another common problem: "A company sells insurance policies. There is a 1% chance of a $10,000 claim, a 2% chance of a $5,000 claim, and 97% chance of no claim. What should the premium be to break even?" Expected payout = 0.0110000 + 0.025000 + 0.970 = 100 + 100 = $200. So the premium should be at least $200 to break even. More complex: "You have two investment options. Option A: 50% chance of $100 profit, 50% chance of $0. Option B: 30% chance of $200 profit, 70% chance of $50 loss. Which has higher expected value?" EV(A)=0.5100+0.50=$50. EV(B)=0.3200+0.7(-50)=60-35=$25. So A is better. Expected value is linear, so you can sum EVs of independent events. For example, if you roll two dice, the expected sum is 3.5+3.5=7. In interviews, always compute EV as sum of (probability value) for each outcome. Watch for hidden costs or gains. Also, consider variance if risk is a factor, but EV alone is often sufficient for basic aptitude questions.
The False Assumption of Uniformity in Recommendation Scoring
- Never assume equal likelihood without justification — always check historical data.
- Probability calculations are only as good as the input assumptions; base rates matter.
- Bayesian updating turns a naive probability model into a high-performing recommendation system.
| File | Command / Code | Purpose |
|---|---|---|
| basic_probability_foundation.py | def probability(favourable_outcomes, total_outcomes): | The Foundation |
| replacement_vs_no_replacement.py | p_first_ace_with = 4 / 52 # 4 aces in 52 cards | Replacement vs. No Replacement |
| combinatorics_probability.py | def combinations(n, r): | Combinatorics + Probability |
| bayes_theorem_example.py | p_disease = 1 / 10000 # 0.0001 | Conditional Probability and Bayes' Theorem |
| expected_value_game.py | def expected_value(outcomes, probabilities): | Expected Value and Decision Making Under Uncertainty |
| DiceSymmetry.py | def simulate_dice_rolls(num_dice: int, trials: int = 100_000) -> float: | Stop Simulating |
| MedianOrderStat.py | from math import comb | Median of Three Uniforms |
| bayes_disease.py | def bayes_disease(): | Conditional Probability and Bayes Theorem Problems |
| full_house_prob.py | def full_house_probability(): | Probability with Combinations |
| expected_value_game.py | def expected_value(): | Expected Value Problems for Aptitude Tests |
Key takeaways
Interview Questions on This Topic
A bag has 5 red and 3 green balls. Two balls are drawn without replacement. What is the probability that both balls are red? Walk me through your reasoning step by step.
Frequently Asked Questions
20+ years shipping production code across the stack, with years spent interviewing engineers. Everything here is grounded in real deployments.
That's Aptitude. Mark it forged?
9 min read · try the examples if you haven't