Boost logo

Boost Users :

Subject: Re: [Boost-users] [math/distributions] calculating p-value?
From: Christian Meesters (meesters_at_[hidden])
Date: 2010-04-09 10:16:05


Thanks Paul.

Actually I didn't read the testing sources. However, are the links to
the math.pdf broken? (Perhaps it's just me, who cannot download this pdf
right now. Or I just have a bad day ...)

The solution: I did indeed make a most stupid mistake: When you
miscalculate N, the distribution you compare against is wrong and in the
extreme, you get only zeros back (which happend to me). Arrgh!
*headbang* ;-)

Thanks,
Christian

On Fri, 2010-04-09 at 12:14 +0100, Paul A. Bristow wrote:
> > -----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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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