
Boost : 
From: John Maddock (john_at_[hidden])
Date: 20070525 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:
http://freespace.virgin.net/boost.regex/toolkit/html/index.html and the
reviewcode can be downloaded from the Boost.Vault here:
http://boostconsulting.com/vault/index.php?&direction=0&order=&directory=Math%20%20Numerics
Alternatively the very latest code is available in the sandbox:
http://svn.boost.org/trac/boost/
Note that if you want the cdf of a Chisquared distribution then:
cdf(chi_squared(df), chisqr);
will better express what you want, and if you want the complement of that
(ie 1cdf), then:
cdf(complement(chi_squared(df), chisqr));
will do what you want.
There is a tutorial on the stats stuff here:
http://freespace.virgin.net/boost.regex/toolkit/html/math_toolkit/dist/stat_tut/overview.html
Along with some worked examples using the Chi Squared distribution here:
http://freespace.virgin.net/boost.regex/toolkit/html/math_toolkit/dist/stat_tut/weg/cs_eg.html
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/randomdistributions.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 :)
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk