P-value for a test of normal variance given sample variance. A sample of $31$ cans of soda showed a standard deviation of $5$ ml. If we are to test that the population variance is less that $30$, how much would the $p$-value approximately be.
I tried using this formula but it gives me a weird number and it looks completely wrong.
$$ \chi^2 = (n-1)\frac{S^2}{\sigma^2}= 30*\frac{5^2}{30} .$$
 A: Thank you for showing some of your work so far. You have started in the right direction. (+1)
You want use your sample to test $H_0:\sigma^2 = 30$ against the one-sided alternative $H_a:\sigma^2 < 30.$
You have the correct test statistic for normal data:
$Q = \frac{(n-1)S^2}{\sigma_0^2} = 
\frac{30(5^2)}{30} = 25.$
Under $H_0,$ you have $Q \sim\mathsf{Chisq}(\nu=30).$
So the P-value is the area under the density curve
of $\mathsf{Chisq}(30)$ to the left of $Q = 25.$

R code for figure:
curve(dchisq(x, 30), 0, 70, ylab="PDF", xlab="Q", lwd=2, 
      main="Density of CHISQ(30)")
 abline(h=0, col="green2")
 abline(v=0, col="green2")
 abline(v=25, col="red", lwd=2, lty="dotted")

You might be able to approximate this P-value using some
printed tables of chi-squared distributions, but
typically they show too few values to be helpful for finding P-values. It is better to
use a statistical calculator or statistical computer software. [From these tables you can see that the answer is about 0.3]
From R,
where pchisq is a chi-squared CDF we obtain
P-value $0.275 > 0.05 = 5\%,$ so you cannot reject $H_0$ at the 5% level of significance. It is true
that $S^2 = 25 < 30,$ but $S^2$ is not enough smaller than $30$ to say it is significantly smaller.
pchisq(25, 30)
[1] 0.2749681

From R we can see that the observed value of the test statistic $Q$ would need to be smaller than $18.49$ in order to reject $H_0.$ (This is a number you could find
in a printed chi-squared table.)
qchisq(.05, 30)
[1] 18.49266

