Exploring the power calculation
As discussed, power is the probability of rejecting the null hypothesis when the alternative hypothesis is true. Here you will explore some properties of the power function and see how it relates to sample size among other parameters. The get_power()
function has been included and takes the following arguments in the listed order n
for sample size, p1
as the baseline value, p2
as the value with lift included, and cl
as the confidence level.
This exercise is part of the course
Customer Analytics and A/B Testing in Python
Exercise instructions
- Calculate the power using
n
=1000
andn
=2000
in that order, along with the pre-loaded parameters,p1
,p2
, andcl
. - Using the variable
n1
for the sample size, find the power with a confidence level ofcl
=0.8
andcl
=0.95
in that order. - Hit 'Submit Answer' to compare the ratios. Which change has the bigger impact, increasing the confidence level or the sample size?
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Look at the impact of sample size increase on power
n_param_one = get_power(n=____, p1=p1, p2=p2, cl=cl)
n_param_two = get_power(n=____, p1=____, p2=____, cl=____)
# Look at the impact of confidence level increase on power
alpha_param_one = get_power(n=n1, p1=p1, p2=p2, cl=____)
alpha_param_two = get_power(n=____, p1=____, p2=____, cl=____)
# Compare the ratios
print(n_param_two / n_param_one)
print(alpha_param_one / alpha_param_two)