Live data from Hacker News

The Central Limit Theorem Visualized with D3

blog.vctr.me

61–70 of 80 posts

Re: The Central Limit Theorem Visualized with D3

#62
post #50
post #45

Earlier quoted context omitted.

No, it does show multiple sample means. Each landing spot is the sum (scaled average) of the n - 1 bernoulli rvs, where n is the number of bins. The issue is that n is small.

You are correct in pointing out this error of the parent comment (by SiVal). Each ball is indeed the sum of "n-1" bernoulli RVs, and the CLT does apply to these sums. As btilly points out elsewhere, to actually obtain the correct limit, you have to normalize the sum correctly. Because of the way the scaling is done in this graphic, as you increase the number of levels, it's in effect normalizing the sum by dividing b…

Thanks for this explanation. I understood most of it but could you explain why you should normalize using 1/sqrt(n) and why doing so makes the result converge in distribution?

Re: The Central Limit Theorem Visualized with D3

#63
post #62
post #50

Earlier quoted context omitted.

You are correct in pointing out this error of the parent comment (by SiVal). Each ball is indeed the sum of "n-1" bernoulli RVs, and the CLT does apply to these sums. As btilly points out elsewhere, to actually obtain the correct limit, you have to normalize the sum correctly. Because of the way the scaling is done in this graphic, as you increase the number of levels, it's in effect normalizing the sum by dividing b…

Thanks for this explanation. I understood most of it but could you explain why you should normalize using 1/sqrt(n) and why doing so makes the result converge in distribution?

For a sequence of independent random variables with the same variance, X_1, X_2,..., we have

  var( (1/sqrt(n)) * (X_1 + X_2 + X_3 + ... X_n) 
    = (1/n) * (var(X_1) + var(X_2) + ... var(X_n))
    = (1/n) * n * var(X_1)
    = var(X_1)
This holds for any n, which means that, if you normalize by 1/sqrt(n) instead of 1/n, the "randomness" never vanishes even when n gets infinitely large. If you normalize by something bigger than 1/sqrt(n) the variance blows up, and if you normalize by something less than 1/sqrt(n), the variance collapses to zero so you get something concentrated at a single point.

The CLT tells us more than that, it actually tells us how the randomness is distributed when n gets very large, which is pretty remarkable when you think about it. (and it holds under much weaker conditions than what I mentioned above, it's just that those assumptions are probably the easiest to understand).

Re: The Central Limit Theorem Visualized with D3

#64
post #5

This isn't the central limit theorem. This is a binomial distribution. Nice animation though.

It does illustrate a special case of the CLT, in the sense that as the number of bins increases, the distribution (the mean of a bunch of +1/-1 Bernoulli random variables) converges to a normal distribution.

yes but the number of bins isn't increasing.

EDIT: nm, I saw where you can increase the bins.

Re: The Central Limit Theorem Visualized with D3

#65

This is not the Central Limit Theorem.

Really? I see a collection X1, X2, ..., XN of Bernoulli(0.5) variables and the demonstration that the distribution of their sum, normalized for variance, approaches the Gaussian distribution as N increases. Is that not a direct consequence of the CLT?

No, it is a property of Bernoulli trials. The distribution is a Binomial distribution, not a Normal distribution. They do, however, look similar http://en.wikipedia.org/wiki/File:Binomial_Distribution.svg

Re: The Central Limit Theorem Visualized with D3

#66
post #13

while i have the attention of HN, does anyone have suggestions on any other types of statistic visualizations?

Brownian motion remains Brownian motion at all scales if you scale correctly.

More specifically, if you take a rectangle of width 1/nth of your visualization box, height 1/sqrt(n)th of your visualization box, centered on the point of the walk in the middle of the box then zoom in, you get another random walk with the same statistical properties as the original.

Re: The Central Limit Theorem Visualized with D3

#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.

Re: The Central Limit Theorem Visualized with D3

#68
post #66
post #13

while i have the attention of HN, does anyone have suggestions on any other types of statistic visualizations?

Brownian motion remains Brownian motion at all scales if you scale correctly. More specifically, if you take a rectangle of width 1/nth of your visualization box, height 1/sqrt(n)th of your visualization box, centered on the point of the walk in the middle of the box then zoom in, you get another random walk with the same statistical properties as the original.

There is a gif of this at

http://en.wikipedia.org/wiki/Wiener_process#Self-similarity

which is rather nice.

If you get some infrastructure for making Brownian motion sample paths, another good one is that it crosses zero infinitely often in the neighborhood of the origin. Keep zooming in, and see more and more crossings. This is another instance of the scaling rule you mention, but it is neat to see.

Re: The Central Limit Theorem Visualized with D3

#69
post #13

while i have the attention of HN, does anyone have suggestions on any other types of statistic visualizations?

You could do a Poisson limit graphic. The result is at

http://en.wikipedia.org/wiki/Poisson_limit_theorem

Basically, you need a whole lot of events which occur in an essentially independent way, and each one is rare. You add up the number of events that happened, and it is approximately Poisson. Something like tossing 1000 marbles into a 100x100 tile floor, and counting the number of marbles that landed in some 10x10 tile area.

Re: The Central Limit Theorem Visualized with D3

#70
post #63
post #62

Earlier quoted context omitted.

Thanks for this explanation. I understood most of it but could you explain why you should normalize using 1/sqrt(n) and why doing so makes the result converge in distribution?

For a sequence of independent random variables with the same variance, X_1, X_2,..., we have var( (1/sqrt(n)) * (X_1 + X_2 + X_3 + ... X_n) = (1/n) * (var(X_1) + var(X_2) + ... var(X_n)) = (1/n) * n * var(X_1) = var(X_1) This holds for any n, which means that, if you normalize by 1/sqrt(n) instead of 1/n, the "randomness" never vanishes even when n gets infinitely large. If you normalize by something bigger than 1/sq…

Thanks a lot for the explanation.
Post reply on HN