|
Boost Users : |
Subject: Re: [Boost-users] [Math] Bug in example code / doc (Binomial Distr.)
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-09-17 10:44:10
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]]
> On Behalf Of Ralf M.
> Sent: Monday, August 31, 2009 11:56 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] [Math] Bug in example code / doc (Binomial Distr.)
>
> On p.66 (Binomial distribution, "Binomial Quiz Example") of the
> Math Toolkit pdf-file, and also at
>
http://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_toolkit
/dist/stat_
> tut/weg/binom_eg/binomial_quiz_example.html
> it is written:
>
> "Probability of getting exactly 11 answers right by chance is 2.32831e-010"
>
> I think this is wrong. It rather should be one of these below:
>
> "Probability of getting exactly 11 answers right by chance is 0.000247132"
> or
> "Probability of getting exactly 16 answers right by chance is 2.32831e-010"
Sorry for delay in reply - I caught me just after setting off on holiday :-)
Guilty as charged :-(
If you agree this is better, it will now read:
Probability of getting none right is 0.0100226
Probability of getting exactly one right is 0.0534538
Probability of getting exactly two right is 0.133635
Probability of getting exactly 11 right is 0.000247132
Probability of getting exactly all 16 answers right by chance is 2.32831e-010
> I have'nt checked the underlying source code of this yet;
> ie. maybe it is only a doc error...
>
>
> And this code there seems IMHO to be problematic too:
> "
> int questions = 16; // All the questions in the quiz.
> int answers = 4; // Possible answers to each question.
> double success_fraction = (double)answers / (double)questions; // If a random
guess.
> // Caution: = answers / questions would be zero (because they are integers)!
> binomial quiz(questions, success_fraction);
> "
>
> Shouldn't the second param not simply be the constant p of each item, ie. here
0.25,
> even if # of questions is set to a different value, for example 32 ?
> Because 32 / 4, as done above, wouldn't be 0.25 anymore...
And this too could be improved. How about
/*`
The number of correct answers, X, is distributed as a binomial random variable
with binomial distribution parameters: questions n and success fraction
probability p.
So we construct a binomial distribution:
*/
int questions = 16; // All the questions in the quiz.
int answers = 4; // Possible answers to each question.
double success_fraction = 1. / answers; // If a random guess, p = 1/4 = 0.25.
binomial quiz(questions, success_fraction);
Thanks for reporting this.
Paul
PS commited to boost-sandbox\math_toolkit\libs\math\example Completed: At
revision: 56273
--- 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