|
Boost Users : |
Subject: Re: [Boost-users] [math/distributions] calculating p-value?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2010-04-09 07:14:30
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Christian Meesters
> Sent: Friday, April 09, 2010 11:21 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] [math/distributions] calculating p-value?
>
> Hi,
>
> Having a test which values are chi^2-distributed, I tried to calculate a
> p-value and utterly failed.
>
> My code, so far:
>
> #include <boost/math/distributions/chi_squared.hpp>
> using boost::math::chi_squared;
>
> <snip>
> chi_squared dist(N - 1);
> p = cdf(complement(dist, (std::fabs(beta)))) ;
> Here, N is the sample size and beta my beta-estimate.
>
> Reading Numerical Recipies my approach might be a bit naive, yet is
> there any short hand using boost? (Or am I making a stupid mistake here?
Nothing obvious jumps out at me.
It appears you have seem the example at
boost_1_42_0\libs\math\example\chi_square_std_dev_test.cpp
and test_chi_squared.cpp has this very similar code
BOOST_CHECK_CLOSE( cdf(complement(dist, cs)), Q, tol);
and you have also seen the section in math.pdf on non-member properties, like cdf
and when to use complements and why.
Have you used a try'n'catch block around your call?
without this, if things go wrong it will end silently (no error messages!), and unhappily for you ;-)
See page 63 of math.pdf for some discussion and examples.
HTH
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow_at_[hidden]
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