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} .$$
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:
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
pchisqis 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.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.)