This question evaluates understanding of statistical inference and probabilistic reasoning by combining a frequentist power/sample-size computation for a two-sided two-sample z-test with a basic Bayesian conditional probability calculation.
You are implementing two small statistical utilities.
Part A — Power / sample size (two-sample z-test)
x
: a 1D numeric array of historical observations of a metric (assume i.i.d.).
alpha
: significance level (e.g., 0.05).
power
: desired power (e.g., 0.8).
effect_size
: the minimum detectable absolute difference in means, Δ (same units as
x
).
n
for an
equal-sized
A/B test using a
two-sided two-sample z-test
.
x
using the sample standard deviation
s
.
n
that achieves the requested power (round up).
Part B — Bayes’ rule
p_A = P(A)
,
p_B_given_A = P(B|A)
,
p_B_given_notA = P(B|¬A)
.
P(A|B)
.
0 < p_A < 1
and all conditional probabilities are valid.