← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Google DS interview with a pretty gnarly statistics question about estimating rare query counts from sampled search logs. The whole thing was one multi-part problem that went deep fast.

Questions Asked (4)

Q1

You have a daily search query log and draw a 10% random sample. If you count queries that appear exactly once in the sample and multiply by 10 to estimate the number of singletons in the full log, is that estimate biased? Which direction, and why?

Product Analytics & MetricsA/B Testing & Experimentation
Author's notes

This part felt approachable at first and then I second-guessed myself halfway through.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the estimate is biased because the sample is drawn without replacement, so the probability of a query being a singleton in the sample depends on its true frequency. Then, derive the expected count of sample singletons and compare it to the true number of singletons, showing that the multiplier 10 overestimates the true count.

Pro tip: Mention that the bias arises because queries with true frequency 1 can only appear once in the sample, while queries with higher frequencies can also appear once by chance, inflating the sample singleton count. This demonstrates a deeper understanding of sampling without replacement.

1. Define the problem

Restate the question: We draw a 10% simple random sample without replacement from a daily query log. We count queries that appear exactly once in the sample and multiply by 10 to estimate the number of singletons in the full log. Is this estimate biased?

2. Identify the source of bias

Recognize that the sample is drawn without replacement, so the probability of a query appearing exactly once in the sample depends on its true frequency in the full log. Queries with true frequency >1 can also appear exactly once in the sample, contributing to the sample singleton count.

3. Derive expected sample singletons

Let N be the total number of queries in the full log, and let f_i be the frequency of query i. The expected number of sample singletons is sum over i of P(query i appears exactly once in sample). For a query with frequency f, this probability is f * 0.1 * (0.9)^{f-1} (since we choose one of its f occurrences to be in the sample and the other f-1 occurrences to be out).

4. Compare to true singletons

The true number of singletons is the count of queries with f=1. The expected sample singleton count includes contributions from queries with f>1. Since f * 0.1 * (0.9)^{f-1} > 0.1 for f>1 (because (0.9)^{f-1} > 0.1 for f up to 22, and even for larger f it's positive), the expected sample singleton count is greater than 0.1 times the true singleton count. Thus, multiplying by 10 overestimates the true number of singletons.

5. Conclude direction and magnitude

The estimate is biased upward. The bias is larger when there are many queries with moderate frequencies (e.g., 2-10) that can appear once in the sample. In the extreme, if all queries had frequency 2, the sample singleton count would be about 2*0.1*0.9*N/2 = 0.09N, and multiplying by 10 gives 0.9N, while true singletons are 0, so huge overestimate.

Key Points to Mention

  • Sampling without replacement vs with replacement
  • Probability of a query appearing exactly once in the sample depends on its true frequency
  • Expected sample singleton count formula: sum f * p * (1-p)^{f-1} with p=0.1
  • Queries with frequency >1 contribute to sample singletons, inflating the count
  • The multiplier 10 assumes each sample singleton represents 10 true singletons, but that's not valid
  • Bias is upward (overestimation) and can be substantial

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Using a frequency-of-frequencies framework, derive a better estimator for the true number of singleton queries. How do sampled frequency counts relate to population counts under binomial sampling, and what kind of estimator (Good-Turing style or similar) would you propose?

Product Analytics & MetricsAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things got uncomfortable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the frequency-of-frequencies framework: let f_k be the number of queries observed exactly k times in the sample. Under binomial sampling, the expected sample frequency for a population frequency x is E[f_k] = sum_x N_x * Bin(k; n, x/N). To estimate the true number of singletons (N_1), use a Good-Turing-style estimator that adjusts for the probability of unseen species, such as N_1_hat = f_1 * (1 - (1 - 1/n)^n)^{-1} or more generally N_1_hat = f_1 / (1 - (1 - 1/n)^n).

Pro tip: Emphasize that the naive estimator f_1 underestimates true singletons because some singletons are missed in the sample; the correction factor accounts for the probability that a singleton is observed at least once. Also, mention that this is analogous to the Good-Turing frequency estimation for species richness.

1. Define the problem and notation

Let N be the total number of unique queries in the population, and N_x be the number of queries with population frequency x. In a sample of size n, let f_k be the number of queries observed exactly k times. We want to estimate N_1, the true number of singleton queries.

2. Relate sample and population via binomial sampling

For a query with population frequency x, the probability of being observed k times in the sample is Bin(k; n, x/N). Thus, the expected frequency-of-frequencies is E[f_k] = sum_x N_x * Bin(k; n, x/N). This relationship allows us to express E[f_1] in terms of N_1 and other N_x.

3. Derive the estimator for N_1

Assuming that queries with frequency >1 contribute negligibly to f_1 (or approximating), we have E[f_1] ≈ N_1 * n * (1/N) * (1 - 1/N)^{n-1} ≈ N_1 * (n/N) * exp(-n/N). For large N and n, this simplifies to E[f_1] ≈ N_1 * (n/N) * e^{-n/N}. Solving for N_1 gives N_1 ≈ f_1 * (N/n) * e^{n/N}. However, a more robust estimator uses the probability that a singleton is observed at least once: P(observed) = 1 - (1 - 1/N)^n ≈ 1 - e^{-n/N}. Thus, N_1_hat = f_1 / (1 - e^{-n/N}). For unknown N, we can estimate N by the total number of distinct queries observed, or use a Good-Turing style approach.

4. Propose a Good-Turing style estimator

A practical estimator is N_1_hat = f_1 * (1 - (1 - 1/n)^n)^{-1}, which corrects for the probability that a singleton is missed. This is derived from the Good-Turing frequency estimation, where the adjusted count for singletons is (f_1 + 1) * (f_1 / (f_1 + 1))? Actually, the standard Good-Turing estimate for the number of singletons is N_1_hat = f_1 * (1 + (f_2 / f_1))? No, that's for the probability of unseen. For the number of singletons, the Good-Turing estimator is N_1_hat = f_1 * (1 - (1 - 1/n)^n)^{-1} under the assumption of a Poisson model. Alternatively, use the Chao estimator: N_1_hat = f_1 + f_1^2/(2 f_2) for species richness, but that estimates total species, not singletons. For singletons specifically, the estimator N_1_hat = f_1 / (1 - (1 - 1/n)^n) is appropriate.

5. Discuss assumptions and limitations

Mention that the estimator assumes random sampling and that the population is large. It may be biased if the sample size is small or if there is heterogeneity in query frequencies. Also, note that the estimator can be unstable if f_1 is small. Suggest using smoothing or Bayesian methods for robustness.

Key Points to Mention

  • Frequency-of-frequencies framework: f_k counts queries observed k times.
  • Binomial sampling model: each query independently included with probability n/N.
  • Naive estimator f_1 underestimates true singletons due to unseen singletons.
  • Good-Turing style correction: N_1_hat = f_1 / (1 - (1 - 1/n)^n) or similar.
  • Assumptions: random sampling, large population, homogeneity.
  • Alternative estimators: Chao estimator for species richness, but focus on singletons.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you compute standard errors for your singleton estimator, and how would you check whether your model assumptions are actually holding given that query frequencies are likely heavy-tailed?

A/B Testing & ExperimentationTechnical Trade-offsRoot Cause Analysis
Author's notes

Talked through the delta method and bootstrapping.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining robust methods for standard error estimation that account for heavy-tailed query frequencies, such as bootstrap or sandwich estimators. Then, describe diagnostic checks for model assumptions, including residual analysis and sensitivity tests. Emphasize the importance of validating assumptions in the context of A/B testing at Google.

Pro tip: Mention that heavy-tailed distributions often violate normality assumptions, so non-parametric methods like the bootstrap are safer. Also, highlight that checking assumptions is an iterative process and should be done before trusting any p-values.

1. Identify the estimator and its assumptions

Clarify what the singleton estimator is and list its key assumptions, such as independence, identical distribution, and finite variance. Note that heavy-tailed query frequencies may violate these.

2. Choose robust SE methods

Consider bootstrap (non-parametric or block), sandwich/Huber-White estimators, or quantile-based methods that do not rely on normality. Discuss trade-offs like computational cost and asymptotic validity.

3. Diagnose heavy-tailedness and model fit

Use QQ-plots, histograms, and tail index estimation (e.g., Hill estimator) to assess heavy tails. Check residuals for patterns and conduct goodness-of-fit tests.

4. Validate assumptions via simulation or sensitivity analysis

Simulate data under the assumed model and compare SE estimates. Perform sensitivity analysis by perturbing assumptions (e.g., adding outliers) to see impact on SEs.

5. Communicate findings and limitations

Summarize which assumptions hold, which are violated, and how that affects inference. Recommend robust alternatives or caveats for decision-making.

Key Points to Mention

  • Bootstrap methods (non-parametric, block bootstrap) for heavy-tailed data
  • Sandwich estimators (Huber-White) for heteroskedasticity-robust standard errors
  • Diagnostic plots: QQ-plots, residual plots, tail index estimation
  • Sensitivity analysis and simulation to test assumption robustness
  • Trade-offs between computational cost and accuracy
  • Implications for A/B testing: inflated false positives if assumptions violated

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Walk through a simulation plan to compare different singleton estimators under realistic search traffic distributions.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

Felt like the coolest part of the problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the goal: comparing singleton estimators (e.g., sample mean, trimmed mean, median) for metrics like average revenue per user under realistic search traffic distributions (e.g., heavy-tailed, zero-inflated). Then outline a simulation plan that generates synthetic traffic from a known distribution, applies each estimator, and evaluates bias, variance, and coverage across repeated samples. Emphasize how the plan accounts for Google-scale traffic patterns such as query heterogeneity and temporal spikes.

Pro tip: Ground your simulation in real Google search traffic characteristics—like power-law query frequencies and diurnal patterns—and discuss how estimator performance might vary across different traffic segments (e.g., head vs. tail queries). This shows you understand production nuances beyond textbook distributions.

1. Define Estimators and Metrics

Select the singleton estimators to compare (e.g., mean, median, trimmed mean, Winsorized mean) and the target metric (e.g., mean revenue per query). Specify evaluation criteria: bias, variance, MSE, and confidence interval coverage.

2. Model Realistic Traffic Distributions

Choose distributions that mimic search traffic: heavy-tailed (Pareto, log-normal), zero-inflated, and mixture models to represent head/tail queries. Incorporate temporal patterns (e.g., daily seasonality) and segment-specific parameters.

3. Design Simulation Experiment

Set sample sizes (e.g., 1k, 10k, 100k), number of replications (e.g., 10,000), and random seeds. For each replication, draw a sample from the traffic distribution, compute each estimator, and record its value and confidence interval.

4. Evaluate and Compare Performance

Aggregate results across replications to compute bias, variance, MSE, and coverage. Visualize with boxplots or heatmaps across sample sizes and distribution parameters. Identify which estimator is most robust under heavy tails.

5. Interpret and Recommend

Discuss trade-offs: e.g., mean is unbiased but high variance; median is robust but may be biased for skewed metrics. Recommend an estimator based on the metric's importance and traffic characteristics, and suggest validation with real A/B test data.

Key Points to Mention

  • Heavy-tailed and zero-inflated distributions typical of search traffic (e.g., revenue per query).
  • Bias-variance trade-off and MSE as evaluation metrics.
  • Confidence interval coverage as a measure of reliability.
  • Sample size and number of replications for stable estimates.
  • Temporal dynamics (e.g., diurnal patterns) and segment heterogeneity (head vs. tail queries).
  • Practical considerations: computational cost, implementation complexity, and sensitivity to outliers.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.