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.

Main content
Current time:0:00Total duration:4:30

Simulation providing evidence that (n-1) gives us unbiased estimate

UNC‑1 (EU)
UNC‑1.J (LO)
UNC‑1.J.3 (EK)
UNC‑3 (EU)
UNC‑3.I (LO)
UNC‑3.I.1 (EK)

Video transcript

here is a simulation created by Khan Academy user te TF I can assume that's pronounced dead F and what it allows us to do is give us an intuition as to why we divide by n minus 1 when we calculate our sample variance and why that gives us an unbiased estimate of population variance so the way this starts off and you can I encourage you to go try this out yourself is that you can construct a distribution it says build a population by clicking in the blue area so here we're actually creating a population so we're creating them every time I click it increases the population size so let me just and I'm just randomly doing this and I encourage you to go on onto this onto this scratch pad it's on the Khan Academy computer science and try to do it yourself so here we are I can stop at some point so I've constructed a population I can throw out some random points up here so this is our population and you saw while I was doing that it was calculating parameters for the population it was calculating the population mean at two hundred four point zero nine and also the population standard deviation which is derived from the population variance this is the square root of the population variance and it's at sixty three point eight it was also pop plotting the population variance down here you see it's 63 point eight which is the standard deviation it's a little harder to see but it says squared this these are these numbers squared so this is essentially sixty three point eight is the population at sixty three point eight squared is the population variance so that's interesting by itself but it really doesn't tell us a lot so far about why we divide by n minus one and this is the interesting part we can now start to take samples and we can decide what sample size we want to do I'll start with really small sample so the smallest possible sample that makes any sense so I'm going to start with really small samples and what they're going to do what the simulation is going to do is every time I take a sample it's going to calculate the variance so the numerator is going to be the sum of each of my data points in my sample minus my sample mean and I'm going to square it and then it's going to divide it by n plus a so and it's going to vary a is going to divide it by anywhere between n plus negatives so n minus 3 all the way to n plus a and we're going to do it many many many many times we're going to essentially take the mean of those variances for any a and figure out which gives us the better at the best estimate so if I just generate one sample right over there well we see when we when R we see kind of this curve when we have high values of a we are under estimating when we have lower values of a we are overestimating the population variance but that was just for one that was just for one sample not really that meaningful it's one sample of size two let's generate a bunch of samples and then average them over many of them and you see when you look at many many many many many samples something interesting is happening when you look at the mean of those samples when you average together those curves from all of those samples you see that our best estimate is when a is pretty close to negative 1 is when this is n plus negative 1 or n minus 1 anything less than negative 1 if we did negative n minus 1 point 0 5 or n minus 1.5 we start overestimating the variance anything less than and anything less than negative 1 so if we start if we have n plus 0 if we divide by n or if we have n plus 100 point zero 5 or whatever it might be we start under estimating we start under estimating the population variance and you can do this for samples of different sizes let me try a sample size 6 and here you go once again as I press I'm just keeping generate sample press down as we generate more and more and more samples and for all of the A's we essentially take the average across those samples for the variance depending on how we calculate it you'll see that once again our best estimate is pretty darn close is pretty darn close to negative 1 and if you were to try this if you were to get this to you know millions of samples generated you will see that your best estimate is when a is negative 1 or when you are dividing but when you have when you're dividing by n minus 1 so once again thanks T et f2 f2 think about why we divide by n minus 1