
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Christian Meesters Sent: Friday, April 09, 2010 11:21 AM To: boost-users@lists.boost.org 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
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@hetp.u-net.com