I was trying to calculate the p-value for the following coin toss example:
n = 5
h = 4 # out of 5 toss 4 are head
# calculate pvalue using equal or more extreme cases
pval = P(4H1T) + P(4T1H) + P(5H) + P(5T)
= 5/32 + 5/32 + 1/32 + 1/32
= 12/32
= 0.375
But when I tried standard method:
from scipy import stats
phat = h / n
p0 = 0.5 # for unbiased coin
q0 = 1 - p0
z = (phat - p0) / sqrt(p0q0/n)
pval = 1 - stats.norm.cdf(z)
I got:
0.08985624743949994.
Question 1
How to get the similar result using python scipy stats (answer = 0.375) ?
References
In this statquest video the author explains how to get pvalue using equal or more extreme values and we get 0.375
But here,
using the formula given we get another answer.
Question 2
Which method is good so that we can compare pvalue with alpha?