Quick summary
Summarize this blog with AI
Probability interview answers depend on the sampling process. The same numbers can produce different answers when draws are independent, a person is selected once rather than repeatedly, or a condition changes the population. These worked questions state those assumptions explicitly.
1. How many ads appear in 100 feed positions?
Suppose each position independently contains an ad with probability 0.04. Then X has a Binomial(100, 0.04) distribution: E[X] = 4 and Var(X) = 100 × 0.04 × 0.96 = 3.84. “More than twice the expected number” means X > 8, so sum probabilities for 9 through 100.
A different policy places an ad at positions 25, 50, 75, and 100. That policy produces exactly four ads and variance zero in this 100-position window. It is not the same random mechanism.
from math import comb
n, p = 100, 0.04
tail = sum(comb(n, k) * p**k * (1-p)**(n-k)
for k in range(9, n+1))
print(f"mean={n*p:.2f}; variance={n*p*(1-p):.2f}")
print(f"P(X > 8)={tail:.6f}")
The code prints P(X > 8) = 0.018992.
2. What about consecutive ads?
Define the quantity first. There are 99 adjacent position pairs, each with probability p² of containing two ads, so the expected number of adjacent ad pairs is 99 × 0.04² = 0.1584. A run of three ads contributes two overlapping pairs. Linearity of expectation applies even though those pair indicators are dependent.
The probability of at least one adjacent pair is different from that expectation. Track sequences with no pair, separating those that end in a non-ad from those that end in an ad. The following recurrence computes the probability without assuming overlapping pairs are independent.
def probability_of_adjacent_ads(n, p):
if not isinstance(n, int) or isinstance(n, bool) or n < 0:
raise ValueError("n must be a nonnegative integer")
if not 0 <= p <= 1:
raise ValueError("p must be between zero and one")
non_ad, ad = 1.0, 0.0
for _ in range(n):
non_ad, ad = (non_ad + ad) * (1-p), non_ad * p
return 1.0 - non_ad - ad
print(f"P(at least one adjacent pair)={probability_of_adjacent_ads(100, .04):.6f}")
The recurrence returns approximately 0.141620, or a 14.16% chance of at least one adjacent pair.
The maximum possible run in the independent model is 100; that event has probability 0.04¹⁰⁰. Under the specified every-25th-position policy, the longest run is one. Neither answer is the expected longest run, which is a separate question.
3. How many meetings are in a room known to be occupied?
Assign M meetings independently and uniformly to N rooms, where M and N are positive integers. For room 1, X is Binomial(M, 1/N). Because X is zero outside the event X > 0, E[X | X > 0] = (M/N) / (1 − (1 − 1/N)ᴹ). For M = 10 and N = 5, this is approximately 2.2406. The condition matters; the unconditional expectation is only 2. With M = 0, conditioning on a nonempty room is undefined.
4. How long until a particular user is selected?
There are 1,000 users and ten draws per round. With replacement within each round, and independent rounds, the chance of selecting a particular user at least once is q = 1 − (999/1000)¹⁰. The number of rounds through the first successful round is geometric, with expectation 1/q, approximately 100.4508.
If each round samples ten distinct users without replacement, then restores the full population before the next independent round, q = 10/1000 and the expectation is 100 rounds. Sampling without replacement across rounds is a different process and is not geometric.
5. What fraction of flagged stories are actually false?
Assume 2% of stories are false, sensitivity is 95%, and specificity is 95%. In a hypothetical 10,000-story population, expect 190 true positives and 490 false positives. The positive predictive value is 190/(190+490) = 19/68, approximately 27.94%.
Sensitivity and specificity are two separate rates; calling both “95% accuracy” loses information. A positive flag does not mean a story has a 95% chance of being false. The base rate affects the answer.
6. What distribution describes daily comments?
No distribution follows from the word “daily.” A Poisson model can be a starting assumption for counts under a suitable constant-rate, independent-arrival model. Compare observed mean and variance, exposure differences, day-of-week patterns, zeros, and extreme values. Overdispersion or clustering may require another model. A normal approximation needs justification and can assign probability to impossible negative counts.
7. What do repeated approvals reveal about a reviewer?
Suppose 20% of reviewers always approve, while the remaining 80% independently approve each item with probability 0.6. One randomly selected reviewer approves with probability 0.2 + 0.8 × 0.6 = 0.68. A rejection rules out the always-approve type under this idealized model. For 100 reviews with this marginal approval probability, the expected approval count is 68; independence is not required for that expectation.
Now select one reviewer and observe three approvals. Assuming conditional independence for the ordinary type, the posterior chance that this same reviewer is an always-approver is 0.2 / (0.2 + 0.8 × 0.6³), approximately 53.65%. Resampling a different reviewer for every item would not provide three observations about one person.
rooms, meetings = 5, 10
occupied_mean = (meetings / rooms) / (1 - (1 - 1/rooms)**meetings)
round_success = 1 - (999/1000)**10
posterior = 0.2 / (0.2 + 0.8 * 0.6**3)
print(f"occupied room: {occupied_mean:.4f}")
print(f"rounds with replacement: {1/round_success:.4f}")
print(f"flag precision: {190/(190+490):.4%}")
print(f"same-reviewer posterior: {posterior:.4%}")
All code uses Python’s standard library. In an interview, explain the model before calculating. For a shorter review of event rules and sampling without replacement, see the probability fundamentals guide.