← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
Jul 2026Remote

Summary

Google data scientist interview that went deep into a single stats/ML problem. The whole session was basically one extended question about a custom error metric, bootstrapping, and probability theory. More math-heavy than I expected for a DS role.

Questions Asked (4)

Q1

Given a CSV with country, actual revenue, and predicted revenue columns, implement a percentage RMSE metric defined as the square root of the mean squared relative error. Your implementation needs to handle zeros and negative values, support optional country-level weights, and be numerically stable.

Product Analytics & MetricsTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This tripped me up more than I wanted to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the metric definition and edge-case handling first, then implement a vectorized, numerically stable solution using NumPy/pandas. Discuss trade-offs between different zero/negative handling strategies and validate with unit tests.

Pro tip: Mention that percentage RMSE is not symmetric and can be dominated by small actuals; propose a weighted variant or log-based alternative if appropriate for the business context.

1. Clarify requirements and edge cases

Ask about the exact definition of relative error, how to handle zeros and negatives, and whether weights are per-country or per-row. Confirm if the metric should be scale-invariant or if a different normalization is preferred.

2. Choose a robust error formula

Decide on a denominator that avoids division by zero and handles negatives, such as max(|actual|, epsilon) or a symmetric denominator like (|actual| + |predicted|)/2. Explain the implications of each choice.

3. Implement vectorized computation

Use NumPy or pandas to compute relative errors, apply weights, and calculate the weighted mean squared error followed by the square root. Ensure numerical stability by using float64 and avoiding overflow/underflow.

4. Validate and test

Write unit tests for edge cases: zeros, negatives, missing weights, and extreme values. Compare against a naive implementation to ensure correctness.

5. Discuss trade-offs and alternatives

Explain when percentage RMSE is appropriate and its limitations (e.g., sensitivity to small actuals). Suggest alternatives like weighted MAPE, symmetric MAPE, or log-based RMSE if the business context requires.

Key Points to Mention

  • Definition of percentage RMSE: sqrt(mean((actual - predicted)/denominator)^2)
  • Handling zeros: use epsilon or a symmetric denominator to avoid division by zero
  • Handling negatives: use absolute values or a symmetric denominator to keep relative error meaningful
  • Weighted version: compute weighted mean squared relative error, then sqrt
  • Numerical stability: use float64, avoid squaring large numbers without scaling, consider log-space for extreme values
  • Validation: unit tests for edge cases and comparison with naive implementation

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

Q2

Implement a nonparametric bootstrap with resample size equal to n to get a 95% confidence interval for the pRMSE. Justify why you use n as the resample size, and explain when you'd prefer a stratified or cluster bootstrap instead.

A/B Testing & ExperimentationTechnical Trade-offsProduct Analytics & Metrics
Author's notes

The justification part is where I felt shaky.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the nonparametric bootstrap procedure: resample n observations with replacement from the original dataset, compute pRMSE for each resample, and take the 2.5th and 97.5th percentiles of the bootstrap distribution. Justify resample size n by appealing to the bootstrap principle that the empirical distribution approximates the population, so resampling n points mimics sampling from the population. Then discuss when stratified or cluster bootstrap is preferred, such as when data has strata or dependence structures.

Pro tip: Emphasize that the bootstrap distribution should be centered at the original estimate, and mention that for pRMSE (a ratio of RMSE to a baseline), the bootstrap automatically handles the ratio's sampling variability, but you might consider bias-corrected accelerated (BCa) intervals for better coverage.

1. Define pRMSE and the estimand

Clarify what pRMSE stands for (e.g., percent RMSE or ratio of RMSE to a benchmark) and state the target parameter you want a confidence interval for.

2. Describe the nonparametric bootstrap procedure

Explain that you repeatedly resample n observations with replacement from the original data, compute pRMSE for each resample, and use the percentiles of the resulting distribution to form a 95% CI.

3. Justify resample size n

Argue that using n preserves the original sample's variability and aligns with the bootstrap principle: the empirical distribution is a plug-in estimate of the population, so resampling n points mimics the original sampling process.

4. Explain when to use stratified or cluster bootstrap

Discuss that stratified bootstrap is used when the population consists of distinct subgroups (strata) and you want to preserve their proportions; cluster bootstrap is used when data are grouped (e.g., users within clusters) and observations within clusters are correlated.

5. Address practical considerations

Mention the number of bootstrap replicates (e.g., 10,000 for 95% CI), potential bias, and alternatives like BCa intervals for improved accuracy.

Key Points to Mention

  • Bootstrap principle: resampling with replacement from the empirical distribution approximates sampling from the population.
  • Resample size n ensures the bootstrap distribution reflects the original sample's variability.
  • Stratified bootstrap: used when strata exist and you want to maintain stratum proportions in each resample.
  • Cluster bootstrap: used when data have hierarchical or clustered structure (e.g., repeated measures per user) to account for within-cluster correlation.
  • Number of bootstrap replicates: typically 10,000 for a 95% CI to reduce Monte Carlo error.
  • Potential improvements: BCa intervals for bias correction and acceleration, especially for skewed statistics like pRMSE.

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

Q3

What is the exact probability that a single bootstrap resample, drawn with replacement from n observations, produces the exact same sample in the exact same order as the original? Give the formula in terms of n and explain why this probability is negligible in practice.

Algorithms & Data StructuresA/B Testing & Experimentation
Author's notes

Loved this question actually.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the bootstrap resample is an ordered sequence of n draws with replacement, so there are n^n possible sequences. Then, compute the probability that a specific sequence (the original) occurs by multiplying the probability of drawing each original observation in its original position, which is (1/n)^n. Finally, discuss why this probability is negligible for typical n, emphasizing that the bootstrap relies on distributional similarity rather than exact replication.

Pro tip: Mention that while the probability of exact replication is tiny, the bootstrap works because it approximates the sampling distribution of a statistic, not because it reproduces the original sample. This shows you understand the method's theoretical foundation.

1. Define the sample space

Recognize that each bootstrap resample is an ordered sequence of n independent draws from the original n observations, with replacement. Thus, there are n^n equally likely sequences.

2. Compute the probability of the exact original sequence

For the resample to match the original exactly, the first draw must be the first original observation (probability 1/n), the second draw must be the second original observation (probability 1/n), and so on. Multiply these probabilities to get (1/n)^n.

3. Explain why this is negligible

For large n, (1/n)^n decreases extremely rapidly. For example, n=10 gives 10^{-10}, and n=100 gives 10^{-200}. This is far smaller than typical significance levels, so exact replication is practically impossible.

4. Connect to the purpose of bootstrap

Emphasize that the bootstrap does not require exact replication; it approximates the sampling distribution of a statistic by resampling. The negligible probability highlights that each resample is a unique perturbation, which is essential for estimating variability.

Key Points to Mention

  • The probability is (1/n)^n, derived from n independent draws each with probability 1/n.
  • There are n^n possible ordered resamples, so the probability is also 1/(n^n).
  • For n=10, probability is 10^{-10}; for n=100, it's 10^{-200}, demonstrating rapid decay.
  • The bootstrap's validity does not depend on replicating the original sample; it relies on the empirical distribution.
  • Exact replication would provide no information about variability, so its impossibility is actually beneficial.
  • This calculation assumes ordered sampling; if order is ignored, the probability is different (multinomial), but the question specifies exact order.

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

Q4

What are the limitations of using bootstrapping to estimate uncertainty for this percentage RMSE metric, specifically around heavy-tailed distributions and cross-country dependence? What mitigations would you consider?

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

This felt like the 'wrap it up' question but it had real depth.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the percentage RMSE metric and the bootstrapping procedure, then systematically discuss the limitations posed by heavy-tailed distributions and cross-country dependence. For each limitation, propose concrete mitigations, and conclude by emphasizing the need to validate assumptions and consider trade-offs in a production setting.

Pro tip: Acknowledge that while bootstrapping is powerful, its validity hinges on exchangeability; for dependent data, consider block or cluster bootstrapping, and for heavy tails, robust transformations or alternative estimators like the median or trimmed mean can provide more stable uncertainty estimates.

1. Clarify the metric and bootstrapping setup

Define percentage RMSE and how bootstrapping is applied (e.g., resampling countries or observations). This sets the stage for discussing limitations.

2. Identify limitations from heavy-tailed distributions

Explain how heavy tails lead to unstable bootstrap estimates, high variance, and poor coverage of confidence intervals due to influential outliers.

3. Identify limitations from cross-country dependence

Discuss how dependence violates the i.i.d. assumption, causing bootstrap resampling to underestimate uncertainty and produce biased intervals.

4. Propose mitigations for heavy tails

Suggest robust transformations (e.g., log), trimmed means, or using alternative resampling methods like the m-out-of-n bootstrap or subsampling.

5. Propose mitigations for dependence

Recommend cluster/block bootstrapping, hierarchical models, or incorporating dependence structure via copulas or mixed-effects models.

Key Points to Mention

  • Heavy tails can cause bootstrap distributions to be multimodal or skewed, leading to unreliable confidence intervals.
  • Cross-country dependence violates the exchangeability assumption, making standard bootstrap inconsistent.
  • Block or cluster bootstrapping preserves dependence structure by resampling entire clusters (e.g., countries).
  • Robust statistics (e.g., median, trimmed mean) or transformations can reduce the impact of outliers.
  • Alternative methods like the m-out-of-n bootstrap or subsampling can provide better coverage for heavy-tailed data.
  • Consider model-based approaches (e.g., Bayesian hierarchical models) to explicitly account for dependence and heavy tails.

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