# Plotting pdf of NormalDistribution

**URL:** <https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916>\
**Category:** Questions\
**Tags:** mathematica, statistics-and-probability\
**Created:** [November 20, 2013, 4:49pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916 "2013-11-20T16:49:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![esorensenprivate](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/esorensenprivate/32/6029_2.png) [@esorensenprivate](https://community.wolfram.com/u/esorensenprivate)\
**Post date:** [November 20, 2013, 4:49pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/1 "2013-11-20T16:49:54Z")

</div>

Hi!  
I’m a have a list of probabilities from several simulations, as seen in list “userverrun9” in the MCode underneath. I want to fit this to a NormalDistribution, and plot the pdf with the 60 and 90% confidence intervals shown.

```auto
userverrun9 = {0.151314,0.155109,0.155837,0.157631,0.158213,0.159777,0.160848,0.16156,0.162517,0.162942,0.162966,0.163466,0.163672,0.163716,0.163841,0.163876,0.164474,0.16485,0.165367,0.165436,0.166677,0.167021,0.167072,0.167111,0.16783,0.167855,0.1681,0.168137,0.16832,0.168426,0.168494,0.168723,0.169853,0.17026,0.170391,0.170712,0.170767,0.170769,0.170789,0.170977,0.171079,0.171207,0.17152,0.171907,0.172012,0.172036,0.172096,0.172326,0.172772,0.172895,0.173225,0.173404,0.173443,0.173512,0.173557,0.173662,0.173721,0.173988,0.174039,0.174173,0.174323,0.174377,0.174517,0.174596,0.175454,0.176267,0.176315,0.176661,0.176741,0.176803,0.177098,0.17766,0.177872,0.178248,0.178344,0.178416,0.178542,0.178612,0.178999,0.179264,0.179411,0.179781,0.180354,0.180354,0.181226,0.181374,0.182026,0.182036,0.182181,0.182481,0.183157,0.183564,0.184894,0.185679,0.186181,0.187088,0.187338,0.187698,0.18772,0.189162,0.192061};
params = FindDistributionParameters[userverrun9, 
  NormalDistribution[a, b]];
NDPlotServer9 = 
  Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.14, 0.21}, 
   PlotRange -> {0, 50}, PlotStyle -> Thick];
NDPlotServer990 = 
  Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.1596, 
    0.18621}, Filling -> Axis, PlotStyle -> Thick];
NDPlotServer960 = 
  Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.166154, 
    0.186209}, Filling -> Axis, PlotStyle -> Thick];
Show[
 Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.14, 0.21}, 
  PlotRange -> {0, 50}, PlotStyle -> Thick],
 Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.1596, 
   0.18621}, Filling -> Axis, FillingStyle -> LightBlue, 
  PlotStyle -> Thick, PlotRange -> {0, 50}],
 Plot[PDF[NormalDistribution[a, b] /. params, x], {x, 0.166154, 
   0.179731}, Filling -> Axis, FillingStyle -> Gray, 
  PlotStyle -> Thick, PlotRange -> {0, 50}]

```

The plot I get out is not what I expected. The Y axis that should show the f\_X(x) is not correct, and the pdf doesn’t satisfy that the integration from -infinity to infinity should equal 1. What have I done wrong?

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [November 20, 2013, 5:07pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/2 "2013-11-20T17:07:43Z")

</div>

Hi. This is the graphic that is produced by your code on my machine:

 ![pdfexample.png](https://global.discourse-cdn.com/wolfram/original/2X/e/e7496132ea5530d5333a508dc8ad24713c11774e.png)

Please let me know what you would like to change about this. I am not sure I understand your question.

The PDF here does integrate to 1:

```auto
NIntegrate[PDF[NormalDistribution[a, b] /. params, x], {x, -Infinity, Infinity}]

```

---

<div class="post-metadata">

**Author:** ![esorensenprivate](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/esorensenprivate/32/6029_2.png) [@esorensenprivate](https://community.wolfram.com/u/esorensenprivate)\
**Post date:** [November 20, 2013, 5:29pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/3 "2013-11-20T17:29:39Z")

</div>

The way I understand this: The plot should show the pdf, and therefore, the integrate of the plotted graph should equal to 1 if integrated from -infinity to infinity. Therefore, the y-axis should show values below 1.0

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [November 20, 2013, 5:51pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/4 "2013-11-20T17:51:38Z")

</div>

This is a misunderstanding about PDFs and probabilities. A PDF doesn’t give the probability of an event happening, it gives the probility density. Probabilities can’t be greater than 1. Probability densities can be greater than 1.

If you have a Discrete PDF representing the frequency of different events, then the PDF must always remain under 1. This is because it is impossible for an event to happen with a probability greater than 1.

This is not true with PDFs in general (continous PDFS). It is possible for a PDF to go above 1. It is possible for a function to go above 1 and for its integral from -Infinity to Infinity to equal 1. An example is the PDF in your example. Another example would be the PDF that is equal to 0 everywhere except from 0 to 1/2 where it is equal to 2. The area under this PDF is 1 and it is a valid PDF.

From what I can see, everything is working correctly here.

---

<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:** [November 21, 2013, 3:56am UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/5 "2013-11-21T03:56:27Z")

</div>

@Sean gives a very clear point of the result.

@Erik, you can try a very simple example to give yourself a feeling of Sean’s explanation. For contiunous distribution with single random variable, roughly speaking we have PDF = Derivative of CDF = a slope. Take a look at the example:

 ![ScreenShot2013-11-20at9.53.03PM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/9/69e8d9dd3bedeaf681b7b57547947b8edf518936.png)

When the variance gets super small, the curve becomes very steep, which makes sense that most observation would be around mean value, say, in a random number generator. Equivalently speaking, when you scan the sample space from left to right you would not have much observation until you become close to the mean value.Same thing afterwards. You can see that nothing specifically prevents the slope/PDF from going to very high number, eg, the change can be very abrupt for tiny deviation.

copyable code:

```auto
Manipulate[
Plot[CDF[NormalDistribution[0,\[Sigma]],x],{x,-5,5},
PlotLabel->Row[{"slope at x=0: ",PDF[NormalDistribution[0,\[Sigma]],0] }],AspectRatio-> 0.5],
{\[Sigma],0.1,1}]

```

---

<div class="post-metadata">

**Author:** ![esorensenprivate](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/esorensenprivate/32/6029_2.png) [@esorensenprivate](https://community.wolfram.com/u/esorensenprivate)\
**Post date:** [November 21, 2013, 6:35pm UTC](https://community.wolfram.com/t/plotting-pdf-of-normaldistribution/916/6 "2013-11-21T18:35:01Z")

</div>

Of course. My bad.Thank you very much
