Message Boards Message Boards

5 Replies
7 Total Likes
View groups...
Share this post:

Plotting pdf of NormalDistribution

Posted 10 years ago
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.
 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];
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?
POSTED BY: Erik Sorensen
5 Replies
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.
POSTED BY: Sean Clarke
Hi. This is the graphic that is produced by your code on my machine:

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:
NIntegrate[PDF[NormalDistribution[a, b] /. params, x], {x, -Infinity, Infinity}]
POSTED BY: Sean Clarke
@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: 

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:  
PlotLabel->Row[{"slope at x=0: ",PDF[NormalDistribution[0,\[Sigma]],0] }],AspectRatio-> 0.5],
POSTED BY: Shenghui Yang
Posted 10 years ago
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
POSTED BY: Erik Sorensen
Posted 10 years ago
Of course. My bad.Thank you very much
POSTED BY: Erik Sorensen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract