Boost logo

Boost Users :

Subject: Re: [Boost-users] [distributions]: Inverse Gamma
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-08-04 11:32:00


>> Yes I truly have one ;) The inverse gamma distribution and its special
>> case, the scaled inverse chi-square 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_chi-square_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
scaled-inverse-chi-squared as well?

John.


Boost-users 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