Newbie math question - roots of a distribution
Hi Boost list,
I've just installed and started to use boost for various problems and I've hit on a math problem I'd like to solve with it but I'm unsure on how to achieve it.
I've gone through the documentation and have worked out how to easily compute the value from a cdf of a binomial distribution:
#include
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_re... 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_tu... HTH, John.
Hi, I'm not sure this is right, since the inverse cdf: returns a value x such that cdf(dist(N,p), x) == P. I'm trying to find 'p'. And if I understand it correctly the examples of the inverse cdf still have to specify p first. Best, Ben. ________________________________________ From: Boost-users [boost-users-bounces@lists.boost.org] on behalf of John Maddock [boost.regex@virgin.net] Sent: 07 February 2014 10:07 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Newbie math question - roots of a distribution
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_re... 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_tu... HTH, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'm not sure this is right, since the inverse cdf: returns a value x such that cdf(dist(N,p), x) == P.
I'm trying to find 'p'. And if I understand it correctly the examples of the inverse cdf still have to specify p first.
Apologies I read your post too quickly - if you want the success faction then see http://www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/dist_re... and www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/dist_ref/dists/binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.lower_bound_on_the_success_fract Pay particular attention to the different methods used and the linked references and discussions as some methods are particular adept at returning "wrong" answers. Hopefully I've answered the question you actually asked this time ;-) John.
participants (2)
-
Benjamin Ward (ENV)
-
John Maddock