# Untitled

May 3rd, 2021
579
4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. from statistics import NormalDist as nd
3.
4. # Number of Sample population
5. N = input("Sample population: ")
6.
7. # Percent that carry the virus worldwide
8. p0 = input("Percentage (0.0-1.0): ")
9.
10. # Sample Proportion
11. infect = input("Sample population infected: ")
12. phat = float(infect)/float(N)
13.
14. # Standard Error Calc
15. SE = math.sqrt(float(p0)*(1-float(p0))/float(N))
16.
17. # Calculate z-score
18. z = ( phat - float(p0) ) / SE
19.
20. # Calculate tail value based off a normative distribution (and the multiply by 2 because it is a double-sided test)
21. tail_value = nd().cdf(z) * 2
22.
23. if (tail_value <= 0.0001):
24.   print("p-value: 0.0000")
25. else:
26.   print("p-value: "+ str(tail_value))
RAW Paste Data

# Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!