Introduction

A casual dive into why sample variance divides by n-1 and how we use samples to estimate population parameters without measuring absolutely everyone.

OK so from here on out — like the category name says — I’m just gonna cherry-pick the basic stats stuff I actually feel like writing about. I’ve done more than this, but I don’t really feel like I’m bringing any deep insight to the table here, so… I’ll leave that part to the folks who actually majored in statistics. I’m just gonna be a casual player.

And even when I say “basic statistics” — look, no matter how little stats you know, you already know what a population mean is, what a variance is, all that. And the stuff like $E(aX+b) = aE(X)+b$, $V(aX+b) = a^2V(X)$? Yeah, I’m not doing those either. That’s high school math…

Ahhh I dunno I dunno, let’s just dive in.

From the population to the sample… wait, why on earth do you divide by $n-1$?

Everything we’ve covered up to this point — like I was hinting at earlier — was about the population.

But hold on. Is it actually feasible to go analyze a whole population? Like… really?

Think about it for a sec. If you wanted to know the average height of people living in Seoul, you’d have to go measure every single Seoul resident. That kinda smells like overkill, right? So in practice, what we do is pull a random sample out of the population and use that to estimate things about the population…

Example time — say a random variable $X$ describes a daily sales count with some probability distribution, and you wanna figure out the average number of cars a dealer sells during the first 10 days of every month.

But you obviously don’t have 10 years to sit around investigating, so you just surveyed last month’s sales for the first 10 days, and let’s say you got these 10 numbers:

9, 11, 11, 14, 13, 9, 8, 9, 14, 12.

For this calculation, assume $n\ge2$ independent observations from the same distribution, with finite mean $\mu$ and variance $\sigma^2$. A real sales sample would need a sampling design that supports those assumptions.

Yep — that’s called a sample. And then — the sample mean is the estimator of the population mean mu, the population mean, and it’s

Equation from the original notes

right? And the estimate from our sample mean is $(9+11+11+\cdots+12)/10 = 11$. So 11 is our estimate.

The X-bar, the sample mean estimate isn’t always gonna match $E(X)$ (or mu, the population mean), but E of X-bar equals mu — yeah, this part is high school stuff.

But the sample variance — that one’s different. The population variance is $\sigma^2=E[(X-\mu)^2]$. For a finite, equally weighted population, that means averaging the squared deviations from its mean. The original picture below accidentally leaves out that square; it is not the formula to use:

Equation from the original notes

whereas the estimator of the population variance — we call it the sample variance, write it as $S^2$ — and $S$-squared is

$$S^2=\frac{1}{n-1}\sum_{i=1}^n(X_i-\bar X)^2.$$

The original picture below drops the square too. Use the corrected text formula above; the worked numerical calculation later does include the squares.

Equation from the original notes

The denominator is different.

Why $n-1$? We estimated the center from these same observations. Moving the center to $\bar X$ makes their squared deviations smaller:

$$\sum_i(X_i-\bar X)^2=\sum_i(X_i-\mu)^2-n(\bar X-\mu)^2.$$

With the independent, same-distribution assumptions above, $E[(\bar X-\mu)^2]=\sigma^2/n$. So the expectation of the sum on the left is $n\sigma^2-\sigma^2=(n-1)\sigma^2$. Divide by $n-1$ and $E[S^2]=\sigma^2$. That’s the unbiasedness we wanted, and it doesn’t require a normal distribution. The chi-square result later will tell us more about the distribution of $S^2$ when the observations are normal.

OK let me just crunch the estimate for our example real quick!!!

Equation from the original notes

And the estimate of the population standard deviation is just the square root of that — so about 2.21 (yeah, I used a calculator~).

Alright. Now we move on to the topic of distributions.

The basic distributions you need to know in stats are: the normal, Poisson, exponential, Gamma, $t$, $\chi^2$ (chi-square), $F$ — and I’ll be covering alllll of them!!! …is a lie, I really don’t wanna do normal distribution T_T

My main major is physics, so I spent my whole life thinking the only distributions that existed in this universe were Gaussian, Poisson, Fermi-Dirac, and Bose-Einstein. So when I ran into all this stats stuff — honestly, full-on culture shock.

So shall we touch on the normal distribution first?

…I was going to — but actually, I think it’d be way better to know the moment generating function before that. So I’ll do MGF first!!

Moment Generating Function

Ahhh wait — you know what, should I just push this to the next post? Yeah, let’s do that >_< !!!


Heads-up. The two original variance-definition pictures omit the square on the deviation. The corrected definitions are written next to them: $\sigma^2=E[(X-\mu)^2]$ and $S^2=\sum_i(X_i-\bar X)^2/(n-1)$. The worked example uses squared deviations correctly: $S^2=44/9\approx4.89$.

Questions or corrections?

Did a step lose you, or does a number look off? Email me or use the contact page. Include the note title and the step or figure you mean.

Feedback goes to me privately by email; it is not posted as a public comment.