Created
July 22, 2018 17:39
-
-
Save marknagelberg/6b0679187cd7ce110546e581417bf6c4 to your computer and use it in GitHub Desktop.
Code to support post on significance levels required for two sample z test of proportions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Map how sample size changes as choice of p1 changes, holding all | |
#else constant. | |
p1s = [x*.01 for x in range(96)] | |
data = [] | |
for p1 in p1s: | |
record = {} | |
record['Probability Difference'] = p_diff | |
record['Sample Size to Detect Difference'] = sample_required(p1=p1, | |
p_diff=.05, | |
alpha=.05) | |
record['Confidence Level'] = '95%' | |
record['Initial Probability'] = p1 * 100 | |
data.append(record) | |
df = pd.DataFrame(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should line 9 be p1 instead of p_diff? p_diff is uninitialized in its current form. Thank you for the great example.