# Illustrate the central limit theorem with Wolfram Language?

**URL:** <https://community.wolfram.com/t/illustrate-the-central-limit-theorem-with-wolfram-language/13206>\
**Category:** Questions\
**Tags:** graphics-and-visualization, statistics-and-probability\
**Created:** [October 18, 2018, 10:44pm UTC](https://community.wolfram.com/t/illustrate-the-central-limit-theorem-with-wolfram-language/13206 "2018-10-18T22:44:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![den14005](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@den14005](https://community.wolfram.com/u/den14005)\
**Post date:** [October 18, 2018, 10:44pm UTC](https://community.wolfram.com/t/illustrate-the-central-limit-theorem-with-wolfram-language/13206/1 "2018-10-18T22:44:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shenghuiy](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/shenghuiy/32/36073_2.png) [@shenghuiy](https://community.wolfram.com/u/shenghuiy)\
**Post date:** [October 19, 2018, 2:19am UTC](https://community.wolfram.com/t/illustrate-the-central-limit-theorem-with-wolfram-language/13206/2 "2018-10-19T02:19:11Z")

</div>

You can check this example: [http://demonstrations.wolfram.com/TheCentralLimitTheorem/](http://demonstrations.wolfram.com/TheCentralLimitTheorem/)

 ![clt.png](https://global.discourse-cdn.com/wolfram/original/3X/f/b/fb59fce179d09247847abc26abcfdd2911ce7a49.png)

---

<div class="post-metadata">

**Author:** ![murray](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/murray/32/39879_2.png) [@murray](https://community.wolfram.com/u/murray)\
**Post date:** [October 19, 2018, 8:02pm UTC](https://community.wolfram.com/t/illustrate-the-central-limit-theorem-with-wolfram-language/13206/3 "2018-10-19T20:02:26Z")

</div>

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]

```
