Last active
July 22, 2018 17:36
-
-
Save marknagelberg/b6bfe3e2141f8eeaeb0f2537ccbed81f to your computer and use it in GitHub Desktop.
Function to calculate sample size
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
import math | |
import numpy as np | |
from scipy import stats | |
import pandas as pd | |
import seaborn as sns | |
def z_calc(p1, p2, n1, n2): | |
p_star = (p1*n1 + p2*n2) / (n1 + n2) | |
return (p2 - p1) / math.sqrt(p_star*(1 - p_star)*((1.0 / n1) + (1.0 / n2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment