Message Boards Message Boards

Illustrate the central limit theorem with Wolfram Language?

Posted 5 years ago

My statistics teacher asked us to generate 100,000 samples of normal, exponential, and binomial distributions of size 1000 each. For each sample he wants us to calculate the mean (100,000 means) and draw a histogram of the 100,000 means. He also wants us to compute the the mean and standard deviation of the 100,000 means.

I'm not very experienced in Mathematica, does anyone know how to go about doing this?

POSTED BY: Joshua Denton
2 Replies

You say "the exponential distribution" and "the binomial distribution", but there are no such things: for each ? > 0 there is a corresponding exponential distribution having that parameter; and for each integer n > 0 and each real p between 0 and 1 there is a corresponding binomial distribution having n and p as its parameters.

That said, the basic idea is to use RandomVariate[dist[param1, param1,...], 1000] to generate a sample of size 1000 from the specified distribution dist with the specified parameters param1, param2, etc. (0 or more such parameters).

To do that 10000 time, you could use Table[..., 10000] and immediately map Mean onto it. For example:

      expMeans = Mean /@ Table[RandomVariate[ExponentialDistribution[1], 1000], 10000]

The mean and standard deviation of those means would then be given by:

     {Mean[expMeans], StandardDeviation[expMeans]}

or both together by:

     Through[{Mean, StandardDeviation}[expMeans]]

And for a histogram, you can either let Mathematica use its default bins or specify them yourself, e.g., by specifying the number of bins, as in:

      Histogram[expMeans, 100]
POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract