|
Boost-Commit : |
From: pbristow_at_[hidden]
Date: 2007-09-21 07:46:06
Author: pbristow
Date: 2007-09-21 07:46:06 EDT (Fri, 21 Sep 2007)
New Revision: 39439
URL: http://svn.boost.org/trac/boost/changeset/39439
Log:
Source updated, minor changes to match
Text files modified:
sandbox/math_toolkit/libs/math/doc/distributions/negative_binomial_example.qbk | 62 +--------------------------------------
1 files changed, 3 insertions(+), 59 deletions(-)
Modified: sandbox/math_toolkit/libs/math/doc/distributions/negative_binomial_example.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/distributions/negative_binomial_example.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/distributions/negative_binomial_example.qbk 2007-09-21 07:46:06 EDT (Fri, 21 Sep 2007)
@@ -164,69 +164,13 @@
[section:negative_binomial_example1 Negative Binomial Sales Quota Example.]
-The example program
+This example program
[@../../example/negative_binomial_example1.cpp negative_binomial_example1.cpp (full source code)]
-demonstrates a simple use to find the probability of meeting a sale quota.
-
-Based on [@http://en.wikipedia.org/wiki/Negative_binomial_distribution
-a problem by Dr. Diane Evans,
-Professor of Mathematics at Rose-Hulman Institute of Technology].
-
-Pat is required to sell candy bars to raise money for the 6th grade field trip.
-There are thirty houses in the neighborhood,
-and Pat is not supposed to return home until five candy bars have been sold.
-So the child goes door to door, selling candy bars.
-At each house, there is a 0.4 probability (40%) of selling one candy bar
-and a 0.6 probability (60%) of selling nothing.
-
-What is the probability mass (density) function for selling the last (fifth)
-candy bar at the nth house?
-
-The Negative Binomial(r, p) distribution describes the probability of k failures
-and r successes in k+r Bernoulli(p) trials with success on the last trial.
-(A [@http://en.wikipedia.org/wiki/Bernoulli_distribution Bernoulli trial]
-is one with only two possible outcomes, success of failure,
-and p is the probability of success).
-Selling five candy bars means getting five successes, so successes r = 5.
-The total number of trials (n) in this case, houses visited) this takes is therefore
- = sucesses + failures or k + r = k + 5.
-The random variable we are interested in is the number of houses (k)
-that must be visited to sell five candy bars,
-so we substitute k = n - 5 into a negative_binomial(5, 0.4) mass (density) function
-and obtain the following mass (density) function of the distribution of houses (for n >= 5):
-Obviously, the best case is that Pat makes sales on all the first five houses.
-
-What is the probability that Pat finishes /on the tenth house/?
-
- f(10) = 0.1003290624, or about 1 in 10
-
-What is the probability that Pat finishes /on or before/ reaching the eighth house?
-
-To finish on or before the eighth house,
-Pat must finish at the fifth, sixth, seventh, or eighth house.
-Sum those probabilities:
-
- f(5) = 0.01024
- f(6) = 0.03072
- f(7) = 0.055296
- f(8) = 0.0774144
- sum {j=5 to 8} f(j) = 0.17367
-
-What is the probability that Pat exhausts all 30 houses in the neighborhood,
-and still doesn't sell the required 5 candy bars?
-
-1 - sum{j=5 to 30} f(j) = 1 - incomplete beta (p = 0.4)(5, 30-5+1) =~ 1 - 0.99849 = 0.00151 = 0.15%.
-
-See also [@ http://en.wikipedia.org/wiki/Bernoulli_distribution Bernoulli distribution]
-and [@http://www.math.uah.edu/stat/bernoulli/Introduction.xhtml Bernoulli applications].
-
-In this example, we will deliberately produce a variety of calculations
-and outputs to demonstrate the ways that the negative binomial distribution
-can be implemented with this library,
-and it is also deliberately over-commented.
+demonstrates a simple use to find the probability of meeting a sales quota.
[import ../../example/negative_binomial_example1.cpp]
[negative_binomial_eg1_1]
+[negative_binomial_eg1_2]
[endsect] [/section:negative_binomial_example1]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk