Skip to content

Instantly share code, notes, and snippets.

@marknagelberg
Created July 22, 2018 17:41
Show Gist options
  • Save marknagelberg/4e647533f034a244ea3850e6ab5ec4da to your computer and use it in GitHub Desktop.
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.
#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