← Amazon Interview Insights

Amazon·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Amazon DS interview that went deep into experimentation stats, way deeper than I expected. The whole session was basically one long A/B testing case with five parts, and I was not prepared for how much math they wanted on the spot.

Questions Asked (5)

Q1

For a two-arm randomized test comparing spam rates of 2.0% vs 1.8%, derive the per-arm sample size needed at alpha=0.05 and 80% power using a two-sided z-test on proportions. State your assumptions about pooled vs unequal variance.

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

I fumbled the pooled variance part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the test setup: two-sided z-test for proportions at alpha=0.05 and 80% power. Then, compute the required per-arm sample size using the standard formula, explicitly stating whether you assume equal variances (pooled) or unequal variances (unpooled), and show the calculation with the given rates.

Pro tip: Mention that in practice, you'd use a power analysis tool or simulation to account for continuity corrections and exact tests, but the z-test approximation is a good starting point. Also, note that Amazon often deals with large-scale tests, so even small differences like 0.2% can be practically significant if the sample size is large enough.

1. Define the hypotheses and parameters

State the null and alternative hypotheses: H0: p1 = p2 vs H1: p1 ≠ p2. Set alpha=0.05 (two-sided) and power=0.80, so beta=0.20. Let p1=0.02 and p2=0.018.

2. Choose the variance assumption

Decide whether to assume equal variances (pooled) or unequal variances (unpooled). For sample size calculation, the unpooled approach is common because it directly uses the alternative proportions, but some prefer pooled for a conservative estimate.

3. Apply the sample size formula

Use the formula for two proportions: n = ( (z_{1-alpha/2} * sqrt(2 * p_bar * (1-p_bar)) + z_{1-beta} * sqrt(p1*(1-p1) + p2*(1-p2)) )^2 ) / (p1 - p2)^2, where p_bar = (p1+p2)/2 if pooled, or use unpooled version. Plug in z-values: z_{0.975}=1.96, z_{0.80}=0.84.

4. Compute and round up

Calculate the numerical value. With p1=0.02, p2=0.018, the difference is 0.002. Using unpooled: p1(1-p1)=0.0196, p2(1-p2)=0.017676, sum=0.037276, sqrt=0.19307. p_bar=0.019, 2*p_bar*(1-p_bar)=2*0.019*0.981=0.037278, sqrt=0.19308. Then n = ( (1.96*0.19308 + 0.84*0.19307)^2 ) / (0.002)^2 = ( (0.37844 + 0.16218)^2 ) / 0.000004 = (0.54062^2)/0.000004 = 0.29227/0.000004 = 73067.5 per arm. Round up to 73068 per arm.

5. Interpret and discuss assumptions

State that approximately 73,068 users per arm are needed. Discuss that this assumes no continuity correction, large sample normality, and that the test is two-sided. Mention that if using pooled variance, the sample size might be slightly different (e.g., pooled p_bar=0.019 gives similar result).

Key Points to Mention

  • Two-sided z-test for proportions with alpha=0.05 and power=0.80.
  • Assumption of equal vs unequal variances: pooled vs unpooled. Typically unpooled is used for sample size calculation because it reflects the alternative hypothesis.
  • Formula for sample size: n = ( (z_{1-alpha/2} * sqrt(2 * p_bar * (1-p_bar)) + z_{1-beta} * sqrt(p1*(1-p1) + p2*(1-p2)) )^2 ) / (p1 - p2)^2.
  • Numerical calculation: z_{0.975}=1.96, z_{0.80}=0.84, p1=0.02, p2=0.018, resulting in ~73,068 per arm.
  • Practical considerations: continuity correction, exact tests, and that such large sample sizes are common in tech companies for detecting small effects.
  • Interpretation: The required sample size is large because the effect size (0.2 percentage points) is small relative to the baseline rate.

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

Q2

Given control=2.1% spam on 500k emails and treatment=1.85% on 500k, compute the 95% confidence interval for the absolute difference in proportions and the corresponding p-value.

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

This part I actually did okay on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, compute the sample proportions and their difference. Then calculate the standard error of the difference using the pooled proportion for the hypothesis test and the unpooled proportions for the confidence interval. Finally, construct the 95% confidence interval and compute the z-statistic and p-value for the two-proportion z-test.

Pro tip: Always clarify whether the confidence interval should be based on the unpooled or pooled standard error; for a confidence interval, use unpooled, but for the hypothesis test, use pooled. Also, mention that with such large sample sizes, the normal approximation is valid and the p-value will be extremely small, so you might report it as <0.0001.

1. Calculate sample proportions and difference

Compute the proportion of spam in control (p1 = 0.021) and treatment (p2 = 0.0185). The absolute difference is p1 - p2 = 0.0025 (or 0.25 percentage points).

2. Compute standard error for the confidence interval

Use the unpooled standard error formula: SE = sqrt( p1*(1-p1)/n1 + p2*(1-p2)/n2 ). With n1 = n2 = 500,000, calculate SE ≈ sqrt(0.021*0.979/500000 + 0.0185*0.9815/500000) ≈ 0.000284.

3. Construct the 95% confidence interval

The 95% CI for the difference is (p1 - p2) ± 1.96 * SE. This yields 0.0025 ± 1.96*0.000284 ≈ (0.00194, 0.00306). So we are 95% confident the true difference is between 0.194 and 0.306 percentage points.

4. Compute the test statistic and p-value

For the hypothesis test, use the pooled proportion: p_pool = (x1 + x2)/(n1 + n2) = (10500 + 9250)/1,000,000 = 0.01975. Then SE_pooled = sqrt( p_pool*(1-p_pool)*(1/n1 + 1/n2) ) ≈ 0.000278. The z-statistic is (0.0025 - 0)/0.000278 ≈ 8.99. The two-sided p-value is approximately 2.4e-19, essentially 0.

5. Interpret the results

The confidence interval does not include zero, and the p-value is far below 0.05, indicating a statistically significant reduction in spam rate in the treatment group. The effect size is small (0.25 percentage points) but may be practically significant given the large volume.

Key Points to Mention

  • Use of unpooled standard error for confidence interval and pooled for hypothesis test.
  • Normal approximation validity due to large sample sizes (np and n(1-p) > 10).
  • Calculation of the pooled proportion for the z-test.
  • Interpretation of the confidence interval in terms of percentage points.
  • The p-value is extremely small, so report as <0.0001 or in scientific notation.
  • Consideration of practical significance vs statistical significance given the large sample size.

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

Q3

How do class imbalance drift and traffic seasonality threaten the validity of a spam classifier experiment, and how would you use stratification or blocking to address them?

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

Seasonality I had a decent answer for, stratify by day-of-week or time window and randomize within strata.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining class imbalance drift and traffic seasonality as threats to internal and external validity, then explain how stratification ensures representative train/test splits and blocking controls for temporal confounds. Finally, discuss practical implementation in an A/B testing framework, emphasizing trade-offs between bias reduction and variance.

Pro tip: Frame your answer around Amazon's leadership principles, such as 'Customer Obsession' (ensuring the classifier works for all customers) and 'Dive Deep' (understanding data drift). Mention that you would monitor drift post-deployment and set up alerts, showing proactive ownership.

1. Define the threats

Explain how class imbalance drift (changing spam-to-ham ratio over time) and traffic seasonality (e.g., holiday spikes) can cause the classifier to learn spurious patterns and fail to generalize, threatening both internal and external validity.

2. Explain stratification

Describe how stratification by class and time (e.g., stratified sampling by week) ensures that training, validation, and test sets have similar class distributions and temporal coverage, reducing bias in performance estimates.

3. Explain blocking

Discuss how blocking (e.g., grouping by time periods or user segments) can control for seasonality by comparing treatments within homogeneous blocks, isolating the treatment effect from temporal confounds.

4. Combine and implement

Propose a combined approach: use stratified blocking in experiment design, then validate with time-based cross-validation. Mention tools like scikit-learn's StratifiedKFold and time series split.

5. Monitor and adapt

Emphasize the need for continuous monitoring of class balance and traffic patterns post-deployment, with automated alerts and retraining triggers to maintain validity.

Key Points to Mention

  • Internal validity: ensuring the experiment measures the true effect without confounding from drift or seasonality.
  • External validity: ensuring results generalize to future time periods and different traffic conditions.
  • Stratified sampling: maintaining class proportions in train/test splits to avoid biased performance metrics.
  • Blocking: grouping experimental units into homogeneous blocks (e.g., by day or user cohort) to reduce variance and control for seasonality.
  • Time-based cross-validation: using techniques like rolling window or expanding window to simulate real-world deployment.
  • Monitoring and drift detection: implementing statistical tests (e.g., KS test) to detect distribution shifts and trigger retraining.

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

Q4

If you peek at results daily and stop the experiment early whenever p<0.05, why does Type I error inflate, and what corrections would you apply?

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

Classic peeking problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Explain that peeking and stopping early inflates Type I error because each look is a hypothesis test, and multiple testing increases the chance of false positives. Then describe corrections like alpha spending functions (e.g., O'Brien-Fleming), group sequential designs, or always-valid p-values, and mention practical alternatives like fixed-horizon tests or Bayesian methods.

Pro tip: Emphasize that the inflation depends on the number and timing of peeks, and that corrections should be pre-specified to maintain validity. Also note that in practice, companies like Amazon often use sequential testing frameworks to allow continuous monitoring without inflating error rates.

1. Define the problem

Clarify that peeking and stopping early when p<0.05 is a form of optional stopping, which leads to multiple comparisons and inflates the family-wise error rate (FWER).

2. Explain the inflation mechanism

Describe how each peek is an additional test, and the probability of at least one false positive accumulates over looks, similar to the multiple comparisons problem.

3. Quantify the impact

Mention that with many peeks, Type I error can approach 1, and that the exact inflation depends on the number of peeks and correlation between test statistics.

4. Present corrections

Discuss group sequential designs with alpha spending (e.g., O'Brien-Fleming, Pocock), always-valid p-values, or Bayesian approaches that allow continuous monitoring without inflation.

5. Discuss trade-offs and practical considerations

Note that corrections may require larger sample sizes or reduce power, and that pre-specification of the analysis plan is crucial to avoid p-hacking.

Key Points to Mention

  • Multiple testing problem and family-wise error rate (FWER)
  • Optional stopping and its effect on Type I error
  • Alpha spending functions (e.g., O'Brien-Fleming, Pocock)
  • Group sequential designs and interim analyses
  • Always-valid p-values and sequential testing
  • Bayesian alternatives for continuous monitoring
  • Pre-registration of analysis plan to maintain validity

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

Q5

If precision at a fixed recall is a business-critical metric, how would you construct a confidence interval for it using the delta method versus bootstrapping, and when is each approach more appropriate?

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

Hardest part of the whole interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining precision at fixed recall as a ratio of two dependent sample means (TP/(TP+FP) at a threshold chosen to achieve the target recall), then explain how the delta method uses a first-order Taylor expansion to approximate the variance of this ratio, while bootstrapping resamples the data to empirically estimate the sampling distribution. Compare their assumptions, computational costs, and performance in small samples or with complex metrics, and conclude with when each is preferable in an A/B testing context at Amazon.

Pro tip: Emphasize that the delta method requires the threshold to be fixed (or the recall constraint to be handled carefully) and that bootstrapping must resample at the appropriate unit (e.g., user or session) to respect the data's dependence structure; this shows you understand practical pitfalls beyond textbook formulas.

1. Define the metric and its components

Express precision at fixed recall as a ratio of two sample means: precision = TP / (TP + FP) where the threshold is chosen so that recall = TP / (TP + FN) equals the target. Clarify that both numerator and denominator are functions of the same threshold and thus dependent.

2. Delta method construction

Use the delta method: compute the gradient of the ratio with respect to the means of TP, FP, and FN (or directly with respect to the confusion matrix counts), then apply the multivariate delta method to obtain an approximate variance and confidence interval. Mention that this requires estimates of the covariance matrix of the counts.

3. Bootstrap construction

Describe a bootstrap procedure: resample the data (e.g., users or sessions) with replacement, recompute the threshold to achieve the fixed recall on each resample, then compute precision. Repeat many times to get the empirical distribution, and form a percentile or BCa confidence interval.

4. Compare assumptions and performance

Contrast the delta method's reliance on asymptotic normality and correct variance estimation (which may fail with small samples or extreme probabilities) with bootstrapping's flexibility but higher computational cost and potential bias if the resampling unit is wrong.

5. Recommend when to use each

Conclude that the delta method is preferable for large samples, simple metrics, and when speed is critical (e.g., real-time monitoring), while bootstrapping is better for small samples, complex metrics, or when the asymptotic approximation is questionable. In A/B testing, consider using both for validation.

Key Points to Mention

  • Precision at fixed recall is a ratio metric; its variance depends on the covariance between true positives and false positives.
  • Delta method: first-order Taylor expansion, requires gradient and covariance matrix of counts, assumes asymptotic normality.
  • Bootstrapping: resample at the unit of randomization (e.g., user) to preserve dependence, recompute threshold on each resample, use percentile or BCa intervals.
  • Delta method is fast and works well for large samples; bootstrapping is more robust for small samples or non-normal distributions but computationally intensive.
  • In A/B testing, the unit of analysis and the fixed recall constraint must be handled consistently across control and treatment.
  • Consider using both methods for validation, especially when the metric is business-critical and decisions depend on the confidence interval.

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