I knew the formula conceptually but blanked on which z-values to pull for alpha and power.
Start by clarifying the inputs and assumptions: historical observations provide an estimate of variance, and the function should compute sample size using the standard formula for a two-sided two-sample z-test. Derive the formula step-by-step, then implement it efficiently, handling edge cases like zero variance or invalid parameters.
Pro tip: Mention that in practice, you'd use the pooled variance from historical data but also consider using a t-test for small samples; however, for large-scale A/B tests at Roblox, the z-test approximation is standard. Also, always round up to ensure sufficient power.
Confirm that historical observations are used to estimate the variance (or standard deviation) of the metric, and that the test is two-sided with equal group sizes. Assume normality or large sample sizes for the z-test.
Use the formula for two-sample z-test: n = ( (z_{1-α/2} + z_{1-β})^2 * (σ1^2 + σ2^2) ) / Δ^2, where σ1^2 and σ2^2 are variances of the two groups (often assumed equal), Δ is the minimum detectable effect, α is significance level, and 1-β is power.
Compute the sample variance from the historical array. If the two groups are assumed to have equal variance, use the pooled variance; otherwise, use the historical variance for both groups if no other information is available.
Calculate z_{1-α/2} for the two-sided test and z_{1-β} for the desired power. Use a standard normal quantile function (e.g., scipy.stats.norm.ppf) to obtain these values.
Plug the values into the formula, round up to the next integer to ensure the required power, and return the per-group sample size. Handle edge cases such as zero variance or non-positive MDE by raising an error or returning infinity.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Pretty mechanical once you write out the law of total probability for P(B).
First, restate Bayes' rule and identify the given probabilities. Then, compute P(B) using the law of total probability: P(B) = P(B|A)P(A) + P(B|not A)P(not A). Finally, plug into Bayes' rule to get P(A|B).
Pro tip: Mention edge cases like P(B)=0 and how to handle them, and relate the formula to a real-world example (e.g., A/B testing at Roblox) to show practical understanding.
Write down Bayes' theorem: P(A|B) = P(B|A) * P(A) / P(B). This sets the foundation.
Use the law of total probability: P(B) = P(B|A)P(A) + P(B|not A)P(not A), where P(not A) = 1 - P(A).
Substitute the computed P(B) and given values into the formula to calculate P(A|B).
Check if P(B) = 0; if so, P(A|B) is undefined. Mention this to show robustness.
Optionally, test with a simple numerical example to ensure the implementation works as expected.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.