Re: mathematica fit data to inverse gamma distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg117398] Re: mathematica fit data to inverse gamma distribution
- From: Peter <petsie at dordos.net>
- Date: Thu, 17 Mar 2011 06:32:19 -0500 (EST)
- References: <ilq6pf$bgh$1@smc.vnet.net>
On 16.03.2011 12:26, Alex wrote: > Hi, > > I am trying to obtain same figure that is provided in Mathematica's website related to fitting an inverse gamma to a dataset. Here is the code I enter: > > data1 = RandomVariate[InverseGammaDistribution[0.5, 3], 10^4]; > Show[ > Histogram[data1, {0, 20, 1}, "PDF"], > Plot[PDF[ > TruncatedDistribution[{0, 20}, InverseGammaDistribution[0.5, 3]], > x], {x, 0, 20}, PlotStyle -> Thick]] > > > and here is the error I receive: > > Histogram::hspec: The height specification PDF is not one of the named height functions or a function that can be used to compute the heights for each bin.>> > Show::"gcomb" : StyleBox[Could not combine the graphics objects in ..... > > I would appreciate anyone's help. > > Regards > > Alex > Hi Alex, as Plot has the attribute HoldAll, apply Evaluate to the PDF to avoid calling e.g. PDF[....,1.234] instead of PDF[...,x] while plotting: Plot[PDF[TruncatedDistribution[{0,20},InverseGammaDistribution[0.5,3]],x]//Evaluate,{x,0,20},PlotStyle->Thick]] works here. Peter