from scipy.stats import norm, zscore
def sample_power_probtest(p1, p2, power=0.8, sig=0.05):
#two-sided t test
z = norm.isf([sig/2])
zp = -1 * norm.isf([power])
d = (p1-p2)
s =2*((p1+p2) /2)*(1-((p1+p2) /2))
n = s * ((zp + z)**2) / (d**2)
return int(round(n[0]))
sample_power_probtest(p1 = 0.5, p2 = 0.75, power = 0.8, sig = 0.05)
59