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.

## Statistics and probability

### Course: Statistics and probability>Unit 13

Lesson 2: Comparing two means

# Hypothesis test for difference of means

Hypothesis Test for Difference of Means. Created by Sal Khan.

## Want to join the conversation?

• Even with an n>30, I still don't agree with using the sample's standard deviation as a valid approximation of the population's standard deviation. Say you test your sample the way Sal does it, and realize that the probability of you getting that sample was 1%. Normally, you would reject the null hypothesis. But say the null hypothesis was indeed correct. This means you just happened to choose a lot samples from the far left or far right of the population mean. Since your sample is representative of such a small extreme section, the standard deviation of your sample would have been a lot smaller than the true standard deviation of the total population. Therefore, since Sal used the sample standard deviation as his population standard deviation, he would have underestimated the population standard deviation, and consequently overestimated the z score of that sample. The degree at which he overestimated? I'm not sure, I think I'd have to solve some recursive function that is really hard to think about right now. Anyways, I'm sure there's something I'm missing, because I have full faith in Sal Khan. Please let me know if I have overlooked something.
• > "The degree at which he overestimated? I'm not sure, I think I'd have to solve some recursive function that is really hard to think about right now."

I'm not sure about that. There might be some way to formally express the degree of error, but I like jumping to simulations. The Type I error -- rejecting Ho when Ho is actually true -- is slightly inflated. By the time we get to n>30 it's not really by much, but it's a bit above what it should be. This means that using the Z-test when we should use the T-test will conclude a significant result a bit too often.
• If we are assuming that the null hypothesis is true (there is no difference between the two diets), why are we using each of the sample standard deviations separately, as if they are separate populations? If the null hypothesis is true, both samples are taken from the same population. Shouldn't we then take an average of the two standard deviations, or recalculate the standard deviation of the whole n=200 sample?
• I was thinking in the same way so I calculated the the null hypothesis distribution STD from the average of variances and the result was 0.6165 which is so close to the 0.617 that Sal used.
• His critical value Z score is 1.65 because of the 95%. I'm a little confused, because my chart says 95% should be 1.96. Am i using a different chart for something unrelated to z scores?
• One sided vs two sided is important. If we're testing for a "difference" then we need to split the type 1 error probability (alpha) into the two tails, so 0.05 translates to a z value of 1.96. If we're only looking for an increase or decrease, then we put all of the alpha probability into one tail, which leads to a z value of 1.65.
• At , I don't understand why the mean of the sampling dist. is the same as the mean of the population dist.

Couldn't your sample mean be quite different? I.e. couldn't you draw a sample that had a higher mean than the overall population ?

Or is he saying that the mean of the distribution of all the samples you draw is going to be the same as the mean of the overall population?
• Great question. And yes, your last sentence is the correct explanation! This is why inferential stats can be confusing, and why every single word is critical when we talk about means and samples and distributions. As you say, the mean of ONE SAMPLE could be (in fact, almost always IS) different from the population mean. But the mean value of the distribution of all the sample means (phew!) will be the same as the population mean. Of course, you DON'T HAVE "all the sample means", you only have ONE of them (usually)! So the "distribution of all sample means" is usually something we just imagine as a theoretical abstraction. But it's critical to understand what that distribution represents (we have to imagine doing the same experiment many, many times) in order for hypothesis testing to make sense.
• I'm baffled as to why we keep using our original sample standard deviations as estimates for the population SDs (c. ) once we're assuming the null hypothesis. If (and I might be barking up the wrong tree here) the hypothesis is that there's no meaningful difference whatsoever in weight loss effect between the two diets, why should their SDs remain distinct when imagined across the whole population? If the two groups' data are basically identical when viewed globally, shouldn't their SDs be identical too?
• because it would lead to same answer. if you sample twice from the same population then the best variance estimator is ((n1-1)var(x1) + (n2-1)var(x2))/(n1+n2-2) ... i know you understand which symbol means what here .. now calculate for variance of difference of means of two iid samples from this population using the just calculated estimate of variance. It is the same thing as what sal does
• On 6.43 sal used the same "The standard deviation of the difference of the sample mean" as the video he used before. But on the last video on this chapter (named "Hypothesis test comparing population proportions), he calculated at new Standard Deviation for the Null Hypothesis. Why didn't he do it here? Where in both cases the Null hypothesis was u1-u2=0.
• I think you have a valid observation and unfortunately I don't have an answer for it. I scrolled all the answers in this thread and looks like no one has responded to your query so far. Please let me know if you have found/(or happen to find in future) the reason as to why new SD was not calculated after assuming null hypothesis as true.
• Hello..
Is it ok, if I use general t-test to solve the same problem?
• Since you are dealing with means, YES! You very well can. Please flag me or downvote if I am wrong, but upvote if I am correct.
• Why do we state the null hypothesis as `mu_1 - mu_2 = 0` and not simply `mu_1 = mu_2`?