Message Boards Message Boards

Showing histogram and PDF of normal distribution in a plot?

Hi, How do I show complete normal distribution over its histogram?

list = {0.014952084292167656`, -0.0011142109478073092`, \
-0.03200699329376222`, 0.02610873317718504`, -0.007922259316024804`, 
   0.02329423863175964`, 
   0.0034785055449905455`, -0.007747760345867161`, 
   0.003986198148096087`, 
   0.031948672158741004`, -0.01922689853585434`, 0.0232439658404808`, 
   0.009156392455101026`, 0.05302010750555419`, 0.025142071231658958`,
    0.0116075829784546`, -0.001449418525741597`, 
   0.029618730201622007`, 
   0.005921508633949274`, -0.0180861548626976`, -0.00510255607675171`,
    0.018578990326231004`, 0.017420623630748748`, 
   0.003315652924846646`, 
   0.005526839598472583`, -0.023282105739082348`, 0.0474595471466141`,
    0.000629691585357639`, 0.005254308208282488`, 
   0.0323716812689209`, -0.007494270578567497`, \
-0.019957153216545107`, 0.0009755785364255892`, 0.012999416718997955`,
    0.016312600450492862`, -0.022726446137008666`, 
   0.007457557185943597`, -0.021121406314605712`, 
   0.020816311136428844`, 
   0.018826234340667714`, -0.026312034792572048`, 
   0.016020506724174488`, -0.06359624135386657`, \
-0.012528348147869107`, 0.018086951234972`, 
   0.0009406040330610273`, -0.010624625399940489`, 
   0.001383440169586178`, -0.03254843844527436`, \
-0.023731778793663033`, -0.029474470123107915`, 
   0.017707966601989755`, -0.011709554448547377`, \
-0.02584689544087218`, 0.010129309176322931`, -0.06913883297091293`, 
   0.017521978981166843`, 0.014526618114977838`, 
   0.038873448773523334`, -0.0259937403719101`, \
-0.020663881794158942`, 0.016251452890144347`, 0.019502766982261666`, 
   0.0248790234506836`, -0.029827586532714834`, 
   0.0028897048234939604`, -0.0015713386704406807`, \
-0.0029079686403274546`, -0.012514878168525697`, \
-0.004687818520397187`, -0.003439080581300734`, -0.00081486164625931`,
    0.009277975678443906`, -0.060646119527069095`, 
   0.007911314948852527`, -0.020871743782455432`, \
-0.034051828420303354`, -0.018067103608901985`, \
-0.019255875162330627`, -0.03503792834281921`, -0.035022689569067`, 
   0.0060782724170112615`, 
   0.04824767377845382`, -0.03138784995280075`, 
   0.006499843955039969`, -0.01786340096987915`, 0.02081189918518067`,
    0.01398221559014895`, -0.03275392018168641`, 0.02883601571673583`,
    0.05740358064871215`, -0.0009542576516227697`, 
   0.07298482561545772`};

fitDist = 
 EstimatedDistribution[list, NormalDistribution[\[Alpha], \[Beta]], 
  ParameterEstimator -> MethodOfMoments]

Show[Histogram[list, Automatic, PDF], 
 Plot[Evaluate@PDF[fitDist][x], {x, 0, 15}, 
  PlotStyle -> Directive[Blue, Thick], Filling -> Axis]]
POSTED BY: M.A. Ghorbani
4 Replies
Posted 1 month ago

Sometimes the PDF is plotted at different scale and even cropped.

mle = FindDistributionParameters[newresults, 
  NormalDistribution[\[Mu], \[Sigma]], 
  ParameterEstimator -> "MaximumLikelihood"]
Show[Histogram[results, "FreedmanDiaconis", "PDF"], ![enter image description here][1]
 Plot[PDF[NormalDistribution[\[Mu], \[Sigma]] /. mle, x], {x, 
   Min[newresults], Max[newresults]}]]

enter image description here

POSTED BY: Amen Bargees
Posted 1 month ago

I'm not understanding or believing what you mean by "Sometimes the PDF is plotted at different scale...." Could you give an example?

Also, adding "PlotRange -> All" will fix any cropping of the PDF.

POSTED BY: Jim Baldwin

Hello Mohammad, this is probably what you want:

fitDist = EstimatedDistribution[list, NormalDistribution[\[Alpha], \[Beta]], ParameterEstimator -> "MethodOfMoments"];
Show[Histogram[list, Automatic, "PDF"], 
 Plot[PDF[fitDist][x], {x, -.1, .1}, PlotStyle -> Directive[Blue, Thick], Filling -> Axis]]

enter image description here

POSTED BY: Henrik Schachner

Thank you, Henrik.

POSTED BY: M.A. Ghorbani
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract