Derivation of the Student's t-Distribution

Where the 'Student' name came from, why we ditch the Z-stat when σ is unknown, and a full derivation of the t-distribution PDF — plus properties and a worked example.

First off, the name. Why “Student t-distribution”?

W.S. Gosset worked at the Guinness brewery and published under the pen name “Student.” That gives us the name Student’s t-distribution. Publishing the distribution made it available to others; it was not a way to keep the mathematical result secret from rival breweries!

OK so why do we even use this thing?

Say we want to estimate the population mean $\mu$. The natural move is to use the sample mean

Sample mean X bar

and look at the distribution of

Sample mean X bar

which gives us

Z statistic

Cool, that’s the Z statistic. Use it, done.

EXCEPT — what if

Population variance sigma squared

is unknown? Then the Z statistic is dead in the water. Can’t use it.

For the exact result here, assume $n\ge2$ independent observations from the same normal population, with $\sigma^2>0$. Replace $\sigma$ by the usual sample standard deviation $S$, computed with denominator $n-1$. Then we use

T statistic

which follows $t_{n-1}$ under those assumptions. This is not an exact distribution-free result for any sample just because $\sigma$ is unknown!

For the general density derivation, write $T=Z/\sqrt{U/\nu}$ with $Z\sim N(0,1)$ and an independent $U\sim\chi^2_\nu$. Here $\nu$ denotes degrees of freedom; the sheets use $n$ for that role. In the normal-sample statistic above, $\nu=n-1$. The PDF looks like:

Student t density

…and that’s what the textbook says.

But we’re not just gonna stare at it and move on, right???? Right????

I mean — this whole post is basically the derivation anyway lol lol lol lol heh heh.

Let’s go.

Equation from the original notes

Equation from the original notes

Equation from the original notes

OK now let’s quickly hit the properties of the t-distribution and wrap this up.

First — the t-distribution is symmetric about the origin. (You can see it’s an even function with basically no effort.)

Second — there is no universal sample-size cutoff of 30 that decides whether a t-test is valid. For independent normal data with unknown variance, the one-sample statistic has an exact t-distribution at any $n\ge2$. For nonnormal data it is an approximation whose quality depends on the distribution and sampling conditions, not a magic number.

The rules of thumb I’d heard were all over the place: some said 100, some 10, and the story was ‘just think of 30 as an average.’ That’s the confusing advice I was recording, not a valid way to choose a test! The distributional conditions above, rather than averaging magic cutoffs, are what matter.

Mean and variance (the $n$ in these two distribution formulas means degrees of freedom, not the size of a sample):

  • Mean: $E(T) = 0$, for $n > 1$. (Translation: the t-distribution with 1 degree of freedom has no mean.)
  • Variance: $\mathrm{Var}(T) = n/(n-2)$, for $n > 2$. (Translation: t-distributions with 1 or 2 degrees of freedom have no variance!!!!)

OK and finally — how to read the t-distribution table. (Honestly might not even be necessary, but,,,)

The table gives you the $(1-\alpha)$ quantile written as

T alpha,n

which means

Upper-tail probability alpha

So for example, when you look at the table:

T0.05,9 equals1.833

What’s that number telling you?!

Right-tail5percent sketch at1.833

Hmm….. let’s just do one example and call it a day.

(Problem from: Walpole, et al., Probability and Statistics for Engineers and Scientists.)

Ex. 8.11 A chemical engineer claims that the yield of a certain batch process is 500g per liter of raw material. To prove it, every month he pulls 25 batches and runs tests. The rule: if the t-value computed from the test results lands between $-t_{0.05}$ and $t_{0.05}$, his claim stands. The 25-batch test came back with a sample mean of 518 and a standard deviation of 40g. What can we say? Assume the population is approximately normal.

Plug into the t formula:

T=(518−500)/(40/√25)=2.25

With 24 degrees of freedom, $t_{0.05}=1.711$ and $t=2.25$ lies outside the stated interval. So we reject $H_0:\mu=500$ under that rule. Each tail has probability 0.05, making this a two-sided 10% test; its two-sided p-value is about 0.0339. The observed mean is higher, but this is statistical evidence, not proof of the true mean. A result inside the interval would mean failing to reject, rather than proving the engineer’s claim.

Now in real life, the t-distribution gets used a ton in t-tests — but we haven’t actually talked about hypothesis testing here yet, so it’d feel kinda wrong to drop a t-test problem on you. We’ll come back to testing later and do one then.

n = [1., 2., 5., 100000000000000]
for i in n:                   # i = n
    x = np.linspace(-5, 5, 100)
    y = sc.t(i).pdf(x)
    plt.plot(x, y, linewidth=2.0, label = 'n=%s' % i)
plt.grid(True)
plt.legend()
plt.ylabel('p(x)')
plt.xlabel('x')
plt.title('Student-t Distribution')
# plt.savefig('5.Student-t Distribution.jpeg')

Student t distributions for increasing degrees of freedom

Apparently, as $n$ keeps cranking up, this thing converges to the Gaussian.

Shall we verify that with a computer?!??!

n = 5.
x = np.linspace(-0.3, 0.3, 100)
for i in range(3):
    y1 = sc.t(n).pdf(x)
    plt.plot(x, y1, linewidth=2.0, label = 'n=%s' % n)
    n = n * 5
y2 = sc.norm(0, 1).pdf(x)
plt.plot(x, y2, linewidth=1.0, label = 'Gaussian')
plt.grid(True)
plt.legend()
plt.ylabel('p(x)')
plt.xlabel('x')
plt.ylim(0.37, 0.4)
plt.title('Student-t & Gaussian Distribution')
# plt.savefig('6.Student-t & Gaussian Distribution.jpeg')

Student t and Gaussian distributions

After plotting it a few times, it really did look like the center was aggressively catching up to the Gaussian, so I zoomed the y-range way in to focus on it.

With the range pinned down like that, let’s crank $n$ up bigger and bigger again.

n = 50.
x = np.linspace(-0.3, 0.3, 100)
for i in range(3):
    y1 = sc.t(n).pdf(x)
    plt.plot(x, y1, linewidth=2.0, label = 'n=%s' % n)
    n = n * 5
y2 = sc.norm(0, 1).pdf(x)
plt.plot(x, y2, linewidth=1.0, label = 'Gaussian')
plt.grid(True)
plt.legend()
plt.ylabel('p(x)')
plt.xlabel('x')
plt.ylim(0.37, 0.4)
plt.title('Student-t & Gaussian Distribution(2)')
# plt.savefig('7.Student-t & Gaussian Distribution(2).jpeg')

Student t and Gaussian distributions second comparison

Once $n$ gets stupidly large, the curves just completely overlap to the eye — so I picked a “big enough” $n$ at a sensible point and stopped……


Heads-up. The figures here are the original notes, slips and all. A few things to watch for:

  • On the first sheet, $(n-1)S/\sigma^2$ should have $S^2$.
  • The sheet goes from $(n-1)S^2/\sigma^2\sim\chi^2_{n-1}$ straight to treating $nS^2/\sigma^2$ as $\chi^2_n$. That’s a shortcut: with the usual sample variance, the $t$ statistic ends up with $n-1$ degrees of freedom.

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.