Click here for a transcript.
We're back in our one-line test, hypothesis test video. In this video, we're going to focus on the hypothesis test for a single proportion. And so, here our null hypothesis is that the proportion is equal to 50 percent, and our alternative is that it's less than that, in effect, looking at how frequently windfall wind generation fell below capacities during the Texas 2021 cold snap. And so, in our previous lesson we went over how to do the randomization procedure for this test. And we start off with simulating random data using random binomial. Then we calculate the original, or the sampling distribution of proportions, calculate the data sample, and then we plotted it. And eventually got a p-value equal to zero, which led us to reject the null hypothesis that the wind actually fell below capacity less than 50 percent of the time.
So, if we want to make the one-liner test for this, it involves a couple extra steps. We're still going to be using that stats.cypi library, but before we can actually implement the test we need to define two variables, the first is success rate. And so, this is how often we were successful. And so here, when success rate is defined by the length of wind in which wind was above 6.1, above capacity, and then we need to define the sample size, which is just the total number of variables or data points. And so then our actual one-line test is stats dot binome underscore test, so binomial test. We give it x equals our success rate, n equals our sample size, and again we specify the alternative equal to less. And if you were doing a right-tailed test you would change this to greater, for example.
But in this case, following what we did up here, we're going to do a left-tailed test. So we can run this. We've got a warning that this command is currently being phased out. So eventually we'll need to use this new command, binom test, but for now it's still working. And essentially, it automatically prints out this p-value here. And so, because of that we can compare to this and look that they're very similar. Once again our one-line test is showing a bit more specificity in that number, but is still very, very close to zero. So again, we reject the null hypothesis.