Comparing Ad Distribution Models: Random vs. Deterministic Placement
Statistics & ExperimentsModel answerLast updated
Analyze two ad-serving approaches for a content feed: probabilistic per-item insertion versus fixed-quota allocation.
You're designing an ad-serving system for a social media feed containing 100 pieces of content.
Your team is evaluating two approaches:
Approach 1: Each piece of content has a 4% chance of being replaced with an ad, independently.
Approach 2: Divide the feed into consecutive groups of 25 items each, and place exactly one ad in each group.
For both approaches, answer the following:
- What are the expected number of ads and the variance in ad count?
- What is the probability that a user sees more than 8 ads (double the target)?
- What is the expected number of times two ads appear consecutively? Which approach is more prone to creating long sequences of multiple ads in a row?
Explain your reasoning and discuss the product implications of each approach.
Hints
Hint 1
For the probabilistic method, recognize the binomial distribution and use its standard formulas
Hint 2
The quota-based method produces a fixed total; think about what that means for variance
Hint 3
Use indicator random variables and linearity of expectation to count adjacent ad occurrences
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
Overview
This problem tests whether you understand how different randomization strategies create different user experiences even when they target the same average outcome. The key insight is that matching means doesn't imply matching distributions—variance and clustering behavior matter for product quality.
Part 1: Mean and Variance
Approach 1 (Probabilistic):
Let X represent the ad count. Since each item independently becomes an ad with probability p = 0.04, X follows a binomial distribution: X ~ Binomial(100, 0.04).
- Mean: E[X] = 100 × 0.04 = 4 ads
- Variance: Var(X) = 100 × 0.04 × 0.96 = 3.84
- Standard deviation: √3.84 ≈ 1.96
Approach 2 (Deterministic Quota):
The feed contains exactly 100/25 = 4 groups, with exactly one ad per group.
- Mean: E[X] = 4 ads
- Variance: Var(X) = 0
The variance is zero regardless of whether ads occupy fixed positions (say, every 25th slot) or random positions within each group. Either way, every feed contains exactly 4 ads.
Part 2: Tail Probability for Excessive Ads
We want P(X > 8), the chance of showing more than double the expected count.
Approach 1 Analysis:
Normal approximation (what the problem hints at):
With continuity correction: z = (8.5 − 4)/1.96 ≈ 2.30, giving P(X ≥ 9) ≈ Φ(−2.30) ≈ 1.1%.
Reality check (what strong candidates add):
The normal approximation performs poorly here because np = 4 is quite small and the distribution is right-skewed. Computing the exact binomial tail using the recursive formula P(k+1) = P(k) × [(100−k)/(k+1)] × (0.04/0.96), we get:
P(X ≤ 8) ≈ 0.981, so P(X ≥ 9) ≈ 1.9%.
A Poisson(4) approximation yields a similar result (≈2.1%). The normal approximation with continuity correction underestimates this tail due to skewness.
Practical interpretation: About 2% of users see double the target ad load—millions of feeds at scale.
Approach 2: P(X > 8) = 0%. Every feed has exactly 4 ads.
Part 3: Consecutive Ads and Clustering
Approach 1:
Define indicator I_i = 1 when positions i and i+1 are both ads, for i = 1, 2, ..., 99.
Since positions are independent: E[I_i] = 0.04² = 0.0016
By linearity of expectation:
E[consecutive pairs] = 99 × 0.0016 ≈ 0.158
Using Poisson approximation: P(at least one consecutive pair) ≈ 1 − e^(−0.158) ≈ 15%
Roughly 1 in 7 feeds shows back-to-back ads.
Longer runs: Expected runs of length 3: (100−2) × 0.04³ ≈ 0.0063. Runs of any length k > 1 are possible, with probability decaying exponentially as 0.04^k. The maximum run length is unbounded in theory.
Approach 2:
The answer depends on the placement strategy within each group:
-
Fixed position (e.g., every 25th slot): Ads are spaced exactly 25 positions apart. Expected consecutive pairs = 0. Maximum run length = 1.
-
Random position within each group: Consecutive ads can only occur at group boundaries (positions 25-26, 50-51, 75-76). The probability of adjacency at each boundary is (1/25)² = 0.0016. With 3 boundaries:
- E[consecutive pairs] = 3 × 0.0016 = 0.0048 (about 30× lower than Approach 1)
- Maximum run length = 2 (impossible to have 3+ consecutive ads, as that would require two ads in the same group)
Summary Comparison
| Metric | Approach 1 (Probabilistic) | Approach 2 (Quota) |
|---|---|---|
| Mean ads | 4 | 4 |
| Variance | 3.84 | 0 |
| P(X > 8) | ≈1.9% | 0% |
| E[consecutive pairs] | 0.158 | 0 to 0.0048 |
| Max run length | Unbounded | 1 or 2 |
Product Implications
Approach 1 drawbacks:
- High variance creates inconsistent user experience—some see no ads, others see 8+
- Clustering: back-to-back ads are disproportionately disruptive and can increase skip rates or churn
- Unpredictable revenue per feed
Approach 1 advantages:
- Stateless and simple to implement
- Less predictable placement reduces "banner blindness"
Approach 2 advantages:
- Consistent ad delivery guarantees stable revenue
- Near-zero clustering (especially with random positioning) improves user experience
- Bounded worst-case ad density
Approach 2 drawbacks:
- Fixed positions are predictable and may be ignored
- Requires tracking position within groups (slight implementation complexity)
Recommendation: Approach 2 with random positioning within groups combines the best of both worlds—deterministic count, minimal clustering, and less predictable placement. Most production ad systems enforce minimum separation between ads for exactly this reason.
Common Pitfalls
- Concluding the approaches are equivalent because means match (ignoring variance and structure)
- Assigning nonzero variance to Approach 2
- Writing E[pairs] as 100p² instead of 99p² (off-by-one error on the number of adjacent positions)
- Believing you need independence between pair indicators to use linearity of expectation (you don't)
- Not acknowledging that normal approximation fails for small np
- Failing to state assumptions about Approach 2's placement rule (fixed vs. random positioning within groups)