If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Estimating a P-value from a simulation

AP.STATS:
DAT‑3 (EU)
,
DAT‑3.A (LO)
,
DAT‑3.A.1 (EK)
,
DAT‑3.A.2 (EK)
,
DAT‑3.B (LO)
,
DAT‑3.B.1 (EK)
,
DAT‑3.B.2 (EK)

## Video transcript

so we have a question here on p-values it says have you read an article that said 6% of teenagers were vegetarians but she thinks it's higher for students at her school to test her theory every took a random sample of 25 students at her school and 20% of them were vegetarians so just from this first paragraph some interesting things are being said it's saying that the true population proportion if we believe this article of teenagers that are vegetarian we could say that is 6% now for her school there is a null hypothesis that the proportion of students at her school that are vegetarians so this is at her school that the true proportion the null would be it's just the same as the proportion of teenagers as a whole so that would be the null hypothesis and you can see that she's generating an alternative hypothesis but she thinks it's higher for students at her large school so her alternative hypothesis would be the proportion the true population parameter for her school school is greater than 6% and so to see whether or not you could reject the null hypothesis you take a sample and that's exactly what Evy did she took a sarandon sample of 25 students and you calculate the sample proportion and then you figure out what is the probability of getting a sample proportion this high or greater and if it's lower than a threshold then you will reject your null hypothesis and that probability we call the p-value the p-value is equal to the probability that your sample proportion and she's doing this for students at her school is going to be greater than or equal to 20% if you assumed that your null hypothesis was true so if you assumed that the true proportion at your school was 6% vegetarians but you took a sample of 25 students where you got 20% what is the probability of getting 20% or greater for a sample of 25 now there's anyways to approach it but it looks like she is using a simulation to see how likely a sample like this was to happen by random chance alone every performed a simulation she simulated 40 samples of N equals 25 students from a large population where 6% of the students were vegetarian she recorded the proportion of vegetarians in each sample here are the sample proportions from her 40 samples so what she's doing here with the simulation this is an approximation of the sampling distribution of the sample proportions if you were to assume that your null hypothesis is true and it says below every wants to test her null hypothesis which is that the true proportion at her school is 6 percent versus the alternative hypothesis that the true proportion at her school is greater than 6 percent where P is a true proportion of students who are vegetarian at her school and then they asked us based on these simulated results what is the approximate p-value of the test and they say the sample result the sample proportion here was 20 percent we saw that right over here well if we assume that this is a reasonably good approximation of our sampling distribution of our sample proportions there's 40 data points here and how many of these samples do we get a sample proportion that is greater than or equal to 20 percent well you could see this is 20 percent right over here 20 hundredths and so you see we have 3 right over here that meet this constraint and so that is 3 out of 40 so if we think this is a reasonably good approximation we would say that our p-value is going to be approximately 3 out of 40 that if the true population proportion for the school were 6 percent if the null hypothesis were true then approximately 3 out of every 40 times you would expect to get a sample with 20 percent or larger being vegetarians and so three fortieths is what let's see if I multiply both the numerator and the denominator by two and a half this is approximately equal to I say two and a half because to go from 40 to 100 and then two and a half times three would be 7.5 so I would say this is approximately 7.5% and this is actually a multiple-choice question and if we scroll down we do indeed see approximately 7.5% right over there