Mathematica Simulating Normal Distribution in Mathematica: Histogram and PDF Plotting

Click For Summary
To simulate a normal distribution in Mathematica using the central limit theorem, one can sum multiple uniform random variables generated by RandomReal[]. To visualize the results, it's essential to plot both the histogram of the generated data and the Gaussian probability density function on the same graph. The key to achieving this is using the Show function, which allows for the combination of multiple graphics elements. An example command is provided, demonstrating how to overlay a histogram of normally distributed random variables with a separate plot, although the example incorrectly uses Sin[x] instead of the Gaussian function. Correcting this will yield the desired visualization of the normal distribution alongside the histogram.
Sam_Goldberg
Messages
46
Reaction score
1
Hi guys,

On my homework, I'm simulating a normal distribution on Mathematica by adding up a bunch of RandomReal[] , that is, uniform(0,1) random variables, and using the central limit theorem. I would like to plot both the histogram and the actual Gaussian probability density function on the same graph, but it does not seem that I'm able to use both the Histogram and Plot functions at the same time. How should I do this? Thanks.
 
Physics news on Phys.org
You use "Show" to show multiple graphics at a time:

Show[Histogram[RandomReal[NormalDistribution[0, 1], 200]], Plot[Sin[x], {x, -6 Pi , 6 Pi}]]
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
616
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K