# Boost Users :

Subject: Re: [Boost-users] Newbie math question - roots of a distribution
Date: 2014-02-07 05:07:33

> But now I'd like to find the root of the cdf, in other words, I want to find the value of successprob, from numbertrials and numbersuccesses and ans.
>
> Let's define ans as 0.95, by finding the root of cdf(mydistribution, numbersuccesses) - 1, using a root finding algorithm, I should be able to get the value of successprob. I've tried reading the roots documentation and looking at some examples but they use simple functions like x * sin(x) - there is only one variable and it is x, the binomial cdf has quite a few variables - number of trials, number of successes, probability of a single success. How can I define a function with boost::math::binomial that could be used with boosts root libraries to find the probability of success from the cdf, given I know ans, the number of successes, and the number of trials?

You want the quantile:
http://www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/dist_ref/nmp.html#math_toolkit.dist_ref.nmp.quantile
also known as the inverse cdf or the percent point function. Example of
use:
http://www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/stat_tut/weg/st_eg/tut_mean_intervals.html

HTH, John.