← Openai Interview Insights

Openai·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

A/B testing code debug question for an OpenAI SWE role. The prompt gives you broken Python and asks you to find what's wrong, which sounds manageable until you realize how many subtle statistical traps are buried in there.

Questions Asked (4)

Q1

You're given a Python function that runs an A/B test on a user-level DataFrame. Find at least three bugs or statistical pitfalls and explain why each one matters.

A/B Testing & ExperimentationProduct Analytics & MetricsTechnical Trade-offs
Author's notes

The code looks innocent at first glance but there's a lot going on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by scanning the code for common A/B testing pitfalls, such as randomization issues, metric calculation errors, and statistical assumption violations. Then, for each bug, explain its impact on the validity of the experiment and suggest a fix. Prioritize bugs that could lead to false positives or negatives.

Pro tip: Demonstrate statistical rigor by not only identifying bugs but also quantifying their potential impact (e.g., inflated Type I error rate, biased effect size). This shows you understand both code and experimentation.

1. Check randomization and assignment

Verify that users are randomly assigned to control and treatment groups, and that the assignment is independent of user characteristics. Look for issues like non-random assignment, unequal group sizes, or leakage between groups.

2. Inspect metric calculation

Ensure the metric (e.g., conversion rate) is computed correctly, with proper numerator and denominator. Check for issues like including users who didn't trigger the metric, double-counting, or incorrect aggregation.

3. Validate statistical tests

Confirm that the statistical test used is appropriate for the metric and data distribution. Look for violations of assumptions (e.g., normality, independence) and incorrect application (e.g., using a t-test on binary data without proper adjustment).

4. Examine data quality and preprocessing

Check for missing data, outliers, or filtering that could bias results. Ensure that data cleaning steps are applied consistently across groups and don't introduce bias.

5. Consider multiple testing and peeking

Look for multiple comparisons without correction or early stopping (peeking) that inflates false positive rates. Ensure that the analysis plan accounts for these issues.

Key Points to Mention

  • Randomization unit vs. analysis unit mismatch (e.g., randomizing by user but analyzing by session)
  • Sample ratio mismatch (SRM) indicating assignment bias
  • Incorrect handling of missing data or non-triggered users
  • Violations of independence (e.g., network effects, repeated measures)
  • Multiple comparisons and alpha inflation
  • Peeking and sequential testing without proper adjustments

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

Q2

When would you use a t-test versus a proportion test versus bootstrap versus a non-parametric test for analyzing an A/B experiment?

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

I had a decent answer for this but fumbled the zero-inflated case a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around the nature of the metric (continuous vs. binary), sample size, and distributional assumptions. Explain when each method is appropriate, emphasizing trade-offs between simplicity, robustness, and computational cost. Use concrete examples from A/B testing to illustrate.

Pro tip: Mention that in practice, for large-scale A/B tests, the t-test and proportion test often yield similar results due to the Central Limit Theorem, but the choice matters for small samples or skewed data. Also, highlight that bootstrap is powerful for complex metrics but requires careful implementation to avoid bias.

1. Identify the metric type

Determine whether the metric is continuous (e.g., revenue, time spent) or binary (e.g., conversion rate, click-through rate). This guides the choice between t-test and proportion test.

2. Check assumptions and sample size

Assess normality, variance homogeneity, and sample size. For large samples, parametric tests are robust; for small samples or non-normal data, consider non-parametric or bootstrap methods.

3. Consider the trade-offs

Weigh simplicity and interpretability (t-test, proportion test) against flexibility and robustness (bootstrap, non-parametric). Bootstrap handles complex metrics but is computationally intensive.

4. Match method to scenario

Provide specific scenarios: t-test for continuous metrics with normal-ish data; proportion test for binary metrics; bootstrap for skewed or complex metrics; non-parametric for ordinal or non-normal data with small samples.

5. Summarize with a decision rule

Conclude with a concise decision tree or rule of thumb, emphasizing that the choice depends on metric type, sample size, and distributional assumptions.

Key Points to Mention

  • T-test: continuous metrics, assumes normality or large sample, compares means.
  • Proportion test: binary metrics, compares conversion rates, uses z-test for proportions.
  • Bootstrap: resampling method, no distributional assumptions, works for complex metrics (e.g., median, ratio), but computationally expensive.
  • Non-parametric tests (e.g., Mann-Whitney U): ordinal or non-normal data, small samples, compares distributions.
  • Central Limit Theorem: with large samples, parametric tests are robust even for non-normal data.
  • Trade-offs: parametric tests are more powerful if assumptions hold; non-parametric and bootstrap are more robust but less powerful.

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

Q3

How would you handle missing values in the metric column before running statistical tests on an A/B experiment?

A/B Testing & ExperimentationRoot Cause Analysis
Author's notes

Shorter answer than the others.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by diagnosing why values are missing—whether it's random or systematic—because that determines the appropriate handling method. Then choose a strategy that preserves statistical validity, such as deletion, imputation, or model-based approaches, and always validate the impact on your test results.

Pro tip: Always check if missingness itself is a metric—if the missing rate differs between control and treatment, that's a signal worth investigating before you impute. Document your missing data handling and run sensitivity analyses to ensure your conclusions are robust.

1. Diagnose Missingness

Determine the mechanism (MCAR, MAR, MNAR) and quantify the missing rate per group. Check if missingness correlates with treatment assignment or other variables.

2. Choose Handling Strategy

Select an approach based on the diagnosis: listwise deletion for MCAR with low missingness, imputation (mean/median, regression, multiple imputation) for MAR, or model-based methods for MNAR.

3. Implement and Validate

Apply the chosen method, ensuring it's done consistently across groups. Validate by comparing distributions before and after, and check for introduced bias.

4. Run Statistical Tests

Perform the planned tests (e.g., t-test, Mann-Whitney) on the handled data. Consider using methods robust to missing data, like mixed models or bootstrap.

5. Sensitivity Analysis

Repeat the analysis with alternative missing data strategies to assess robustness. Report how conclusions change under different assumptions.

Key Points to Mention

  • Missing data mechanisms: MCAR, MAR, MNAR and their implications
  • Impact of missing data on statistical power and bias
  • Imputation techniques: mean/median, regression, multiple imputation, and their assumptions
  • Deletion methods: listwise vs. pairwise and when they are appropriate
  • Sensitivity analysis to test robustness of results
  • Tools/libraries for handling missing data (e.g., pandas, scikit-learn, R's mice)

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

Q4

What is a sample ratio mismatch (SRM) and how would you detect and handle it in an A/B test?

A/B Testing & ExperimentationRoot Cause Analysis
Author's notes

SRM check is basically just a chi-squared test on the observed variant split vs the expected split.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Define SRM as a statistically significant deviation between the observed and expected sample sizes in each variant of an A/B test. Explain that it indicates a flaw in the randomization or data collection process, and then outline a systematic approach to detect, diagnose, and handle it.

Pro tip: Emphasize that SRM is a validity threat, not just a metric anomaly—if detected, you should immediately halt the experiment and investigate before trusting any results. Also, mention that prevention is better than cure: implement automated SRM checks in your experimentation platform.

1. Define SRM and its implications

Explain that SRM occurs when the actual ratio of users in each variant significantly differs from the intended ratio (e.g., 50/50). It suggests a bug in assignment, logging, or filtering, and invalidates the test results.

2. Detect SRM using statistical tests

Use a chi-squared goodness-of-fit test or a binomial test to compare observed vs. expected counts. Set a significance threshold (e.g., p < 0.001) and monitor continuously or at the end of the test.

3. Investigate potential causes

If SRM is detected, check for issues in randomization (e.g., biased hash function), data pipeline (e.g., logging errors), or user segmentation (e.g., bot traffic, uneven exposure).

4. Handle SRM appropriately

If SRM is confirmed, stop the experiment, fix the root cause, and rerun the test. If the cause is benign (e.g., known bot filtering), consider adjusting the analysis or excluding affected data.

5. Prevent future SRM

Implement automated SRM checks in your experimentation platform, use robust randomization methods, and regularly audit data pipelines to catch issues early.

Key Points to Mention

  • SRM is a mismatch between expected and observed sample sizes across variants.
  • It indicates a flaw in randomization, data collection, or filtering, making results unreliable.
  • Detection: chi-squared test, binomial test, or sequential monitoring with a strict p-value threshold.
  • Common causes: biased assignment algorithm, logging errors, bot traffic, uneven user segmentation.
  • Handling: stop the experiment, investigate root cause, fix, and rerun; do not trust results if SRM is present.
  • Prevention: automated checks, robust randomization, and data pipeline audits.

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