4
$\begingroup$

I'm working on this question is from Wolfram Mathematica online course. I tried my best to find the answer, still not getting it right

The question is:

Make a list of histograms of 10000 instances of totals of n random reals up to 100, with n going from 1 to 5 (illustrating the central limit theorem)

The Central limit theorem states that (From Wikipedia)

In probability theory, the central limit theorem (CLT) establishes that, in many situations, for identically distributed independent samples, the standardized sample mean tends towards the standard normal distribution even if the original variables themselves are not normally distributed.

I have tried this

Table[Histogram[RandomReal[n*100, 10000]], {n, 5}]

enter image description here

But one would expect the Histogram become more of a Gaussian.

$\endgroup$
4
  • $\begingroup$ Please load Mathematica code showing what you have tried so far. $\endgroup$
    – Syed
    Commented Feb 24, 2023 at 9:18
  • $\begingroup$ @Syed sorry my bad :"") $\endgroup$
    – Ratheesh
    Commented Feb 24, 2023 at 9:23
  • 1
    $\begingroup$ @Ratheesh I have edited your question to improve it. Next time, please do a better effort when crafting your questions. Show some diligence, share your code, and outputs. Explain what is the problem, what makes your output different from the expected output. There is still room from improvement, if you shared what you found on the site and documentation and why is that not enough to solve your problem. $\endgroup$
    – rhermans
    Commented Feb 24, 2023 at 10:08
  • $\begingroup$ @rhermans thank you soo much for the advice. i'll improve myself $\endgroup$
    – Ratheesh
    Commented Feb 24, 2023 at 15:36

1 Answer 1

7
$\begingroup$

You need to generate 10000 sums of n random numbers and make a histogram of these sums. In your code you just sum up 10000 uniformly distributed random numbers 5 times.

With the corrected code below you can see that for increasing n the distribution approaches the normal distribution as stated by the central limit theorem.

Table[
    Histogram[
        Table[
            Total[
                RandomReal[100, n] (* generate n random numbers in the interval [0, 100] *)
            ] (* sum these n numbers *)
        , 10000] (* do this 10000 times *)
    ] (* make a historgram of these 10000 summed values *)
, {n, 1, 5}] (* generate histograms with n in {1, 2, 3, 4, 5} *)

enter image description here

PS: A very illustrative post about the central limit theorem can also be found over on stackoverflow.

$\endgroup$
3
  • 3
    $\begingroup$ I updated the answer, now you see that with increasing n the distribution approaches the normal distribution as stated by the central limit theorem $\endgroup$
    – Mathias
    Commented Feb 24, 2023 at 9:58
  • 1
    $\begingroup$ thanks for the change. Now it does illustrate the CLT. Probably you could add the explanation to your answer, and why the OP's solution didn't work. (+1) $\endgroup$
    – rhermans
    Commented Feb 24, 2023 at 10:11
  • $\begingroup$ Thanks for improving your answer! $\endgroup$
    – rhermans
    Commented Feb 24, 2023 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.