
Boost Users : 
Subject: Re: [Boostusers] [distributions]: Inverse Gamma
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 20100805 04:41:49
> Original Message
> From: boostusersbounces_at_[hidden] [mailto:boostusersbounces_at_[hidden]] On Behalf Of John Maddock
> Sent: Wednesday, August 04, 2010 4:32 PM
> To: boostusers_at_[hidden]
> Subject: Re: [Boostusers] [distributions]: Inverse Gamma
>
> >> Yes I truly have one ;) The inverse gamma distribution and its special
> >> case, the scaled inverse chisquare distribution, is the conjugate prior
> >> to the normal distribution variance parameter in Bayesian statistics.
> >> Pretty much as uncommon and unheard of as it is outside Bayes world [to
> >> the best of my knowledge], it's very much central to Bayesian stats and
> >> appears in every textbook right after the introduction chapter ;)
> >>
> >> http://en.wikipedia.org/wiki/Scaled_inverse_chisquare_distribution
> >> http://en.wikipedia.org/wiki/Conjugate_prior
> >>
> >> Hence I wonder it has not been requested so far  but being a Bayesian
> >> C++ / booster I definitely want / need it :).
> >>
> >> @John: Yes it is a transformation deviate of the gamma, and an easy so.
> >> And it should be fairly easy to implement IMHO.
> >
> > The pdf and pdf etc looks fairly straightforward (only uses exp, pow and
> > gamma?) so I might be persuaded to do these.
> > But the inverses (qhantiles) may prove more troublesome if have to be done
> > by brute force numerically
> >
> > R library does it numerically
> > http://rss.acs.unt.edu/Rdoc/library/pscl/html/igamma.html
> >
> >  or are there analytic expressions for these?
> >
> > Or can it use the inverse of the gamma distribution?
>
> Implementation would be the same as the gamma distro, all the information
> needed is on Wikipedia  cdf is simply:
>
> gamma_q(alpha, beta/x);
>
> so gamma_q_inv can be used for the quantile. PDF is just a call to
> gamma_p_derivative.
>
> >> Is contribution on my side expected (can be done just notice I am a
> >> [heavy !] user of the stats library only, not familiar with code /
> >> numerical stability issues).
> >
> > I'm not mathematician enough to deal with this  but I can deal with the
> > obfuscated code (by templating and policies) if
> > you can provide the equations.
> >
> > (And there is the question of testing  some parameters and value
> > combinations (preferably exact) are needed for sanity
> > and accuracy checks).
>
> Paul, I don't mind filling in the implementation details if you could take
> care of docs and tests  if that helps? Do we need the
> scaledinversechisquared as well?
John  I was just about to start to do the inverse gamma implementation  since it doesn't appear to need anything fancy
like root finding, it might just within my skill_set/pay_grade ;)
I'd need more guidance on the scaledinversechisquared (since we are doing an upgrade, it might be worth doing this
too).
But I'll certainly do the grunt work on docs and testing anyway.
Thomas  could you provide an *example* of using this distribution(s) for our docs?
(IMO this is especially important because the presentation of the distributions is unlike what your average FORTRAN or R
user would expect).
Paul
 Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow_at_[hidden]
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net