Skip to content

Instantly share code, notes, and snippets.

@marknagelberg
Created July 22, 2018 17:39
Show Gist options
  • Save marknagelberg/6b0679187cd7ce110546e581417bf6c4 to your computer and use it in GitHub Desktop.
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.
#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)
@marm0tuw
Copy link

marm0tuw commented Feb 4, 2019

Should line 9 be p1 instead of p_diff? p_diff is uninitialized in its current form. Thank you for the great example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment