Mean Uncertainty vs. Tail Threshold for Per-User Comment Counts
Statistics & ExperimentsModel answerLast updated
Estimate a 95% interval for average comments per user, explain how sample size shrinks the mean's variance, and compute and interpret the 95th percentile of the counts.
Scenario
A platform's trust and safety team wants to separate ordinary users from suspected fake accounts using how often each user comments. You have a random sample of n users, and for each one you know the number of comments they posted in a fixed period.
Questions
- How would you build a 95% confidence interval for the population mean number of comments per user? State the assumptions you rely on and which critical value you use.
- What is the sampling distribution of the sample mean? How does the sample size
naffect its variance, and what does that imply for the width of your interval? - How do you compute and interpret the 95th percentile of the comment counts? How does that quantity differ from the confidence interval in part 1, and how would you use it in the fake-account setting?
What a strong answer covers
- Assumptions, and what happens when they fail (skew, outliers, dependence between users)
- Formulas, with a short numerical example
- A correct interpretation of a confidence interval
- Alternatives when the normal approximation is doubtful
- Uncertainty in the percentile estimate itself
Hints
Hint 1
Separate two ideas: uncertainty about the average user (the standard error of the mean) and the spread of individual users (the standard deviation and quantiles of the data).
Hint 2
The variance of the sample mean is sigma squared over n, so the standard error shrinks like 1 over the square root of n. Use the Central Limit Theorem to justify normality of the mean even though the counts themselves are skewed, and swap sigma for the sample standard deviation with a t critical value.
Hint 3
A percentile is an order statistic: sort the counts and pick the rank (or interpolate). It does not narrow with more data the way the CI for the mean does, and it has its own sampling error that you can bound with a bootstrap or binomial rank argument.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The question has three parts that are easy to blur together:
- A confidence interval (CI) for the mean expresses uncertainty about the average user.
- The sampling distribution of the mean explains why that interval narrows as
ngrows. - A percentile describes where individual users sit in the tail.
Keeping "uncertainty about the mean" separate from "spread of the data" is the core of a good answer.
Step 1: Setup and assumptions
Let X₁, …, Xₙ be per-user comment counts. Assume:
- Independence. Users are drawn independently (for example, simple random sampling of user IDs). Coordinated bot rings or multiple rows per user break this.
- Identical distribution with mean μ and finite variance σ². Comment counts are bounded in practice, so variance is finite, though heavy tails slow convergence.
Sample statistics:
- Mean: x̄ = (1/n) Σ Xᵢ
- Standard deviation: s = √[Σ (Xᵢ − x̄)² / (n − 1)], using Bessel's correction so s² is unbiased for σ².
Step 2: Sampling distribution of the mean
- E[x̄] = μ (unbiased).
- Var(x̄) = σ²/n, since the variance of a sum of independent terms adds, and dividing by n scales it by 1/n².
- SE(x̄) = σ/√n.
By the Central Limit Theorem, for large n, x̄ ≈ N(μ, σ²/n), even though individual counts are zero-inflated and right-skewed.
Effect of n:
- Variance falls as 1/n; standard error falls as 1/√n.
- Quadrupling n halves the SE and the CI width. Doubling n only shrinks the width by √2.
- For a target margin of error E, n ≈ (z·σ/E)².
ndoes not change the spread of the underlying counts; it only reduces uncertainty about their mean.
Step 3: The 95% confidence interval
Since σ is unknown, plug in s:
x̄ ± t₀.₉₇₅,ₙ₋₁ · s/√n
For large n (roughly above 100), t ≈ z = 1.96.
Worked example: n = 400, x̄ = 12, s = 30.
- SE = 30/√400 = 1.5
- Margin = 1.96 × 1.5 ≈ 2.94
- CI ≈ (9.06, 14.94)
Interpretation. If we repeated the sampling procedure many times, about 95% of intervals built this way would contain the fixed true mean μ. It is wrong to say "there is a 95% probability μ lies in (9.06, 14.94)", and wrong to read the interval as the range containing 95% of users.
When the normal approximation is shaky (small n, or extreme skew with s ≫ x̄):
- Bootstrap: resample with replacement about 10,000 times, compute the mean each time, and take the 2.5th and 97.5th percentiles. Use BCa for skewed data.
- Log transform: build the CI on log(1 + X) and back-transform, noting it targets a geometric-type mean rather than the arithmetic mean.
- Robust center: report the median with a bootstrap CI alongside the mean, since a few bots can pull the mean up sharply.
Step 4: The 95th percentile
Q₀.₉₅ is the value q with P(X ≤ q) ≥ 0.95: 95% of users post q comments or fewer.
Computation:
- Sort the counts.
- Pick a definition and state it:
- Nearest rank: the k-th smallest with k = ⌈0.95n⌉. For n = 400, k = 380.
- Linear interpolation (NumPy default): position h = 0.95(n − 1) = 379.05 (0-indexed), so Q = x[379] + 0.05·(x[380] − x[379]).
- Counts are discrete with many ties, so definitions often agree.
Uncertainty in the percentile. It is also an estimate. Options:
- Bootstrap the percentile.
- Use order statistics: the number of observations below Q₀.₉₅ is Binomial(n, 0.95), giving rank bounds of about 0.95n ± 1.96·√(n·0.95·0.05). For n = 400 that is 380 ± 8.5, so roughly the 371st to 389th order statistics.
Use in the fake-account setting:
- Q₀.₉₅ is a natural screening threshold for review: users above it are the top 5% most active commenters.
- Being in the top 5% is not proof of being fake. Power users, creators, and moderators land there too.
- Combine it with other signals (account age, comment velocity, duplicated text, network structure) and compute thresholds within segments such as country or account age so whole cohorts are not flagged.
Contrasting the two quantities
| Quantity | Describes | As n grows |
|---|---|---|
| 95% CI for μ: x̄ ± 1.96·s/√n | Uncertainty about the average user | Shrinks toward 0 |
| Q₀.₉₅ | Where 95% of individual users fall | Converges to a fixed true quantile |
In the example, the CI for the mean is about 9 to 15, while the 95th percentile could easily be 60 or higher.
Common mistakes
- Stating the wrong probabilistic meaning of the CI, or treating it as a range covering 95% of users.
- Applying a z-interval blindly to small, heavy-tailed samples instead of using a bootstrap or robust statistics.
- Confusing σ (spread of users) with σ/√n (spread of the sample mean).
- Assuming doubling n halves the width; it only divides it by √2.
- Violating independence: several rows per user, sampling comments instead of users (which oversamples heavy commenters), or clusters of coordinated bots. These understate the true SE. Aggregate to one row per user or use cluster-robust errors.
- A contaminated baseline: fake accounts in the sample inflate both the mean and the percentile. Estimate the baseline on a verified-genuine cohort where possible.
- Reporting the sample percentile as if exact, without an interval.
Quick code sketch
import numpy as np
from scipy import stats
x = np.asarray(counts)
n = len(x)
xbar, s = x.mean(), x.std(ddof=1)
t = stats.t.ppf(0.975, n - 1)
ci = (xbar - t * s / np.sqrt(n), xbar + t * s / np.sqrt(n))
q95 = np.percentile(x, 95) # linear interpolation
rng = np.random.default_rng(0)
boot = [np.percentile(rng.choice(x, n), 95) for _ in range(10_000)]
q95_ci = np.percentile(boot, [2.5, 97.5])
Complexity is O(n log n) for the sort-based percentile and O(B·n) for the bootstrap with B resamples.