Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import scipy.stats as st
- def conflevel(n, e, a):
- z = -st.norm.ppf(a / 2)
- uppi = e + (z**2/(2*n)) + (z * math.sqrt(((e*(1-e)) / n) + (z**2/(4*n**2))))
- nidri = 1 + (z**2/n)
- return round(uppi / nidri, 4)
- print("example from book", conflevel(7, (2/7), 0.25))
- print("c=0.5", conflevel(10, 0.3, 0.5))
- print("c=0.25", conflevel(10, 0.3, 0.25))
- print("c=0.1", conflevel(10, 0.3, 0.1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement