运行 ❯
获取您
自己的 Python
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
import scipy.stats as stats import math # Specify the number of occurences (x), the sample size (n), and the proportion claimed in the null-hypothesis (p) x = 10 n = 100 p = 0.5 # Calculate the sample proportion p_hat = x/n # Calculate the test statistic test_stat = (p_hat-p)/(math.sqrt((p*(1-p))/(n))) # Output the p-value of the test statistic (two-tailed test) print(2*stats.norm.cdf(test_stat))
1.244192114854348e-15