[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_too... 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" I have'n 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...
Math Toolkit pdf-file, and also at http://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_too... 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"
I have'n 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...
I'll investigate as soon as I can, but I'm going to be offline now for a while... Paul Bristow might be able to answer this one though... Paul? HTH, John.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ralf M. Sent: Monday, August 31, 2009 11:56 PM To: boost-users@lists.boost.org 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_too... /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@hetp.u-net.com
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of John Maddock Sent: Friday, September 18, 2009 11:25 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Math] Bug in example code / doc (Binomial Distr.)
PS commited to boost-sandbox\math_toolkit\libs\math\example Completed: At revision: 56273
Thanks Paul, will merge to Trunk when I get organized here (also back from 2 weeks away).
Fine - sorry about the silly mistake(s). Commiserations about the builders - you may nobody to blame but yourself (or Senior Management?) ;-) Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com
participants (3)
-
John Maddock
-
Paul A. Bristow
-
Ralf M.