From: John Maddock (john_at_[hidden])
Date: 2007-05-25 12:02:26
John Ky wrote:
> I'm trying to upgrade some software to use boost 1.34 from an earlier
> version, but I'm stuck on this particular function because I don't
> understand statistics.
> #include <boost/integer.hpp>
> #include <boost/random/gamma_distribution.hpp>
> inline double alpha_value(int df, double chisq)
> if (chisq < 0.0 || df < 1)
> return 0.0;
> return boost::math::gamma_Q(((double)df) / 2.0, chisq / 2.0);
> Does anyone know the equivalent way of doing this in 1.34?
The gamma_q function is part of the recently reviewed Math Toolkit: it's
been accepted as part of Boost, but hasn't yet made it as far as cvs never
mind a release (Paul and I are working on the final touches now).
Documentation is available online here:
http://freespace.virgin.net/boost.regex/toolkit/html/index.html and the
review-code can be downloaded from the Boost.Vault here:
Alternatively the very latest code is available in the sandbox:
Note that if you want the cdf of a Chi-squared distribution then:
will better express what you want, and if you want the complement of that
(ie 1-cdf), then:
will do what you want.
There is a tutorial on the stats stuff here:
Along with some worked examples using the Chi Squared distribution here:
Of course if what you want is a random number, then you can do that with the
existing Boost.Random library, docs here:
http://www.boost.org/libs/random/random-distributions.html but appear to be
wildly out of date and don't mention most of the distributions that are
supported :-( You should be able to get the general idea from here though.
Hopefully this will point you in the right direction :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk