Created
July 22, 2018 17:41
-
-
Save marknagelberg/4e647533f034a244ea3850e6ab5ec4da 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
#Observe probability difference from 2% to 10% | |
p_diffs = [x*.01 for x in range(2,11)] | |
data = [] | |
for p_diff in p_diffs: | |
record = {} | |
record['Probability Difference'] = p_diff * 100 | |
record['Sample Size to Detect Difference'] = sample_required(p1=.5, | |
p_diff=p_diff, | |
alpha=.05) | |
record['Confidence Level'] = '95%' | |
record['Initial probability'] = '50%' | |
data.append(record) | |
for p_diff in p_diffs: | |
record = {} | |
record['Probability Difference'] = p_diff * 100 | |
record['Sample Size to Detect Difference'] = sample_required(p1=.5, | |
p_diff=p_diff, | |
alpha=.01) | |
record['Confidence Level'] = '99%' | |
record['Initial probability'] = '50%' | |
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