Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-05-25 12:02:26

John Ky wrote:
> Hi,
> 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: 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:

cdf(chi_squared(df), chisqr);

will better express what you want, and if you want the complement of that
(ie 1-cdf), then:

cdf(complement(chi_squared(df), chisqr));

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: 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, gregod at, cpdaniel at, john at