yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Chi-square goodness-of-fit example | AP Statistics | Khan Academy


4m read
·Nov 11, 2024

In the game Rock Paper Scissors, Kenny expects to win, tie, and lose with equal frequency. Kenny plays Rock Paper Scissors often, but he suspected his own games were not following that pattern. So he took a random sample of 24 games and recorded their outcomes. Here are his results: out of the 24 games, he won four, lost 13, and tied seven times. He wants to use these results to carry out a chi-squared goodness of fit test to determine if the distribution of his outcomes disagrees with an even distribution.

What are the values of the test statistic, the chi-squared test statistic, and p-value for Kenny's test? So pause this video and see if you can figure that out.

Okay, so he's essentially just doing a hypothesis test using the chi-square statistic because it's a hypothesis that's thinking about multiple categories. So what would his null hypothesis be? Well, his null hypothesis would be that he has that all the outcomes are equal probability outcomes—equal, equal probability.

Then his alternative hypothesis would be that his outcomes have not equal probability. Remember, we assume that the null hypothesis is true, and then assuming if the null hypothesis is true, the probability of getting a result at least this extreme is low enough, then we would reject our null hypothesis. Another way to think about it is if our p-value is below a threshold, we would reject our null hypothesis.

What he did is he took a sample of 24 games, so n is equal to 24, and then this was the data that he got. Now, before we even calculate our chi-square statistic and figure out what's the probability of getting a chi-square statistic that large or greater, let's make sure we meet the conditions for inference for a chi-squared goodness-of-fit test.

You've seen some of them, but some of them are a little bit different. One is the random condition. I'll write them up here: the random condition would be that this is truly a random sample of games, and it tells us right here he took a random sample of his 24 games, so we meet that condition.

The second condition, when we're talking about chi-squared hypothesis testing, is the large counts condition. This is an important one to appreciate. This is that the expected number of each category of outcomes is at least equal to five. Now, you might say, "Hey, wait, I only got four wins," or "Kenny only got four wins out of his sample of 24," but that does not violate the large counts condition.

Remember, what is the expected number of wins, losses, and ties? Well, if we're assuming the null hypothesis where the outcomes have equal probability, so the expected... I could write right over here, it would be that it's one-third, one-third, one-third, and so one-third of 24 is 8, 8, and 8. That's what Kenny would expect, and since all of these are at least equal to 5, we meet the large count condition.

Then, the last condition is the independence condition. If we aren't sampling with replacement, then we just have to feel good that our sample size is no more than 10 percent of the population. He can definitely play more than 240 games in his life, so we would assume that we meet that condition as well.

So with that out of the way, we can actually calculate our chi-squared statistic and try to make some inference based on it. Our chi-squared statistic is going to be equal to... For each category, it's going to be the difference between the expected and what he got in that sample, squared, divided by the expected.

So the first category is wins; that's going to be 4 minus 8, squared, over an expected number of wins of 8, plus losses. That's 13 minus 8; 13 is how many he got—how many he lost—minus 8 expected, squared, all of that over 8.

So let's see, what is this? Four minus eight is negative four. You square that, you get sixteen. Thirteen minus eight is five; you square that, you get 25. Seven minus 8 is negative 1; square that, you get 1.

Sixteen divided by 8 is going to be 2. Twenty-five divided by 8 is going to be, let's see, that's 3 and 1/8, so that's 3.125. And then 1 divided by 8 is 0.125. You add these together; so let's see, it's going to be 2 plus 3.125, which is 5.125, plus another 0.125, so that's going to be 5.25.

So our chi-squared statistic is 5.25. Now, to figure out our p-value, our p-value is going to be equal to the probability of getting a chi-square statistic greater than or equal to 5.25. You could use a chi-squared table for that, and we always have to think about our degrees of freedom.

We have one, two, three categories, so our degrees of freedom is going to be one less than that, or three minus one, which is two. So our degrees of freedom is going to be equal to two, and that makes sense because, you know, for a certain number of games, if you know the number of wins and you know the certain number of losses, you can figure out the number of ties, or if you know any two of these categories, you can always figure out the third.

So that's why you have two degrees of freedom. Let's get out our chi-squared table. We have 2 degrees of freedom, so we are in this row, and where is 5.25? So 5.25 is right over there, and so our probability is going to be between 0.10 and 0.05.

So our p-value is going to be greater than 0.05 and less than 0.10, and so, for example, if ahead of time—and he should have done this ahead of time—he set a significance level of five percent, and our p-value here is greater than five percent, which we just saw, he would fail to reject in this situation the null hypothesis.

But they're not asking us that here; all they're asking us is what is our chi-squared value and what range is our p-value in? Well, let's see; 5.25 are both of these values, and we saw we got a p-value between 5 and 10, so it is choice A right over there.

More Articles

View All
Example multiplying multi digit numbers
In this video, we’re going to try to compute 6742 times 23. So like always, pause this video and try to compute it for yourself. All right, now let’s work on this together, and I’m going to do it using what’s often known as the standard algorithm. Algor…
9 More Video Game WTFs [CONTINUED]
Do you remember Game Genie? This is what would happen if Mario had a magic mushroom. Oh, I love [Music] that someone’s hallucinating. What I love about this is the Game Genie codes themselves are hilarious. The codes he’s using are Zley, Pigp, and I in Co…
The Mexican-American War | AP US History | Khan Academy
This is a painting of U.S. General Winfield Scott entering Mexico City on September 15, 1847. Scott landed with a U.S. naval fleet several weeks beforehand. He bombarded the coastal stronghold of Veracruz and then fought his way inland toward the capital.…
24 Hours of Sun at the South Pole | Continent 7: Antarctica
The sunlight down there is incredible because you get to see animals go about sort of what they do in perpetual sunlight. In 24 hours, generally, if you have nighttime, if we’ve got an instrument on an animal, or it gets dark out, you can’t work. For me,…
Blockchain 101 - A Visual Demo
This is a blockchain demo. We’re gonna do this in a very visual way, though. We’re gonna make it very easy to understand by stepping through the key pieces of what a blockchain is in a visual way. But before we get started, we need to take a look at this…
Proportional reasoning with motion | AP Physics 1 | Khan Academy
NASA is researching how to send humans to Mars by as early as 2030. Now this is a complex mission because you’re traveling for millions of kilometers, and this will involve a lot of things. We have to think about how much fuel we need, how much oxygen we …