Live data from Hacker News

The Central Limit Theorem Visualized with D3

blog.vctr.me

71–80 of 80 posts

Re: The Central Limit Theorem Visualized with D3

#73
post #67
post #58

I liked this but as other commenters have pointed out it's purely binomial at this stage. The great thing about the central limit theorem is that it is more general than just the limiting Binomial case. So, there's this thing called the cumulant-generating function. It's pretty much defined for any random variable X. If you want to get technical it is the logarithm of the Fourier transform of a probability density fu…

Some of the explanatory power of the graphical demo seems to have been lost.

Maybe. But the proof also gives a lot of cute ideas for how to go further with this sort of demo. Since adding random variables amounts to doing convolutions with their distribution functions, if you had a Fourier transform package in JS you could probably show people some nice visualizations of adding together various random variables, and what it does to their probability distributions. This might give more insight into the generality of the CLT: you take a strange curve, convolve it with itself a bunch of times, and in the convolutions and rescaling it becomes first a skewed distribution, then a normal one.

Re: The Central Limit Theorem Visualized with D3

#74
post #58

I liked this but as other commenters have pointed out it's purely binomial at this stage. The great thing about the central limit theorem is that it is more general than just the limiting Binomial case. So, there's this thing called the cumulant-generating function. It's pretty much defined for any random variable X. If you want to get technical it is the logarithm of the Fourier transform of a probability density fu…

Wikipedia and MathWorld[1] define the cumulant-generating function to be the log of the moment generating function, i.e. a Laplace transform, rather than a Fourier transform. This is (essentially) just notational since the proof still holds, but it does mean that the i's and -'s disappear, e.g. with the Laplace-CGF, c'(0) = μ, c''(0) = σ², c'''(0) = σ³ γ.

This proof also works with directly with moment generating functions and characteristic functions (which are the same as the two forms of CGF's without the logarithm), which avoids the slight issue of ln(cos(k)) when cos(k) = 0.

[1]: http://mathworld.wolfram.com/Moment-GeneratingFunction.html

Re: The Central Limit Theorem Visualized with D3

#75
I had to finish the number examples on that page to prove this to myself:

000 -> 0 001 -> 1 010 -> 1 011 -> 2 100 -> 1 101 -> 2 110 -> 2 111 -> 3

0 -> 1: 12.5% 1 -> 3: 37.5% 2 -> 3: 37.5% 3 -> 1: 12.5%

0000 -> 0 0001 -> 1 0010 -> 1 0011 -> 2 0100 -> 1 0101 -> 2 0110 -> 2 0111 -> 3 1000 -> 1 1001 -> 2 1010 -> 2 1011 -> 3 1100 -> 2 1101 -> 3 1110 -> 3 1111 -> 4

0 -> 1: 6.25% 1 -> 4: 25% 2 -> 6: 37.5% 3 -> 4: 25% 4 -> 1: 6.25%

Re: The Central Limit Theorem Visualized with D3

#76
Here's what's going on, what will illustrate the central limit theorem (CLT) and what will not:

For positive integer n and for i = 1, 2, ..., n, let real valued random variable X(i) be so that

P(X(i) = -1 = P(X(i) = 1 ) = 1/2

Assume that {X(1), ..., X(n)} is an independent set of random variables.

Easily the expectation E[X(i)] = 0.

Let real valued random variable

S(n) = X(1) + X(2) + ... + X(n)

Easily E[S(n)] = 0.

For n = 4, S(n) can take on values -4, -3, ..., 0, 1, ..., 4.

The animation in the OP should converge to the density of S(n) where n = 4.

By the CLT, as n approaches infinity, the density of

( 1/sqrt(n) ) S(n)

will be Gaussian with expectation 0.

By the strong law of large numbers, as n approaches infinity, the probability random variable

(1/n) S(n)

converges to 0 is 1.

For increasing n, S(n) is a martingale and is a discrete approximation to Brownian motion. As n approaches infinity, the density of S(n) approaches 0 everywhere on the real line and in its limit is not a density.

Re: The Central Limit Theorem Visualized with D3

#77
post #76

Here's what's going on, what will illustrate the central limit theorem (CLT) and what will not: For positive integer n and for i = 1, 2, ..., n, let real valued random variable X(i) be so that P(X(i) = -1 = P(X(i) = 1 ) = 1/2 Assume that {X(1), ..., X(n)} is an independent set of random variables. Easily the expectation E[X(i)] = 0. Let real valued random variable S(n) = X(1) + X(2) + ... + X(n) Easily E[S(n)] = 0. F…

Errata:

Change

P(X(i) = -1 = P(X(i) = 1 ) = 1/2

to

P(X(i) = -1 ) = P(X(i) = 1 ) = 1/2

For more, let v(i) be the variance of X(i). Then since E[X(i)] = 0

  v(i) = E[ (X(i) - E[X(i)])^2 ]

       =  E[ (X(i))^2 ]

       = (1/2) 1 + (1/2) 1

       = 1
Since in the i.i.d. case the variance of a sum is the sum of the variances, the variance of S(n) is n. Then the standard deviation of S(n) is sqrt(n) so that the standard deviation of

(1/sqrt(n)) S(n)

is 1.

So, for large n, the density of

(1/sqrt(n)) S(n)

converges to Gaussian with expectation 0 and standard deviation 1 and variance 1.

Re: The Central Limit Theorem Visualized with D3

#78
post #77
post #76

Here's what's going on, what will illustrate the central limit theorem (CLT) and what will not: For positive integer n and for i = 1, 2, ..., n, let real valued random variable X(i) be so that P(X(i) = -1 = P(X(i) = 1 ) = 1/2 Assume that {X(1), ..., X(n)} is an independent set of random variables. Easily the expectation E[X(i)] = 0. Let real valued random variable S(n) = X(1) + X(2) + ... + X(n) Easily E[S(n)] = 0. F…

Errata: Change P(X(i) = -1 = P(X(i) = 1 ) = 1/2 to P(X(i) = -1 ) = P(X(i) = 1 ) = 1/2 For more, let v(i) be the variance of X(i). Then since E[X(i)] = 0 v(i) = E[ (X(i) - E[X(i)])^2 ] = E[ (X(i))^2 ] = (1/2) 1 + (1/2) 1 = 1 Since in the i.i.d. case the variance of a sum is the sum of the variances, the variance of S(n) is n. Then the standard deviation of S(n) is sqrt(n) so that the standard deviation of (1/sqrt(n))…

Errata:

Change

Since in the i.i.d. case the variance of a sum is the sum of the variances,

to

Since in the independent case, and, hence, also the i.i.d., case, the variance of a sum is the sum of the variances,

Re: The Central Limit Theorem Visualized with D3

#79
post #74
post #58

I liked this but as other commenters have pointed out it's purely binomial at this stage. The great thing about the central limit theorem is that it is more general than just the limiting Binomial case. So, there's this thing called the cumulant-generating function. It's pretty much defined for any random variable X. If you want to get technical it is the logarithm of the Fourier transform of a probability density fu…

Wikipedia and MathWorld[1] define the cumulant-generating function to be the log of the moment generating function, i.e. a Laplace transform, rather than a Fourier transform. This is (essentially) just notational since the proof still holds, but it does mean that the i's and -'s disappear, e.g. with the Laplace-CGF, c'(0) = μ, c''(0) = σ², c'''(0) = σ³ γ. This proof also works with directly with moment generating fun…

That was in some sense intentional -- I prefer exp(i μ k) exp(-k² σ² / (2 n)) for the clarity of the expression in Fourier space.

That issue is not avoided -- it becomes ln(cosh(k)), which still only has a finite radius of convergence due to branch points at ± i π/2, and a complicated branch-sheet structure. It is not dissimilar from 1/(1 + x^2) -- a perfectly smooth ordinary real function on the real line, very pleasant to work with, but the (real!) Taylor series at 0, 1 - x^2 + x^4 - x^6 + ... does not converge outside of the interval (-1, 1) because it must go to infinity at ± i on the complex plane.

Re: The Central Limit Theorem Visualized with D3

#80
post #75

I had to finish the number examples on that page to prove this to myself: 000 -> 0 001 -> 1 010 -> 1 011 -> 2 100 -> 1 101 -> 2 110 -> 2 111 -> 3 0 -> 1: 12.5% 1 -> 3: 37.5% 2 -> 3: 37.5% 3 -> 1: 12.5% 0000 -> 0 0001 -> 1 0010 -> 1 0011 -> 2 0100 -> 1 0101 -> 2 0110 -> 2 0111 -> 3 1000 -> 1 1001 -> 2 1010 -> 2 1011 -> 3 1100 -> 2 1101 -> 3 1110 -> 3 1111 -> 4 0 -> 1: 6.25% 1 -> 4: 25% 2 -> 6: 37.5% 3 -> 4: 25% 4 -> 1…

Sorry hn killed the formatting :(
Post reply on HN