Skip to content

Instantly share code, notes, and snippets.

@lylayang
Last active October 3, 2019 00:40
Show Gist options
  • Select an option

  • Save lylayang/bd54f988636dacede7d18d1c0daa1402 to your computer and use it in GitHub Desktop.

Select an option

Save lylayang/bd54f988636dacede7d18d1c0daa1402 to your computer and use it in GitHub Desktop.
samplesize_list=[]
baseline=0.1
#set lift range: 5%~30% with 1% incrementality of baseline(0.1)
deltas=np.arange(0.005, 0.03, 0.001)
for delta in deltas:
prob2=baseline+delta
effect_size=sms.proportion_effectsize(baseline, prob2)
sample_size=sms.NormalIndPower().solve_power(effect_size=effect_size, power=0.8, alpha=0.05, ratio=1)
samplesize_list.append(sample_size)
plt.plot(deltas, samplesize_list)
plt.title('Minimum required sample size for minimum detectable delta/effective size')
plt.ylabel('Required Sample Size')
plt.xlabel('Minimum Detectable effective size')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment