
David B. answered 11/13/23
Math and Statistics need not be scary
The posted problem is asking us to determine a probability or p value, which is a continuous distribution, based on count data (discrete distribution). Most simple high school texts will teach a method using a very basic and reasonably accurate approximation using the normal distribution. This is fine for kids and for teaching basic concepts but the proper distribution for a p parameter taken from a Bernoulli distribution is the conjugate prior distribution which is the Beta distribution expressed as a probability.
The problem here is that the level model accuracy and method of determining the test statistic are NOT specified in the question.
It would be SO EASY to just use a simple (and inaccurate) approximation:
Po as 40/138 = 0.28986
V as PQ or (.31)*(.69) = .21390,
se as √(V/n) or √(.1891/138) = 0.03934
Z value for a proportion test (i.e. the TEST STATISTIC) of (Po - π)/se or ( 0.28986 - 0.3100)/0.03934 - which is (rounded to 3 decimal places) = -0.512
(note π is used to designate the population proportion P)
TEST STATISTIC (Z) = -0.512
This is used with standardized Z tables to determine the probability of failing the corrected null hypothesis of Ho:p<=0.31.
note: The posted probrem has a null hypothesis which is logically inconsistent with the alternate hypothesis , which means the student's question can NOT be answered as is )
Using the corrected null hypothesis of Ho: p<=0.31 we find that P(x>Z) = 0.696 so we would NOT reject the null hypothesis.
This is of course a primitive example using high school level statistics.
Using the correct relationships we find that the correct estimated Po = (s+1)/(n+2) or 0.2929
The test used will involve the beta distribution with a beta parameter of 99 and an alpha parameter of 41
The calculation of the p value using the beta distribution and its inverse is a non trivial exercise as the inverse beta distribution does not exist in closed form and using the incomplete beta distribution one has to use iterative methods to find the solution. Fortunately computer software will take care of that for us.
Using R programing language
n = 138
s = 40
p = .31 #population proportion, what we test against
Po = (s+1)/(n+2)
alpha = s + 1
beta = (n-s) + 1
Ptest = pbeta(.31,alpha,beta)
The accurate value of P for the test would be P(x>Z) = 0.679
note: for more information on the proper proportion estimator and hints on the inverse beta distribution needed to answer the hypothesis question see : (https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Jeffreys_interval )