1
$\begingroup$
data = RandomVariate[BetaDistribution[1, 3], 1000];
plot = Show[
  Histogram[data, Automatic, "PDF", PlotLabel -> "\[Gamma]", 
   GridLines -> {{{Mean[data], Directive[Opacity[1], Thick, Blue]}}, 
     None}, Method -> {"GridLinesInFront" -> True}], 
  Plot[PDF[GammaDistribution[0.25, 0.1], x], {x, 0.001, 1}, 
   PlotStyle -> Red]]

The histogram we obtain, is enter image description here

I think the problem is that the gamma density increases very rapidly as we come closer to zero. Is there a way to somehow solve this?

$\endgroup$
1
$\begingroup$

You could try to add some PlotRange, e.g.:

plot = Show[
Histogram[data, Automatic, "PDF", PlotLabel -> "\[Gamma]", 
GridLines -> {{{Mean[data], Directive[Opacity[1], Thick, Blue]}},None},
Method -> {"GridLinesInFront" -> True}], 
Plot[PDF[GammaDistribution[0.25, 0.1], x], {x, 0.001, 1}, 
PlotStyle -> Red, PlotRange -> {{0, 0.9}, {0, 4}}]]

Which results to a plot such as this:

enter image description here

$\endgroup$
1
$\begingroup$

You can also add PlotRange -> All to Plot and PlotRange -> Automatic to Show to get

Show[
  Histogram[data, Automatic, "PDF", PlotLabel -> "γ", 
     GridLines -> {{{Mean[data], Directive[Opacity[1], Thick, Blue]}},  None}, 
     Method -> {"GridLinesInFront" -> True}], 
  Plot[PDF[GammaDistribution[0.25, 0.1], x], {x, 0.001, 1}, 
    PlotStyle -> Red, 
    PlotRange -> All], 
  PlotRange -> Automatic]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.