[SOUND] In this lesson, we will start by focusing on step three and learn how to calculate what is known as the P value for the sample data we have collected. P value is the largest chance of having Type I error occur that is null hypothesis or rejected based on observed test statistics. Remember, Type I error is the probability of rejecting a null hypothesis when it should not have been rejected because in reality, it's actually true. We know this can happen because there is a chance that we have a chance that is not really a good representative sample, which leads us to make a wrong conclusion. Let me explain this concept through an example. Let's go back to this example, we did in an earlier lesson and expand on it. This is where we want to insure that the bag of chocolates are being filled correctly to 300 grams. If too much then we will be losing money since we are charging the customer as if the bag only has 300 grams of chocolate. Too little and our company can be accused of defrauding the customers. So this is a two tail test. To do this testing, we are taking samples of 50 bags and based on what we get we will decide If the production line is working properly or if it needs adjustments. The latest sample has given us the following results. Sample mean is about 294.6 and standard deviation of the sample is about 11. We will follow the steps for performing hypothesis testing of stating the hypothesis, specify the significance level and move to calculating the p-value which would be based on sample mean and standard deviation. But before we can actually calculate the p-value, I would like to review the principles behind what is being done. Statistical tasks rely on sampling distribution of the statistics that estimates the parameter specified in the null and alternate hypothesis. This is based on what we learned in the first course. Central limit theorem, which showed that if you repeatedly take samples from a population. In this case the population of bags of chocolates we are producing. Then the means of these samples will cluster around the center and the variability is determined by the standard error. This is the distribution of the sample means if we repeatedly took samples from our production line and plotted the sample means. This curve peaks at 300 and has a standard error of 1.55. So now, we have taken one sample. What we are contemplating is to know what is the chance of getting a sample that differs from our null hypothesis by as much as this one sample that we have if the null is actually true. Let's first look at our sample and the distribution of weights for the 50 bags that we weighed. Our sample of 50 bags gave a mean of 294.8 and a standard deviation of 11. This is how the weight of these 50 bags were distributed. The distribution of this sample shows a lot more variability. Looking at the two distribution at the same time, you can see that our sample miu falls way out to the left of the hypothesized miu after three hundred. The answer to the question of, what is the probability of getting the sample that differs from hypothesized miu? By as much as this one sample if the null hypostasis is indeed true. This answer is what we refer to as the p-value so p-value is probability of finding a sample like the one we have. Okay, so let us now see how to find the p-value of our sample and to do this. First we have to calculate the t value, known as the test statistic, which tells us how many standard errors we are away from the mean. When we are testing the mean, we will use the t distribution, the other bell-shaped curve with similar properties as the normal distribution. Except its spread is partly controlled by its degrees of freedom, which is sample size minus 1. So in this example, we put 294.6 for the sample mean and subtract it from the hypothesized mean of 300. Then the difference is divided by the standard error, which is the sample standard deviation on 11, divided by the square root of the sample size of 50. The test statistic, or the t value, for our sample is negative 3.47. So the sample we have falls 3.47 standard deviations away from the center of the distribution. Do you remember what we call observations which are more than 3 standard deviations away from the mean? Outliers, these have very low probability of occurring. So right away, you know that you have a sample that is way in the left tail. The actual probability of finding a sample, this is this far, to the left is found by using the excel function shown here this function will return the probability to the left of a given test or t-value. It has three arguments. The first one, is the t value you have calculated. Second argument, is the degrees of freedom which is sample size minus 1. And the last argument, one means that we want cumulative probability. You will always use one for the last argument in this class. Of course, there are Excel illustration videos, which I take you through every step, so to be sure to watch those. Now back to here, placing the appropriate values for these arguments returns the p-value of .00055. This is the probability of drawing a sample like ours. It is pretty low, five out of 100,000. Let me explain more what this means in pictures. Clearly our sample falls way out in the tail on the left side. And the probability of finding a sample like this or even more extreme is extremely small. Again 55 out of 100,000, for us our alpha sets the limit up to which we will accept as reasonable differences. We will notice from sample to sample. Views alpha .05. And that is roughly about two standard errors. So now that we have the p-value, we are ready to move on to making conclusions from our sample results. So the significance level sets the number of deviation from mean v accept as natural variation and acceptable. Anything outside of those bounds means that we believe there is too much difference between what we see from our sample information and what we thought we should see. We could use this to even find the confidence interval for the population me. At alpha 5%, confidence level is 95%, and that is roughly two standard errors. We can use this to get a quick estimate for the confidence interval, which would be between 291.49 and 297.7, so the bag's mean rate appears to be below 300 grams. Given what we see, of course, there are two possibilities. One, the null hypothesis is true. We are very unlucky to find this sample, or two, sample data provides evidence against the null hypothesis and it should be rejected. The most plausible explanation is the second conclusion. However, if you feel uncomfortable with this conclusion then you can take another sample to see what happens. This is exactly what happened in the Volkswagen case when the researcher at first found sample information that was way out. First they decided that it must be their bad luck. So they repeated their experiment. And time and time again they would get results that would point them to rejecting Volkswagen's claims. So ultimately, they decided to report their results, and as you know, it was Volkswagen that had lied. So the correct conclusion was indeed to reject the null hypothesis. For a two-tail test, you can reject the null hypothesis if sample mean is too far to the right or to the left. In our example, we will reject the null hypothesis if the mean weights were too low or too high. Because in both cases, the production process would require adjustments. The rule is, to reject no hypothesis if p-value is less than alpha. In the two tail task, both the alpha and p-value split between the two tails. So p-value, we need to compare Is two times .00055 or 0..11 which is less than .05 and thus reject the null hypothesis. You would actually reject even at .01 level of significance. This means that the line manager must stop the production and make adjustments. Otherwise, on average, they would keep producing bags that will weigh less than 300 grams.