From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../math_toolkit/dist_ref/dist_algorithms.html | 136 ++ .../math/doc/html/math_toolkit/dist_ref/dists.html | 104 ++ .../math_toolkit/dist_ref/dists/arcine_dist.html | 642 +++++++++ .../dist_ref/dists/bernoulli_dist.html | 356 +++++ .../math_toolkit/dist_ref/dists/beta_dist.html | 622 +++++++++ .../math_toolkit/dist_ref/dists/binomial_dist.html | 908 ++++++++++++ .../math_toolkit/dist_ref/dists/cauchy_dist.html | 305 ++++ .../dist_ref/dists/chi_squared_dist.html | 411 ++++++ .../html/math_toolkit/dist_ref/dists/exp_dist.html | 328 +++++ .../math_toolkit/dist_ref/dists/extreme_dist.html | 331 +++++ .../html/math_toolkit/dist_ref/dists/f_dist.html | 434 ++++++ .../math_toolkit/dist_ref/dists/gamma_dist.html | 364 +++++ .../dist_ref/dists/geometric_dist.html | 841 +++++++++++ .../dist_ref/dists/hyperexponential_dist.html | 1460 ++++++++++++++++++++ .../dist_ref/dists/hypergeometric_dist.html | 339 +++++ .../dist_ref/dists/inverse_chi_squared_dist.html | 471 +++++++ .../dist_ref/dists/inverse_gamma_dist.html | 367 +++++ .../dist_ref/dists/inverse_gaussian_dist.html | 445 ++++++ .../math_toolkit/dist_ref/dists/laplace_dist.html | 360 +++++ .../math_toolkit/dist_ref/dists/logistic_dist.html | 298 ++++ .../dist_ref/dists/lognormal_dist.html | 330 +++++ .../math_toolkit/dist_ref/dists/nc_beta_dist.html | 484 +++++++ .../dist_ref/dists/nc_chi_squared_dist.html | 572 ++++++++ .../math_toolkit/dist_ref/dists/nc_f_dist.html | 410 ++++++ .../math_toolkit/dist_ref/dists/nc_t_dist.html | 566 ++++++++ .../dist_ref/dists/negative_binomial_dist.html | 883 ++++++++++++ .../math_toolkit/dist_ref/dists/normal_dist.html | 325 +++++ .../html/math_toolkit/dist_ref/dists/pareto.html | 350 +++++ .../math_toolkit/dist_ref/dists/poisson_dist.html | 330 +++++ .../html/math_toolkit/dist_ref/dists/rayleigh.html | 347 +++++ .../dist_ref/dists/skew_normal_dist.html | 498 +++++++ .../dist_ref/dists/students_t_dist.html | 430 ++++++ .../dist_ref/dists/triangular_dist.html | 446 ++++++ .../math_toolkit/dist_ref/dists/uniform_dist.html | 367 +++++ .../math_toolkit/dist_ref/dists/weibull_dist.html | 369 +++++ .../math/doc/html/math_toolkit/dist_ref/nmp.html | 706 ++++++++++ 36 files changed, 16935 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dist_algorithms.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/arcine_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/bernoulli_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/beta_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/binomial_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/cauchy_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/chi_squared_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/exp_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/extreme_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/f_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/gamma_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/geometric_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hyperexponential_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_chi_squared_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gamma_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gaussian_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/laplace_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/logistic_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/lognormal_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_beta_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_chi_squared_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_f_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_t_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/negative_binomial_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/normal_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/pareto.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/poisson_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/rayleigh.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/skew_normal_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/students_t_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/triangular_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/uniform_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/dists/weibull_dist.html create mode 100644 boost/libs/math/doc/html/math_toolkit/dist_ref/nmp.html (limited to 'boost/libs/math/doc/html/math_toolkit/dist_ref') diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dist_algorithms.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dist_algorithms.html new file mode 100644 index 00000000..f94fdc94 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dist_algorithms.html @@ -0,0 +1,136 @@ + + + +Distribution Algorithms + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Finding + the Location and Scale for Normal and similar distributions +
+

+ Two functions aid finding location and scale of random variable z to give + probability p (given a scale or location). Only applies to distributions + like normal, lognormal, extreme value, Cauchy, (and symmetrical triangular), + that have scale and location properties. +

+

+ These functions are useful to predict the mean and/or standard deviation + that will be needed to meet a specified minimum weight or maximum dose. +

+

+ Complement versions are also provided, both with explicit and implicit (default) + policy. +

+
using boost::math::policies::policy; // May be needed by users defining their own policies.
+using boost::math::complement; // Will be needed by users who want to use complements.
+
+
+ + find_location + function +
+
#include <boost/math/distributions/find_location.hpp>
+
namespace boost{ namespace math{
+
+template <class Dist, class Policy> // explicit error handling policy
+  typename Dist::value_type find_location( // For example, normal mean.
+  typename Dist::value_type z, // location of random variable z to give probability, P(X > z) == p.
+  // For example, a nominal minimum acceptable z, so that p * 100 % are > z
+  typename Dist::value_type p, // probability value desired at x, say 0.95 for 95% > z.
+  typename Dist::value_type scale, // scale parameter, for example, normal standard deviation.
+  const Policy& pol);
+
+template <class Dist>  // with default policy.
+  typename Dist::value_type find_location( // For example, normal mean.
+  typename Dist::value_type z, // location of random variable z to give probability, P(X > z) == p.
+  // For example, a nominal minimum acceptable z, so that p * 100 % are > z
+  typename Dist::value_type p, // probability value desired at x, say 0.95 for 95% > z.
+  typename Dist::value_type scale); // scale parameter, for example, normal standard deviation.
+
+  }} // namespaces
+
+
+ + find_scale + function +
+
#include <boost/math/distributions/find_scale.hpp>
+
namespace boost{ namespace math{
+
+template <class Dist, class Policy>
+  typename Dist::value_type find_scale( // For example, normal mean.
+  typename Dist::value_type z, // location of random variable z to give probability, P(X > z) == p.
+  // For example, a nominal minimum acceptable weight z, so that p * 100 % are > z
+  typename Dist::value_type p, // probability value desired at x, say 0.95 for 95% > z.
+  typename Dist::value_type location, // location parameter, for example, normal distribution mean.
+  const Policy& pol);
+
+ template <class Dist> // with default policy.
+   typename Dist::value_type find_scale( // For example, normal mean.
+   typename Dist::value_type z, // location of random variable z to give probability, P(X > z) == p.
+   // For example, a nominal minimum acceptable z, so that p * 100 % are > z
+   typename Dist::value_type p, // probability value desired at x, say 0.95 for 95% > z.
+   typename Dist::value_type location) // location parameter, for example, normal distribution mean.
+}} // namespaces
+
+

+ All argument must be finite, otherwise domain_error + is called. +

+

+ Probability arguments must be [0, 1], otherwise domain_error + is called. +

+

+ If the choice of arguments would give a negative scale, domain_error + is called, unless the policy is to ignore, when the negative (impossible) + value of scale is returned. +

+

+ Find Mean and standard + deviation examples gives simple examples of use of both find_scale + and find_location, and a longer example finding means and standard deviations + of normally distributed weights to meet a specification. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists.html new file mode 100644 index 00000000..fbd6decc --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists.html @@ -0,0 +1,104 @@ + + + +Distributions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/arcine_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/arcine_dist.html new file mode 100644 index 00000000..4b6fc238 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/arcine_dist.html @@ -0,0 +1,642 @@ + + + +Arcsine Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/arcsine.hpp>
+
namespace boost{ namespace math{
+
+ template <class RealType = double,
+           class Policy   = policies::policy<> >
+class arcsine_distribution;
+
+typedef arcsine_distribution<double> arcsine; // double precision standard arcsine distribution [0,1].
+
+template <class RealType, class Policy>
+class arcsine_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor from two range parameters, x_min and x_max:
+   arcsine_distribution(RealType x_min, RealType x_max);
+
+   // Range Parameter accessors:
+   RealType x_min() const;
+   RealType x_max() const;
+};
+}} // namespaces
+
+

+ The class type arcsine_distribution + represents an arcsine + probability + distribution function. The arcsine distribution is named because + its CDF uses the inverse sin-1 or arcsine. +

+

+ This is implemented as a generalized version with support from x_min + to x_max providing the 'standard arcsine distribution' + as default with x_min = 0 and x_max = 1. + (A few make other choices for 'standard'). +

+

+ The arcsine distribution is generalized to include any bounded support + a <= x <= b by Wolfram + and Wikipedia, + but also using location and scale + parameters by Virtual + Laboratories in Probability and Statistics Arcsine + distribution. The end-point version is simpler and more obvious, + so we implement that. If desired, this + outlines how the Beta + Distribution can be used to add a shape factor. +

+

+ The probability + density function PDF for the arcsine + distribution defined on the interval [x_min, x_max] + is given by: +

+

+     f(x; x_min, x_max) = 1 /(π⋅√((x - x_min)⋅(x_max - x_min)) +

+

+ For example, Wolfram Alpha + arcsine distribution, from input of +

+
N[PDF[arcsinedistribution[0, 1], 0.5], 50]
+
+

+ computes the PDF value +

+
0.63661977236758134307553505349005744813783858296183
+
+

+ The Probability Density Functions (PDF) of generalized arcsine distributions + are symmetric U-shaped curves, centered on (x_max - x_min)/2, + highest (infinite) near the two extrema, and quite flat over the central + region. +

+

+ If random variate x is x_min + or x_max, then the PDF is infinity. If random variate + x is x_min then the CDF is zero. + If random variate x is x_max + then the CDF is unity. +

+

+ The 'Standard' (0, 1) arcsine distribution is shown in blue and some generalized + examples with other x ranges. +

+

+ +

+

+ The Cumulative Distribution Function CDF is defined as +

+

+     F(x) = 2⋅arcsin(√((x-x_min)/(x_max - x))) / π +

+

+ +

+
+ + Constructor +
+
arcsine_distribution(RealType x_min, RealType x_max);
+
+

+ constructs an arcsine distribution with range parameters x_min + and x_max. +

+

+ Requires x_min < x_max, otherwise domain_error + is called. +

+

+ For example: +

+
arcsine_distribution<> myarcsine(-2, 4);
+
+

+ constructs an arcsine distribution with x_min = -2 + and x_max = 4. +

+

+ Default values of x_min = 0 and x_max = + 1 and a typedef arcsine_distribution<double> arcsine; + mean that +

+
arcsine as;
+
+

+ constructs a 'Standard 01' arcsine distribution. +

+
+ + Parameter + Accessors +
+
RealType x_min() const;
+RealType x_max() const;
+
+

+ Return the parameter x_min or x_max + from which this distribution was constructed. +

+

+ So, for example: +

+
using boost::math::arcsine_distribution;
+
+arcsine_distribution<> as(2, 5); // Cconstructs a double arcsine distribution.
+assert(as.x_min() == 2.);  // as.x_min() returns 2.
+assert(as.x_max() == 5.);   // as.x_max()  returns 5.
+
+
+ + Non-member + Accessor Functions +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The formulae for calculating these are shown in the table below, and at + Wolfram + Mathworld. +

+
+ + + + + +
[Note]Note

+ There are always two values for the + mode, at x_min + and at x_max, default 0 and 1, so instead we raise + the exception domain_error. + At these extrema, the PDFs are infinite, and the CDFs zero or unity. +

+
+ + Applications +
+

+ The arcsine distribution is useful to describe Random + walks, (including drunken walks) Brownian + motion, Weiner + processes, Bernoulli + trials, and their appplication to solve stock market and other + ruinous gambling + games. +

+

+ The random variate x is constrained to x_min + and x_max, (for our 'standard' distribution, 0 and + 1), and is usually some fraction. For any other x_min + and x_max a fraction can be obtained from x + using +

+

+   fraction = (x - x_min) / (x_max - x_min) +

+

+ The simplest example is tossing heads and tails with a fair coin and modelling + the risk of losing, or winning. Walkers (molecules, drunks...) moving left + or right of a centre line are another common example. +

+

+ The random variate x is the fraction of time spent + on the 'winning' side. If half the time is spent on the 'winning' side + (and so the other half on the 'losing' side) then x = 1/2. +

+

+ For large numbers of tosses, this is modelled by the (standard [0,1]) arcsine + distribution, and the PDF can be calculated thus: +

+
std::cout << pdf(as, 1. / 2) << std::endl; // 0.637
+// pdf has a minimum at x = 0.5
+
+

+ From the plot of PDF, it is clear that x = ½ is the + minimum of the curve, so this is the + least likely scenario. (This is highly + counter-intuitive, considering that fair tosses must eventually + become equal. It turns out that eventually is not + just very long, but infinite!). +

+

+ The most likely scenarios are towards + the extrema where x = 0 or x + = 1. +

+

+ If fraction of time on the left is a ¼, it is only slightly more likely + because the curve is quite flat bottomed. +

+
std::cout << pdf(as, 1. / 4) << std::endl; // 0.735
+
+

+ If we consider fair coin-tossing games being played for 100 days (hypothetically + continuously to be 'at-limit') the person winning after day 5 will not + change in fraction 0.144 of the cases. +

+

+ We can easily compute this setting x = 5./100 = 0.05 +

+
std::cout << cdf(as, 0.05) << std::endl; // 0.144
+
+

+ Similarly, we can compute from a fraction of 0.05 /2 = 0.025 (halved because + we are considering both winners and losers) corresponding to 1 - 0.025 + or 97.5% of the gamblers, (walkers, particles...) on the same + side of the origin +

+
std::cout << 2 * cdf(as, 1 - 0.975) << std::endl; // 0.202
+
+

+ (use of the complement gives a bit more clarity, and avoids potential loss + of accuracy when x is close to unity, see why + complements?). +

+
std::cout << 2 * cdf(complement(as, 0.975)) << std::endl; // 0.202
+
+

+ or we can reverse the calculation by assuming a fraction of time on one + side, say fraction 0.2, +

+
std::cout << quantile(as, 1 - 0.2 / 2) << std::endl; //  0.976
+
+std::cout << quantile(complement(as, 0.2 / 2)) << std::endl; // 0.976
+
+

+ Summary: Every time we toss, the odds + are equal, so on average we have the same change of winning and losing. +

+

+ But this is not true for an an individual + game where one will be mostly in a bad or good patch. +

+

+ This is quite counter-intuitive to most people, but the mathematics is + clear, and gamblers continue to provide proof. +

+

+ Moral: if you in a losing patch, leave + the game. (Because the odds to recover to a good patch are poor). +

+

+ Corollary: Quit while you are ahead? +

+

+ A working example is at arcsine_example.cpp + including sample output . +

+
+ + Related + distributions +
+

+ The arcsine distribution with x_min = 0 and x_max + = 1 is special case of the Beta + Distribution with α = 1/2 and β = 1/2. +

+
+ + Accuracy +
+

+ This distribution is implemented using sqrt, sine, cos and arc sine and + cos trigonometric functions which are normally accurate to a few machine epsilon. + But all values suffer from loss + of significance or cancellation error for values of x + close to x_max. For example, for a standard [0, 1] + arcsine distribution as, the pdf is symmetric about + random variate x = 0.5 so that one would expect pdf(as, 0.01) == + pdf(as, 0.99). But + as x nears unity, there is increasing loss + of significance. To counteract this, the complement versions of + CDF and quantile are implemented with alternative expressions using cos-1 + instead of sin-1. Users should see why + complements? for guidance on when to avoid loss of accuracy by using + complements. +

+
+ + Testing +
+

+ The results were tested against a few accurate spot values computed by + Wolfram Alpha, for example: +

+
N[PDF[arcsinedistribution[0, 1], 0.5], 50]
+  0.63661977236758134307553505349005744813783858296183
+
+
+ + Implementation +
+

+ In the following table a and b + are the parameters x_min   and x_max, + x is the random variable, p is + the probability and its complement q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ support +

+
+

+ x ∈ [a, b], default x ∈ [0, 1] +

+
+

+ pdf +

+
+

+ f(x; a, b) = 1/(π⋅√(x - a)⋅(b - x)) +

+
+

+ cdf +

+
+

+ F(x) = 2/π⋅sin-1(√(x - a) / (b - a) ) +

+
+

+ cdf of complement +

+
+

+ 2/(π⋅cos-1(√(x - a) / (b - a))) +

+
+

+ quantile +

+
+

+ -a⋅sin2(½π⋅p) + a + b⋅sin2(½π⋅p) +

+
+

+ quantile from the complement +

+
+

+ -a⋅cos2(½π⋅p) + a + b⋅cos2(½π⋅q) +

+
+

+ mean +

+
+

+ ½(a+b) +

+
+

+ median +

+
+

+ ½(a+b) +

+
+

+ mode +

+
+

+ x ∈ [a, b], so raises domain_error (returning NaN). +

+
+

+ variance +

+
+

+ (b - a)2 / 8 +

+
+

+ skewness +

+
+

+ 0 +

+
+

+ kurtosis excess +

+
+

+ -3/2 +

+
+

+ kurtosis +

+
+

+ kurtosis_excess + 3 +

+
+

+ The quantile was calculated using an expression obtained by using Wolfram Alpha to invert the + formula for the CDF thus +

+
solve [p - 2/pi sin^-1(sqrt((x-a)/(b-a))) = 0, x]
+
+

+ which was interpreted as +

+
Solve[p - (2 ArcSin[Sqrt[(-a + x)/(-a + b)]])/Pi == 0, x, MaxExtraConditions -> Automatic]
+
+

+ and produced the resulting expression +

+
x = -a sin^2((pi p)/2)+a+b sin^2((pi p)/2)
+
+

+ Thanks to Wolfram for providing this facility. +

+
+ + References +
+ +
+ + Sources +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/bernoulli_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/bernoulli_dist.html new file mode 100644 index 00000000..b2322e96 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/bernoulli_dist.html @@ -0,0 +1,356 @@ + + + +Bernoulli Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/bernoulli.hpp>
+
namespace boost{ namespace math{
+ template <class RealType = double,
+           class Policy   = policies::policy<> >
+ class bernoulli_distribution;
+
+ typedef bernoulli_distribution<> bernoulli;
+
+ template <class RealType, class Policy>
+ class bernoulli_distribution
+ {
+ public:
+    typedef RealType  value_type;
+    typedef Policy    policy_type;
+
+    bernoulli_distribution(RealType p); // Constructor.
+    // Accessor function.
+    RealType success_fraction() const
+    // Probability of success (as a fraction).
+ };
+}} // namespaces
+
+

+ The Bernoulli distribution is a discrete distribution of the outcome of + a single trial with only two results, 0 (failure) or 1 (success), with + a probability of success p. +

+

+ The Bernoulli distribution is the simplest building block on which other + discrete distributions of sequences of independent Bernoulli trials can + be based. +

+

+ The Bernoulli is the binomial distribution (k = 1, p) with only one trial. +

+

+ probability + density function pdf f(0) = 1 - p, f(1) = p. Cumulative + distribution function D(k) = if (k == 0) 1 - p else 1. +

+

+ The following graph illustrates how the probability + density function pdf varies with the outcome of the single trial: +

+

+ +

+

+ and the Cumulative + distribution function +

+

+ +

+
+ + Member + Functions +
+
bernoulli_distribution(RealType p);
+
+

+ Constructs a bernoulli + distribution with success_fraction p. +

+
RealType success_fraction() const
+
+

+ Returns the success_fraction parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is 0 and 1, and the useful supported + range is only 0 or 1. +

+

+ Outside this range, functions are undefined, or may throw domain_error + exception and make an error message available. +

+
+ + Accuracy +
+

+ The Bernoulli distribution is implemented with simple arithmetic operators + and so should have errors within an epsilon or two. +

+
+ + Implementation +
+

+ In the following table p is the probability of success + and q = 1-p. k is the random + variate, either 0 or 1. +

+
+ + + + + +
[Note]Note
+

+ The Bernoulli distribution is implemented here as a strict + discrete distribution. If a generalised version, allowing + k to be any real, is required then the binomial distribution with a single + trial should be used, for example: +

+

+ binomial_distribution(1, + 0.25) +

+
+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ Supported range +

+
+

+ {0, 1} +

+
+

+ pdf +

+
+

+ Using the relation: pdf = 1 - p for k = 0, else p +

+
+

+ cdf +

+
+

+ Using the relation: cdf = 1 - p for k = 0, else 1 +

+
+

+ cdf complement +

+
+

+ q = 1 - p +

+
+

+ quantile +

+
+

+ if x <= (1-p) 0 else 1 +

+
+

+ quantile from the complement +

+
+

+ if x <= (1-p) 1 else 0 +

+
+

+ mean +

+
+

+ p +

+
+

+ variance +

+
+

+ p * (1 - p) +

+
+

+ mode +

+
+

+ if (p < 0.5) 0 else 1 +

+
+

+ skewness +

+
+

+ (1 - 2 * p) / sqrt(p * q) +

+
+

+ kurtosis +

+
+

+ 6 * p * p - 6 * p +1/ p * q +

+
+

+ kurtosis excess +

+
+

+ kurtosis -3 +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/beta_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/beta_dist.html new file mode 100644 index 00000000..5acf27ba --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/beta_dist.html @@ -0,0 +1,622 @@ + + + +Beta Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/beta.hpp>
+
namespace boost{ namespace math{
+
+ template <class RealType = double,
+           class Policy   = policies::policy<> >
+class beta_distribution;
+
+// typedef beta_distribution<double> beta;
+// Note that this is deliberately NOT provided,
+// to avoid a clash with the function name beta.
+
+template <class RealType, class Policy>
+class beta_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+   // Constructor from two shape parameters, alpha & beta:
+   beta_distribution(RealType a, RealType b);
+
+   // Parameter accessors:
+   RealType alpha() const;
+   RealType beta() const;
+
+   // Parameter estimators of alpha or beta from mean and variance.
+   static RealType find_alpha(
+     RealType mean, // Expected value of mean.
+     RealType variance); // Expected value of variance.
+
+   static RealType find_beta(
+     RealType mean, // Expected value of mean.
+     RealType variance); // Expected value of variance.
+
+   // Parameter estimators from
+   // either alpha or beta, and x and probability.
+
+   static RealType find_alpha(
+     RealType beta, // from beta.
+     RealType x, //  x.
+     RealType probability); // cdf
+
+   static RealType find_beta(
+     RealType alpha, // alpha.
+     RealType x, // probability x.
+     RealType probability); // probability cdf.
+};
+
+}} // namespaces
+
+

+ The class type beta_distribution + represents a beta + probability + distribution function. +

+

+ The beta + distribution is used as a prior + distribution for binomial proportions in Bayesian + analysis. +

+

+ See also: beta + distribution and Bayesian + statistics. +

+

+ How the beta distribution is used for Bayesian + analysis of one parameter models is discussed by Jeff Grynaviski. +

+

+ The probability + density function PDF for the beta + distribution defined on the interval [0,1] is given by: +

+

+ f(x;α,β) = xα - 1 (1 - x)β -1 / B(α, β) +

+

+ where B(α, β) is the beta + function, implemented in this library as beta. + Division by the beta function ensures that the pdf is normalized to the + range zero to unity. +

+

+ The following graph illustrates examples of the pdf for various values + of the shape parameters. Note the α = β = 2 (blue line) is dome-shaped, and + might be approximated by a symmetrical triangular distribution. +

+

+ +

+

+ If α = β = 1, then it is a __space uniform + distribution, equal to unity in the entire interval x = 0 to 1. + If α __space and β __space are < 1, then the pdf is U-shaped. If α != β, then + the shape is asymmetric and could be approximated by a triangle whose apex + is away from the centre (where x = half). +

+
+ + Member + Functions +
+
+ + Constructor +
+
beta_distribution(RealType alpha, RealType beta);
+
+

+ Constructs a beta distribution with shape parameters alpha + and beta. +

+

+ Requires alpha,beta > 0,otherwise domain_error + is called. Note that technically the beta distribution is defined for alpha,beta + >= 0, but it's not clear whether any program can actually make use of + that latitude or how many of the non-member functions can be usefully defined + in that case. Therefore for now, we regard it as an error if alpha or beta + is zero. +

+

+ For example: +

+
beta_distribution<> mybeta(2, 5);
+
+

+ Constructs a the beta distribution with alpha=2 and beta=5 (shown in yellow + in the graph above). +

+
+ + Parameter + Accessors +
+
RealType alpha() const;
+
+

+ Returns the parameter alpha from which this distribution + was constructed. +

+
RealType beta() const;
+
+

+ Returns the parameter beta from which this distribution + was constructed. +

+

+ So for example: +

+
beta_distribution<> mybeta(2, 5);
+assert(mybeta.alpha() == 2.);  // mybeta.alpha() returns 2
+assert(mybeta.beta() == 5.);   // mybeta.beta()  returns 5
+
+
+ + Parameter + Estimators +
+

+ Two pairs of parameter estimators are provided. +

+

+ One estimates either α __space or β __space from presumed-known mean and variance. +

+

+ The other pair estimates either α __space or β __space from the cdf and x. +

+

+ It is also possible to estimate α __space and β __space from 'known' mode & + quantile. For example, calculators are provided by the Pooled + Prevalence Calculator and Beta + Buster but this is not yet implemented here. +

+
static RealType find_alpha(
+  RealType mean, // Expected value of mean.
+  RealType variance); // Expected value of variance.
+
+

+ Returns the unique value of α   that corresponds to a beta distribution with + mean mean and variance variance. +

+
static RealType find_beta(
+  RealType mean, // Expected value of mean.
+  RealType variance); // Expected value of variance.
+
+

+ Returns the unique value of β   that corresponds to a beta distribution with + mean mean and variance variance. +

+
static RealType find_alpha(
+  RealType beta, // from beta.
+  RealType x, //  x.
+  RealType probability); // probability cdf
+
+

+ Returns the value of α   that gives: cdf(beta_distribution<RealType>(alpha, beta), x) == probability. +

+
static RealType find_beta(
+  RealType alpha, // alpha.
+  RealType x, // probability x.
+  RealType probability); // probability cdf.
+
+

+ Returns the value of β   that gives: cdf(beta_distribution<RealType>(alpha, beta), x) == probability. +

+
+ + Non-member + Accessor Functions +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The formulae for calculating these are shown in the table below, and at + Wolfram + Mathworld. +

+
+ + Applications +
+

+ The beta distribution can be used to model events constrained to take place + within an interval defined by a minimum and maximum value: so it is used + in project management systems. +

+

+ It is also widely used in Bayesian + statistical inference. +

+
+ + Related + distributions +
+

+ The beta distribution with both α __space and β = 1 follows a uniform + distribution. +

+

+ The triangular + is used when less precise information is available. +

+

+ The binomial + distribution is closely related when α __space and β __space are integers. +

+

+ With integer values of α __space and β __space the distribution B(i, j) is + that of the j-th highest of a sample of i + j + 1 independent random variables + uniformly distributed between 0 and 1. The cumulative probability from + 0 to x is thus the probability that the j-th highest value is less than + x. Or it is the probability that at least i of the random variables are + less than x, a probability given by summing over the Binomial + Distribution with its p parameter set to x. +

+
+ + Accuracy +
+

+ This distribution is implemented using the beta + functions beta + and incomplete beta + functions ibeta + and ibetac; + please refer to these functions for information on accuracy. +

+
+ + Implementation +
+

+ In the following table a and b + are the parameters α   and β, x is the random variable, + p is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ f(x;α,β) = xα - 1 (1 - x)β -1 / B(α, β) +

+

+ Implemented using ibeta_derivative(a, + b, x). +

+
+

+ cdf +

+
+

+ Using the incomplete beta function ibeta(a, + b, x) +

+
+

+ cdf complement +

+
+

+ ibetac(a, + b, x) +

+
+

+ quantile +

+
+

+ Using the inverse incomplete beta function ibeta_inv(a, + b, p) +

+
+

+ quantile from the complement +

+
+

+ ibetac_inv(a, + b, q) +

+
+

+ mean +

+
+

+ a/(a+b) +

+
+

+ variance +

+
+

+ a * + b / + (a+b)^2 * (a + + b + + 1) +

+
+

+ mode +

+
+

+ (a-1) / + (a + + b + - 2) +

+
+

+ skewness +

+
+

+ 2 (b-a) + sqrt(a+b+1)/(a+b+2) * sqrt(a + * b) +

+
+

+ kurtosis excess +

+
+

+ +

+
+

+ kurtosis +

+
+

+ kurtosis + + 3 +

+
+

+ parameter estimation +

+
+
+

+ alpha +

+

+ from mean and variance +

+
+

+ mean * + (( (mean * + (1 + - mean)) / + variance)- + 1) +

+
+

+ beta +

+

+ from mean and variance +

+
+

+ (1 + - mean) * + (((mean + * (1 - mean)) + /variance)-1) +

+
+

+ The member functions find_alpha + and find_beta +

+

+ from cdf and probability x +

+

+ and either alpha + or beta +

+
+

+ Implemented in terms of the inverse incomplete beta functions +

+

+ ibeta_inva, + and ibeta_invb + respectively. +

+
+

+ find_alpha +

+
+

+ ibeta_inva(beta, + x, + probability) +

+
+

+ find_beta +

+
+

+ ibeta_invb(alpha, + x, + probability) +

+
+
+ + References +
+

+ Wikipedia Beta + distribution +

+

+ NIST + Exploratory Data Analysis +

+

+ Wolfram + MathWorld +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/binomial_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/binomial_dist.html new file mode 100644 index 00000000..54d78d81 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/binomial_dist.html @@ -0,0 +1,908 @@ + + + +Binomial Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/binomial.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class binomial_distribution;
+
+typedef binomial_distribution<> binomial;
+
+template <class RealType, class Policy>
+class binomial_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   static const unspecified-type clopper_pearson_exact_interval;
+   static const unspecified-type jeffreys_prior_interval;
+
+   // construct:
+   binomial_distribution(RealType n, RealType p);
+
+   // parameter access::
+   RealType success_fraction() const;
+   RealType trials() const;
+
+   // Bounds on success fraction:
+   static RealType find_lower_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability,
+      unspecified-type method = clopper_pearson_exact_interval);
+   static RealType find_upper_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability,
+      unspecified-type method = clopper_pearson_exact_interval);
+
+   // estimate min/max number of trials:
+   static RealType find_minimum_number_of_trials(
+      RealType k,     // number of events
+      RealType p,     // success fraction
+      RealType alpha); // risk level
+
+   static RealType find_maximum_number_of_trials(
+      RealType k,     // number of events
+      RealType p,     // success fraction
+      RealType alpha); // risk level
+};
+
+}} // namespaces
+
+

+ The class type binomial_distribution + represents a binomial + distribution: it is used when there are exactly two mutually exclusive + outcomes of a trial. These outcomes are labelled "success" and + "failure". The Binomial + Distribution is used to obtain the probability of observing k successes + in N trials, with the probability of success on a single trial denoted + by p. The binomial distribution assumes that p is fixed for all trials. +

+
+ + + + + +
[Note]Note

+ The random variable for the binomial distribution is the number of successes, + (the number of trials is a fixed property of the distribution) whereas + for the negative binomial, the random variable is the number of trials, + for a fixed number of successes. +

+

+ The PDF for the binomial distribution is given by: +

+

+ +

+

+ The following two graphs illustrate how the PDF changes depending upon + the distributions parameters, first we'll keep the success fraction p + fixed at 0.5, and vary the sample size: +

+

+ +

+

+ Alternatively, we can keep the sample size fixed at N=20 and vary the success + fraction p: +

+

+ +

+
+ + + + + +
[Caution]Caution
+

+ The Binomial distribution is a discrete distribution: internally, functions + like the cdf and pdf are treated "as if" they + are continuous functions, but in reality the results returned from these + functions only have meaning if an integer value is provided for the random + variate argument. +

+

+ The quantile function will by default return an integer result that has + been rounded outwards. That is to say lower quantiles + (where the probability is less than 0.5) are rounded downward, and upper + quantiles (where the probability is greater than 0.5) are rounded upwards. + This behaviour ensures that if an X% quantile is requested, then at + least the requested coverage will be present in the central + region, and no more than the requested coverage + will be present in the tails. +

+

+ This behaviour can be changed so that the quantile functions are rounded + differently, or even return a real-valued result using Policies. + It is strongly recommended that you read the tutorial Understanding + Quantiles of Discrete Distributions before using the quantile + function on the Binomial distribution. The reference + docs describe how to change the rounding policy for these distributions. +

+
+
+ + Member + Functions +
+
+ + Construct +
+
binomial_distribution(RealType n, RealType p);
+
+

+ Constructor: n is the total number of trials, p + is the probability of success of a single trial. +

+

+ Requires 0 <= + p <= + 1, and n + >= 0, + otherwise calls domain_error. +

+
+ + Accessors +
+
RealType success_fraction() const;
+
+

+ Returns the parameter p from which this distribution + was constructed. +

+
RealType trials() const;
+
+

+ Returns the parameter n from which this distribution + was constructed. +

+
+ + Lower + Bound on the Success Fraction +
+
static RealType find_lower_bound_on_p(
+   RealType trials,
+   RealType successes,
+   RealType alpha,
+   unspecified-type method = clopper_pearson_exact_interval);
+
+

+ Returns a lower bound on the success fraction: +

+
+

+
+
trials
+

+ The total number of trials conducted. +

+
successes
+

+ The number of successes that occurred. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is less than the value + returned. +

+
method
+

+ An optional parameter that specifies the method to be used to compute + the interval (See below). +

+
+
+

+ For example, if you observe k successes from n + trials the best estimate for the success fraction is simply k/n, + but if you want to be 95% sure that the true value is greater + than some value, pmin, then: +

+
pmin = binomial_distribution<RealType>::find_lower_bound_on_p(
+                    n, k, 0.05);
+
+

+ See worked + example. +

+

+ There are currently two possible values available for the method + optional parameter: clopper_pearson_exact_interval + or jeffreys_prior_interval. These constants are both + members of class template binomial_distribution, + so usage is for example: +

+
p = binomial_distribution<RealType>::find_lower_bound_on_p(
+    n, k, 0.05, binomial_distribution<RealType>::jeffreys_prior_interval);
+
+

+ The default method if this parameter is not specified is the Clopper Pearson + "exact" interval. This produces an interval that guarantees at + least 100(1-alpha)% coverage, but which is known to be overly + conservative, sometimes producing intervals with much greater than the + requested coverage. +

+

+ The alternative calculation method produces a non-informative Jeffreys + Prior interval. It produces 100(1-alpha)% + coverage only in the average case, though is typically + very close to the requested coverage level. It is one of the main methods + of calculation recommended in the review by Brown, Cai and DasGupta. +

+

+ Please note that the "textbook" calculation method using a normal + approximation (the Wald interval) is deliberately not provided: it is known + to produce consistently poor results, even when the sample size is surprisingly + large. Refer to Brown, Cai and DasGupta for a full explanation. Many other + methods of calculation are available, and may be more appropriate for specific + situations. Unfortunately there appears to be no consensus amongst statisticians + as to which is "best": refer to the discussion at the end of + Brown, Cai and DasGupta for examples. +

+

+ The two methods provided here were chosen principally because they can + be used for both one and two sided intervals. See also: +

+

+ Lawrence D. Brown, T. Tony Cai and Anirban DasGupta (2001), Interval Estimation + for a Binomial Proportion, Statistical Science, Vol. 16, No. 2, 101-133. +

+

+ T. Tony Cai (2005), One-sided confidence intervals in discrete distributions, + Journal of Statistical Planning and Inference 131, 63-88. +

+

+ Agresti, A. and Coull, B. A. (1998). Approximate is better than "exact" + for interval estimation of binomial proportions. Amer. Statist. 52 119-126. +

+

+ Clopper, C. J. and Pearson, E. S. (1934). The use of confidence or fiducial + limits illustrated in the case of the binomial. Biometrika 26 404-413. +

+
+ + Upper + Bound on the Success Fraction +
+
static RealType find_upper_bound_on_p(
+   RealType trials,
+   RealType successes,
+   RealType alpha,
+   unspecified-type method = clopper_pearson_exact_interval);
+
+

+ Returns an upper bound on the success fraction: +

+
+

+
+
trials
+

+ The total number of trials conducted. +

+
successes
+

+ The number of successes that occurred. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is greater than the value + returned. +

+
method
+

+ An optional parameter that specifies the method to be used to compute + the interval. Refer to the documentation for find_upper_bound_on_p + above for the meaning of the method options. +

+
+
+

+ For example, if you observe k successes from n + trials the best estimate for the success fraction is simply k/n, + but if you want to be 95% sure that the true value is less + than some value, pmax, then: +

+
pmax = binomial_distribution<RealType>::find_upper_bound_on_p(
+                    n, k, 0.05);
+
+

+ See worked + example. +

+
+ + + + + +
[Note]Note
+

+ In order to obtain a two sided bound on the success fraction, you call + both find_lower_bound_on_p + and find_upper_bound_on_p + each with the same arguments. +

+

+ If the desired risk level that the true success fraction lies outside + the bounds is α, then you pass α/2 to these functions. +

+

+ So for example a two sided 95% confidence interval would be obtained + by passing α = 0.025 to each of the functions. +

+

+ See worked + example. +

+
+
+ + Estimating + the Number of Trials Required for a Certain Number of Successes +
+
static RealType find_minimum_number_of_trials(
+   RealType k,     // number of events
+   RealType p,     // success fraction
+   RealType alpha); // probability threshold
+
+

+ This function estimates the minimum number of trials required to ensure + that more than k events is observed with a level of risk alpha + that k or fewer events occur. +

+
+

+
+
k
+

+ The number of success observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable probability that k events or fewer will be + observed. +

+
+
+

+ For example: +

+
binomial_distribution<RealType>::find_number_of_trials(10, 0.5, 0.05);
+
+

+ Returns the smallest number of trials we must conduct to be 95% sure of + seeing 10 events that occur with frequency one half. +

+
+ + Estimating + the Maximum Number of Trials to Ensure no more than a Certain Number of + Successes +
+
static RealType find_maximum_number_of_trials(
+   RealType k,     // number of events
+   RealType p,     // success fraction
+   RealType alpha); // probability threshold
+
+

+ This function estimates the maximum number of trials we can conduct to + ensure that k successes or fewer are observed, with a risk alpha + that more than k occur. +

+
+

+
+
k
+

+ The number of success observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable probability that more than k events will be + observed. +

+
+
+

+ For example: +

+
binomial_distribution<RealType>::find_maximum_number_of_trials(0, 1e-6, 0.05);
+
+

+ Returns the largest number of trials we can conduct and still be 95% certain + of not observing any events that occur with one in a million frequency. + This is typically used in failure analysis. +

+

+ See Worked + Example. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain for the random variable k is 0 <= k <= N, otherwise a domain_error + is returned. +

+

+ It's worth taking a moment to define what these accessors actually mean + in the context of this distribution: +

+
+

Table 5.1. Meaning of the non-member accessors

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Meaning +

+
+

+ Probability Density + Function +

+
+

+ The probability of obtaining exactly k + successes from n trials with success fraction p. For + example: +

+

+ pdf(binomial(n, + p), + k) +

+
+

+ Cumulative Distribution + Function +

+
+

+ The probability of obtaining k successes + or fewer from n trials with success fraction p. For + example: +

+

+ cdf(binomial(n, + p), + k) +

+
+

+ Complement of + the Cumulative Distribution Function +

+
+

+ The probability of obtaining more than + k successes from n trials with success fraction p. + For example: +

+

+ cdf(complement(binomial(n, + p), + k)) +

+
+

+ Quantile +

+
+

+ The greatest number of successes + that may be observed from n trials with success fraction p, at + probability P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the result. For example: +

+

+ quantile(binomial(n, + p), + P) +

+
+

+ Quantile + from the complement of the probability +

+
+

+ The smallest number of successes + that may be observed from n trials with success fraction p, at + probability P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the result. For example: +

+

+ quantile(complement(binomial(n, + p), + P)) +

+
+
+
+ + Examples +
+

+ Various worked examples + are available illustrating the use of the binomial distribution. +

+
+ + Accuracy +
+

+ This distribution is implemented using the incomplete beta functions ibeta and ibetac, + please refer to these functions for information on accuracy. +

+
+ + Implementation +
+

+ In the following table p is the probability that one + trial will be successful (the success fraction), n + is the number of trials, k is the number of successes, + p is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Implementation is in terms of ibeta_derivative: + if nCk is the binomial coefficient of a and b, then we have: +

+

+ +

+

+ Which can be evaluated as ibeta_derivative(k+1, n-k+1, p) / + (n+1) +

+

+ The function ibeta_derivative + is used here, since it has already been optimised for the lowest + possible error - indeed this is really just a thin wrapper around + part of the internals of the incomplete beta function. +

+

+ There are also various special cases: refer to the code for details. +

+
+

+ cdf +

+
+

+ Using the relation: +

+
p = I[sub 1-p](n - k, k + 1)
+  = 1 - I[sub p](k + 1, n - k)
+  = ibetac(k + 1, n - k, p)
+

+ There are also various special cases: refer to the code for details. +

+
+

+ cdf complement +

+
+

+ Using the relation: q = ibeta(k + + 1, n - k, p) +

+

+ There are also various special cases: refer to the code for details. +

+
+

+ quantile +

+
+

+ Since the cdf is non-linear in variate k + none of the inverse incomplete beta functions can be used here. + Instead the quantile is found numerically using a derivative + free method (TOMS + 748 algorithm). +

+
+

+ quantile from the complement +

+
+

+ Found numerically as above. +

+
+

+ mean +

+
+

+ p * + n +

+
+

+ variance +

+
+

+ p * + n * + (1-p) +

+
+

+ mode +

+
+

+ floor(p * + (n + + 1)) +

+
+

+ skewness +

+
+

+ (1 + - 2 + * p) / + sqrt(n * + p * + (1 + - p)) +

+
+

+ kurtosis +

+
+

+ 3 - + (6 + / n) + + (1 + / (n * + p * + (1 + - p))) +

+
+

+ kurtosis excess +

+
+

+ (1 + - 6 + * p + * q) / + (n + * p + * q) +

+
+

+ parameter estimation +

+
+

+ The member functions find_upper_bound_on_p + find_lower_bound_on_p + and find_number_of_trials + are implemented in terms of the inverse incomplete beta functions + ibetac_inv, + ibeta_inv, + and ibetac_invb + respectively +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/cauchy_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/cauchy_dist.html new file mode 100644 index 00000000..08c174dd --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/cauchy_dist.html @@ -0,0 +1,305 @@ + + + +Cauchy-Lorentz Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/cauchy.hpp>
+
template <class RealType = double,
+          class Policy   = policies::policy<> >
+class cauchy_distribution;
+
+typedef cauchy_distribution<> cauchy;
+
+template <class RealType, class Policy>
+class cauchy_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   cauchy_distribution(RealType location = 0, RealType scale = 1);
+
+   RealType location()const;
+   RealType scale()const;
+};
+
+

+ The Cauchy-Lorentz + distribution is named after Augustin Cauchy and Hendrik Lorentz. + It is a continuous + probability distribution with probability + distribution function PDF given by: +

+

+ +

+

+ The location parameter x0   is the location of the peak of the distribution + (the mode of the distribution), while the scale parameter γ   specifies half + the width of the PDF at half the maximum height. If the location is zero, + and the scale 1, then the result is a standard Cauchy distribution. +

+

+ The distribution is important in physics as it is the solution to the differential + equation describing forced resonance, while in spectroscopy it is the description + of the line shape of spectral lines. +

+

+ The following graph shows how the distributions moves as the location parameter + changes: +

+

+ +

+

+ While the following graph shows how the shape (scale) parameter alters + the distribution: +

+

+ +

+
+ + Member + Functions +
+
cauchy_distribution(RealType location = 0, RealType scale = 1);
+
+

+ Constructs a Cauchy distribution, with location parameter location + and scale parameter scale. When these parameters take + their default values (location = 0, scale = 1) then the result is a Standard + Cauchy Distribution. +

+

+ Requires scale > 0, otherwise calls domain_error. +

+
RealType location()const;
+
+

+ Returns the location parameter of the distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of the distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ Note however that the Cauchy distribution does not have a mean, standard + deviation, etc. See mathematically + undefined function to control whether these should fail to compile + with a BOOST_STATIC_ASSERTION_FAILURE, which is the default. +

+

+ Alternately, the functions mean, + standard deviation, + variance, skewness, kurtosis + and kurtosis_excess + will all return a domain_error + if called. +

+

+ The domain of the random variable is [-[max_value], +[min_value]]. +

+
+ + Accuracy +
+

+ The Cauchy distribution is implemented in terms of the standard library + tan and atan + functions, and as such should have very low error rates. +

+
+ + Implementation +
+

+ In the following table x0 is the location parameter of the distribution, + γ   is its scale parameter, x is the random variate, + p is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = 1 / (π * γ * (1 + ((x - x0 ) / γ)2) +

+
+

+ cdf and its complement +

+
+

+ The cdf is normally given by: +

+

+ p = 0.5 + atan(x)/π +

+

+ But that suffers from cancellation error as x -> -∞. So recall + that for x < + 0: +

+

+ atan(x) = -π/2 - atan(1/x) +

+

+ Substituting into the above we get: +

+

+ p = -atan(1/x) ; x < 0 +

+

+ So the procedure is to calculate the cdf for -fabs(x) using the + above formula. Note that to factor in the location and scale + parameters you must substitute (x - x0 ) / γ   for x in the above. +

+

+ This procedure yields the smaller of p and + q, so the result may need subtracting from + 1 depending on whether we want the complement or not, and whether + x is less than x0 or not. +

+
+

+ quantile +

+
+

+ The same procedure is used irrespective of whether we're starting + from the probability or its complement. First the argument p + is reduced to the range [-0.5, 0.5], then the relation +

+

+ x = x0 ± γ   / tan(π * p) +

+

+ is used to obtain the result. Whether we're adding or subtracting + from x0 is determined by whether we're starting from the complement + or not. +

+
+

+ mode +

+
+

+ The location parameter. +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/chi_squared_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/chi_squared_dist.html new file mode 100644 index 00000000..e14a9ffe --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/chi_squared_dist.html @@ -0,0 +1,411 @@ + + + +Chi Squared Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/chi_squared.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class chi_squared_distribution;
+
+typedef chi_squared_distribution<> chi_squared;
+
+template <class RealType, class Policy>
+class chi_squared_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor:
+   chi_squared_distribution(RealType i);
+
+   // Accessor to parameter:
+   RealType degrees_of_freedom()const;
+
+   // Parameter estimation:
+   static RealType find_degrees_of_freedom(
+      RealType difference_from_mean,
+      RealType alpha,
+      RealType beta,
+      RealType sd,
+      RealType hint = 100);
+};
+
+}} // namespaces
+
+

+ The Chi-Squared distribution is one of the most widely used distributions + in statistical tests. If χi   are ν   +independent, normally distributed random + variables with means μi   and variances σi2, then the random variable: +

+

+ +

+

+ is distributed according to the Chi-Squared distribution. +

+

+ The Chi-Squared distribution is a special case of the gamma distribution + and has a single parameter ν   that specifies the number of degrees of freedom. + The following graph illustrates how the distribution changes for different + values of ν: +

+

+ +

+
+ + Member + Functions +
+
chi_squared_distribution(RealType v);
+
+

+ Constructs a Chi-Squared distribution with v degrees + of freedom. +

+

+ Requires v > 0, otherwise calls domain_error. +

+
RealType degrees_of_freedom()const;
+
+

+ Returns the parameter v from which this object was + constructed. +

+
static RealType find_degrees_of_freedom(
+   RealType difference_from_variance,
+   RealType alpha,
+   RealType beta,
+   RealType variance,
+   RealType hint = 100);
+
+

+ Estimates the sample size required to detect a difference from a nominal + variance in a Chi-Squared test for equal standard deviations. +

+
+

+
+
difference_from_variance
+

+ The difference from the assumed nominal variance that is to be detected: + Note that the sign of this value is critical, see below. +

+
alpha
+

+ The maximum acceptable risk of rejecting the null hypothesis when + it is in fact true. +

+
beta
+

+ The maximum acceptable risk of falsely failing to reject the null + hypothesis. +

+
variance
+

+ The nominal variance being tested against. +

+
hint
+

+ An optional hint on where to start looking for a result: the current + sample size would be a good choice. +

+
+
+

+ Note that this calculation works with variances and + not standard deviations. +

+

+ The sign of the parameter difference_from_variance + is important: the Chi Squared distribution is asymmetric, and the caller + must decide in advance whether they are testing for a variance greater + than a nominal value (positive difference_from_variance) + or testing for a variance less than a nominal value (negative difference_from_variance). + If the latter, then obviously it is a requirement that variance + + difference_from_variance + > 0, + since no sample can have a negative variance! +

+

+ This procedure uses the method in Diamond, W. J. (1989). Practical Experiment + Designs, Van-Nostrand Reinhold, New York. +

+

+ See also section on Sample sizes required in the + NIST Engineering Statistics Handbook, Section 7.2.3.2. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ (We have followed the usual restriction of the mode to degrees of freedom + >= 2, but note that the maximum of the pdf is actually zero for degrees + of freedom from 2 down to 0, and provide an extended definition that would + avoid a discontinuity in the mode as alternative code in a comment). +

+

+ The domain of the random variable is [0, +∞]. +

+
+ + Examples +
+

+ Various worked examples + are available illustrating the use of the Chi Squared Distribution. +

+
+ + Accuracy +
+

+ The Chi-Squared distribution is implemented in terms of the incomplete + gamma functions: please refer to the accuracy data for those functions. +

+
+ + Implementation +
+

+ In the following table v is the number of degrees + of freedom of the distribution, x is the random variate, + p is the probability, and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(v + / 2, x / 2) / 2 +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_p(v + / 2, x / 2) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_q(v + / 2, x / 2) +

+
+

+ quantile +

+
+

+ Using the relation: x = 2 * gamma_p_inv(v + / 2, p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = 2 * gamma_q_inv(v + / 2, p) +

+
+

+ mean +

+
+

+ v +

+
+

+ variance +

+
+

+ 2v +

+
+

+ mode +

+
+

+ v - 2 (if v >= 2) +

+
+

+ skewness +

+
+

+ 2 * sqrt(2 / v) == sqrt(8 / v) +

+
+

+ kurtosis +

+
+

+ 3 + 12 / v +

+
+

+ kurtosis excess +

+
+

+ 12 / v +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/exp_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/exp_dist.html new file mode 100644 index 00000000..67fd3839 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/exp_dist.html @@ -0,0 +1,328 @@ + + + +Exponential Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/exponential.hpp>
+
template <class RealType = double,
+          class Policy   = policies::policy<> >
+class exponential_distribution;
+
+typedef exponential_distribution<> exponential;
+
+template <class RealType, class Policy>
+class exponential_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   exponential_distribution(RealType lambda = 1);
+
+   RealType lambda()const;
+};
+
+

+ The exponential + distribution is a continuous + probability distribution with PDF: +

+

+ +

+

+ It is often used to model the time between independent events that happen + at a constant average rate. +

+

+ The following graph shows how the distribution changes for different values + of the rate parameter lambda: +

+

+ +

+
+ + Member + Functions +
+
exponential_distribution(RealType lambda = 1);
+
+

+ Constructs an Exponential + distribution with parameter lambda. Lambda + is defined as the reciprocal of the scale parameter. +

+

+ Requires lambda > 0, otherwise calls domain_error. +

+
RealType lambda()const;
+
+

+ Accessor function returns the lambda parameter of the distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, +∞]. +

+
+ + Accuracy +
+

+ The exponential distribution is implemented in terms of the standard library + functions exp, log, log1p + and expm1 and as such should + have very low error rates. +

+
+ + Implementation +
+

+ In the following table λ is the parameter lambda of the distribution, x + is the random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = λ * exp(-λ * x) +

+
+

+ cdf +

+
+

+ Using the relation: p = 1 - exp(-x * λ) = -expm1(-x * λ) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = exp(-x * λ) +

+
+

+ quantile +

+
+

+ Using the relation: x = -log(1-p) / λ = -log1p(-p) / λ +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = -log(q) / λ +

+
+

+ mean +

+
+

+ 1/λ +

+
+

+ standard deviation +

+
+

+ 1/λ +

+
+

+ mode +

+
+

+ 0 +

+
+

+ skewness +

+
+

+ 2 +

+
+

+ kurtosis +

+
+

+ 9 +

+
+

+ kurtosis excess +

+
+

+ 6 +

+
+
+ + references +
+ +

+ (See also the reference documentation for the related Extreme + Distributions.) +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/extreme_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/extreme_dist.html new file mode 100644 index 00000000..b142bfd5 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/extreme_dist.html @@ -0,0 +1,331 @@ + + + +Extreme Value Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/extreme.hpp>
+
template <class RealType = double,
+          class Policy   = policies::policy<> >
+class extreme_value_distribution;
+
+typedef extreme_value_distribution<> extreme_value;
+
+template <class RealType, class Policy>
+class extreme_value_distribution
+{
+public:
+   typedef RealType value_type;
+
+   extreme_value_distribution(RealType location = 0, RealType scale = 1);
+
+   RealType scale()const;
+   RealType location()const;
+};
+
+

+ There are various extreme + value distributions : this implementation represents the maximum + case, and is variously known as a Fisher-Tippett distribution, a log-Weibull + distribution or a Gumbel distribution. +

+

+ Extreme value theory is important for assessing risk for highly unusual + events, such as 100-year floods. +

+

+ More information can be found on the NIST, + Wikipedia, + Mathworld, + and Extreme + value theory websites. +

+

+ The relationship of the types of extreme value distributions, of which + this is but one, is discussed by Extreme + Value Distributions, Theory and Applications Samuel Kotz & Saralees + Nadarajah. +

+

+ The distribution has a PDF given by: +

+

+ f(x) = (1/scale) e-(x-location)/scale e-e-(x-location)/scale +

+

+ Which in the standard case (scale = 1, location = 0) reduces to: +

+

+ f(x) = e-xe-e-x +

+

+ The following graph illustrates how the PDF varies with the location parameter: +

+

+ +

+

+ And this graph illustrates how the PDF varies with the shape parameter: +

+

+ +

+
+ + Member + Functions +
+
extreme_value_distribution(RealType location = 0, RealType scale = 1);
+
+

+ Constructs an Extreme Value distribution with the specified location and + scale parameters. +

+

+ Requires scale > + 0, otherwise calls domain_error. +

+
RealType location()const;
+
+

+ Returns the location parameter of the distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of the distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random parameter is [-∞, +∞]. +

+
+ + Accuracy +
+

+ The extreme value distribution is implemented in terms of the standard + library exp and log functions and as such should have + very low error rates. +

+
+ + Implementation +
+

+ In the following table: a is the location parameter, + b is the scale parameter, x is + the random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = exp((a-x)/b) * exp(-exp((a-x)/b)) / + b +

+
+

+ cdf +

+
+

+ Using the relation: p = exp(-exp((a-x)/b)) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = -expm1(-exp((a-x)/b)) +

+
+

+ quantile +

+
+

+ Using the relation: a - log(-log(p)) * b +

+
+

+ quantile from the complement +

+
+

+ Using the relation: a - log(-log1p(-q)) * b +

+
+

+ mean +

+
+

+ a + Euler-Mascheroni-constant + * b +

+
+

+ standard deviation +

+
+

+ pi * b / sqrt(6) +

+
+

+ mode +

+
+

+ The same as the location parameter a. +

+
+

+ skewness +

+
+

+ 12 * sqrt(6) * zeta(3) / pi3 +

+
+

+ kurtosis +

+
+

+ 27 / 5 +

+
+

+ kurtosis excess +

+
+

+ kurtosis - 3 or 12 / 5 +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/f_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/f_dist.html new file mode 100644 index 00000000..9911987f --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/f_dist.html @@ -0,0 +1,434 @@ + + + +F Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/fisher_f.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class fisher_f_distribution;
+
+typedef fisher_f_distribution<> fisher_f;
+
+template <class RealType, class Policy>
+class fisher_f_distribution
+{
+public:
+   typedef RealType value_type;
+
+   // Construct:
+   fisher_f_distribution(const RealType& i, const RealType& j);
+
+   // Accessors:
+   RealType degrees_of_freedom1()const;
+   RealType degrees_of_freedom2()const;
+};
+
+}} //namespaces
+
+

+ The F distribution is a continuous distribution that arises when testing + whether two samples have the same variance. If χ2m   and χ2n   are independent + variates each distributed as Chi-Squared with m and + n degrees of freedom, then the test statistic: +

+

+ Fn,m   = (χ2n   / n) / (χ2m   / m) +

+

+ Is distributed over the range [0, ∞] with an F distribution, and has the + PDF: +

+

+ +

+

+ The following graph illustrates how the PDF varies depending on the two + degrees of freedom parameters. +

+

+ +

+
+ + Member Functions +
+
fisher_f_distribution(const RealType& df1, const RealType& df2);
+
+

+ Constructs an F-distribution with numerator degrees of freedom df1 + and denominator degrees of freedom df2. +

+

+ Requires that df1 and df2 are + both greater than zero, otherwise domain_error + is called. +

+
RealType degrees_of_freedom1()const;
+
+

+ Returns the numerator degrees of freedom parameter of the distribution. +

+
RealType degrees_of_freedom2()const;
+
+

+ Returns the denominator degrees of freedom parameter of the distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, +∞]. +

+
+ + Examples +
+

+ Various worked examples + are available illustrating the use of the F Distribution. +

+
+ + Accuracy +
+

+ The normal distribution is implemented in terms of the incomplete + beta function and its inverses, + refer to those functions for accuracy data. +

+
+ + Implementation +
+

+ In the following table v1 and v2 + are the first and second degrees of freedom parameters of the distribution, + x is the random variate, p is + the probability, and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ The usual form of the PDF is given by: +

+

+ +

+

+ However, that form is hard to evaluate directly without incurring + problems with either accuracy or numeric overflow. +

+

+ Direct differentiation of the CDF expressed in terms of the incomplete + beta function +

+

+ led to the following two formulas: +

+

+ fv1,v2(x) = y * ibeta_derivative(v2 + / 2, v1 / 2, v2 / (v2 + v1 * x)) +

+

+ with y = (v2 * v1) / ((v2 + v1 * x) * (v2 + v1 * x)) +

+

+ and +

+

+ fv1,v2(x) = y * ibeta_derivative(v1 + / 2, v2 / 2, v1 * x / (v2 + v1 * x)) +

+

+ with y = (z * v1 - x * v1 * v1) / z2 +

+

+ and z = v2 + v1 * x +

+

+ The first of these is used for v1 * x > v2, otherwise the + second is used. +

+

+ The aim is to keep the x argument to ibeta_derivative + away from 1 to avoid rounding error. +

+
+

+ cdf +

+
+

+ Using the relations: +

+

+ p = ibeta(v1 + / 2, v2 / 2, v1 * x / (v2 + v1 * x)) +

+

+ and +

+

+ p = ibetac(v2 + / 2, v1 / 2, v2 / (v2 + v1 * x)) +

+

+ The first is used for v1 * x > v2, otherwise the second is + used. +

+

+ The aim is to keep the x argument to ibeta well + away from 1 to avoid rounding error. +

+
+

+ cdf complement +

+
+

+ Using the relations: +

+

+ p = ibetac(v1 + / 2, v2 / 2, v1 * x / (v2 + v1 * x)) +

+

+ and +

+

+ p = ibeta(v2 + / 2, v1 / 2, v2 / (v2 + v1 * x)) +

+

+ The first is used for v1 * x < v2, otherwise the second is + used. +

+

+ The aim is to keep the x argument to ibeta well + away from 1 to avoid rounding error. +

+
+

+ quantile +

+
+

+ Using the relation: +

+

+ x = v2 * a / (v1 * b) +

+

+ where: +

+

+ a = ibeta_inv(v1 + / 2, v2 / 2, p) +

+

+ and +

+

+ b = 1 - a +

+

+ Quantities a and b + are both computed by ibeta_inv + without the subtraction implied above. +

+
+

+ quantile +

+

+ from the complement +

+
+

+ Using the relation: +

+

+ x = v2 * a / (v1 * b) +

+

+ where +

+

+ a = ibetac_inv(v1 + / 2, v2 / 2, p) +

+

+ and +

+

+ b = 1 - a +

+

+ Quantities a and b + are both computed by ibetac_inv + without the subtraction implied above. +

+
+

+ mean +

+
+

+ v2 / (v2 - 2) +

+
+

+ variance +

+
+

+ 2 * v22 * (v1 + v2 - 2) / (v1 * (v2 - 2) * (v2 - 2) * (v2 - 4)) +

+
+

+ mode +

+
+

+ v2 * (v1 - 2) / (v1 * (v2 + 2)) +

+
+

+ skewness +

+
+

+ 2 * (v2 + 2 * v1 - 2) * sqrt((2 * v2 - 8) / (v1 * (v2 + v1 - + 2))) / (v2 - 6) +

+
+

+ kurtosis and kurtosis excess +

+
+

+ Refer to, Weisstein, + Eric W. "F-Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/gamma_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/gamma_dist.html new file mode 100644 index 00000000..ebbfd9a0 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/gamma_dist.html @@ -0,0 +1,364 @@ + + + +Gamma (and Erlang) Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/gamma.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class gamma_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   gamma_distribution(RealType shape, RealType scale = 1)
+
+   RealType shape()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The gamma distribution is a continuous probability distribution. When the + shape parameter is an integer then it is known as the Erlang Distribution. + It is also closely related to the Poisson and Chi Squared Distributions. +

+

+ When the shape parameter has an integer value, the distribution is the + Erlang distribution. + Since this can be produced by ensuring that the shape parameter has an + integer value > 0, the Erlang distribution is not separately implemented. +

+
+ + + + + +
[Note]Note
+

+ To avoid potential confusion with the gamma functions, this distribution + does not provide the typedef: +

+
typedef gamma_distribution<double> gamma;
+

+ Instead if you want a double precision gamma distribution you can write +

+
boost::math::gamma_distribution<> my_gamma(1, 1);
+
+

+ For shape parameter k and scale parameter θ   it is defined + by the probability density function: +

+

+ +

+

+ Sometimes an alternative formulation is used: given parameters α  = k and + β  = 1 / θ, then the distribution can be defined by the PDF: +

+

+ +

+

+ In this form the inverse scale parameter is called a rate parameter. +

+

+ Both forms are in common usage: this library uses the first definition + throughout. Therefore to construct a Gamma Distribution from a rate + parameter, you should pass the reciprocal of the rate as the + scale parameter. +

+

+ The following two graphs illustrate how the PDF of the gamma distribution + varies as the parameters vary: +

+

+ +

+

+ +

+

+ The Erlang Distribution is the same as + the Gamma, but with the shape parameter an integer. It is often expressed + using a rate rather than a scale + as the second parameter (remember that the rate is the reciprocal of the + scale). +

+

+ Internally the functions used to implement the Gamma Distribution are already + optimised for small-integer arguments, so in general there should be no + great loss of performance from using a Gamma Distribution rather than a + dedicated Erlang Distribution. +

+
+ + Member + Functions +
+
gamma_distribution(RealType shape, RealType scale = 1);
+
+

+ Constructs a gamma distribution with shape shape and + scale scale. +

+

+ Requires that the shape and scale parameters are greater than zero, otherwise + calls domain_error. +

+
RealType shape()const;
+
+

+ Returns the shape parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0,+∞]. +

+
+ + Accuracy +
+

+ The lognormal distribution is implemented in terms of the incomplete gamma + functions gamma_p and + gamma_q and their inverses + gamma_p_inv and + gamma_q_inv: refer + to the accuracy data for those functions for more information. +

+
+ + Implementation +
+

+ In the following table k is the shape parameter of + the distribution, θ   is its scale parameter, x is the + random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(k, + x / θ) / θ +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_p(k, + x / θ) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_q(k, + x / θ) +

+
+

+ quantile +

+
+

+ Using the relation: x = θ  * gamma_p_inv(k, + p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = θ  * gamma_q_inv(k, + p) +

+
+

+ mean +

+
+

+ kθ +

+
+

+ variance +

+
+

+ kθ2 +

+
+

+ mode +

+
+

+ (k-1)θ   for k>1 otherwise a domain_error +

+
+

+ skewness +

+
+

+ 2 / sqrt(k) +

+
+

+ kurtosis +

+
+

+ 3 + 6 / k +

+
+

+ kurtosis excess +

+
+

+ 6 / k +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/geometric_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/geometric_dist.html new file mode 100644 index 00000000..f29f2c42 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/geometric_dist.html @@ -0,0 +1,841 @@ + + + +Geometric Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/geometric.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class geometric_distribution;
+
+typedef geometric_distribution<> geometric;
+
+template <class RealType, class Policy>
+class geometric_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Constructor from success_fraction:
+   geometric_distribution(RealType p);
+
+   // Parameter accessors:
+   RealType success_fraction() const;
+   RealType successes() const;
+
+   // Bounds on success fraction:
+   static RealType find_lower_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability); // alpha
+   static RealType find_upper_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability); // alpha
+
+   // Estimate min/max number of trials:
+   static RealType find_minimum_number_of_trials(
+      RealType k,     // Number of failures.
+      RealType p,     // Success fraction.
+      RealType probability); // Probability threshold alpha.
+   static RealType find_maximum_number_of_trials(
+      RealType k,     // Number of failures.
+      RealType p,     // Success fraction.
+      RealType probability); // Probability threshold alpha.
+};
+
+}} // namespaces
+
+

+ The class type geometric_distribution + represents a geometric + distribution: it is used when there are exactly two mutually exclusive + outcomes of a Bernoulli + trial: these outcomes are labelled "success" and "failure". +

+

+ For Bernoulli + trials each with success fraction p, the geometric + distribution gives the probability of observing k + trials (failures, events, occurrences, or arrivals) before the first success. +

+
+ + + + + +
[Note]Note

+ For this implementation, the set of trials includes + zero (unlike another definition where the set of trials starts + at one, sometimes named shifted). +

+

+ The geometric distribution assumes that success_fraction p + is fixed for all k trials. +

+

+ The probability that there are k failures before the + first success is +

+

+    Pr(Y=k) = (1-p)kp +

+

+ For example, when throwing a 6-face dice the success probability p + = 1/6 = 0.1666 ̇  . Throwing repeatedly until a three + appears, the probability distribution of the number of times not-a-three + is thrown is geometric. +

+

+ Geometric distribution has the Probability Density Function PDF: +

+

+    (1-p)kp +

+

+ The following graph illustrates how the PDF and CDF vary for three examples + of the success fraction p, (when considering the geometric + distribution as a continuous function), +

+

+ +

+

+ +

+

+ and as discrete. +

+

+ +

+

+ +

+
+ + Related + Distributions +
+

+ The geometric distribution is a special case of the Negative + Binomial Distribution with successes parameter r + = 1, so only one first and only success is required : thus by definition +    geometric(p) == + negative_binomial(1, p) +

+
negative_binomial_distribution(RealType r, RealType success_fraction);
+negative_binomial nb(1, success_fraction);
+geometric g(success_fraction);
+ASSERT(pdf(nb, 1) == pdf(g, 1));
+
+

+ This implementation uses real numbers for the computation throughout (because + it uses the real-valued power and exponential + functions). So to obtain a conventional strictly-discrete geometric distribution + you must ensure that an integer value is provided for the number of trials + (random variable) k, and take integer values (floor + or ceil functions) from functions that return a number of successes. +

+
+ + + + + +
[Caution]Caution
+

+ The geometric distribution is a discrete distribution: internally, functions + like the cdf and pdf are treated "as if" they + are continuous functions, but in reality the results returned from these + functions only have meaning if an integer value is provided for the random + variate argument. +

+

+ The quantile function will by default return an integer result that has + been rounded outwards. That is to say lower quantiles + (where the probability is less than 0.5) are rounded downward, and upper + quantiles (where the probability is greater than 0.5) are rounded upwards. + This behaviour ensures that if an X% quantile is requested, then at + least the requested coverage will be present in the central + region, and no more than the requested coverage + will be present in the tails. +

+

+ This behaviour can be changed so that the quantile functions are rounded + differently, or even return a real-valued result using Policies. + It is strongly recommended that you read the tutorial Understanding + Quantiles of Discrete Distributions before using the quantile + function on the geometric distribution. The reference + docs describe how to change the rounding policy for these distributions. +

+
+
+ + Member + Functions +
+
+ + Constructor +
+
geometric_distribution(RealType p);
+
+

+ Constructor: p or success_fraction is the probability + of success of a single trial. +

+

+ Requires: 0 <= + p <= + 1. +

+
+ + Accessors +
+
RealType success_fraction() const; // successes / trials (0 <= p <= 1)
+
+

+ Returns the success_fraction parameter p from which + this distribution was constructed. +

+
RealType successes() const; // required successes always one,
+// included for compatibility with negative binomial distribution
+// with successes r == 1.
+
+

+ Returns unity. +

+

+ The following functions are equivalent to those provided for the negative + binomial, with successes = 1, but are provided here for completeness. +

+

+ The best method of calculation for the following functions is disputed: + see Binomial + Distribution and Negative + Binomial Distribution for more discussion. +

+
+ + Lower + Bound on success_fraction Parameter p +
+
static RealType find_lower_bound_on_p(
+  RealType failures,
+  RealType probability) // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
+
+

+ Returns a lower bound on the success fraction: +

+
+

+
+
failures
+

+ The total number of failures before the 1st success. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is less than the value + returned. +

+
+
+

+ For example, if you observe k failures from n + trials the best estimate for the success fraction is simply 1/n, + but if you want to be 95% sure that the true value is greater + than some value, pmin, then: +

+
pmin = geometric_distribution<RealType>::
+   find_lower_bound_on_p(failures, 0.05);
+
+

+ See + negative_binomial confidence interval example. +

+

+ This function uses the Clopper-Pearson method of computing the lower bound + on the success fraction, whilst many texts refer to this method as giving + an "exact" result in practice it produces an interval that guarantees + at least the coverage required, and may produce pessimistic + estimates for some combinations of failures and successes. + See: +

+

+ Yong + Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some + Discrete Distributions. Computational statistics and data analysis, 2005, + vol. 48, no3, 605-621. +

+
+ + Upper + Bound on success_fraction Parameter p +
+
static RealType find_upper_bound_on_p(
+   RealType trials,
+   RealType alpha); // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
+
+

+ Returns an upper bound on the success + fraction: +

+
+

+
+
trials
+

+ The total number of trials conducted. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is greater than the value + returned. +

+
+
+

+ For example, if you observe k successes from n + trials the best estimate for the success fraction is simply k/n, + but if you want to be 95% sure that the true value is less + than some value, pmax, then: +

+
pmax = geometric_distribution<RealType>::find_upper_bound_on_p(
+                    k, 0.05);
+
+

+ See + negative binomial confidence interval example. +

+

+ This function uses the Clopper-Pearson method of computing the lower bound + on the success fraction, whilst many texts refer to this method as giving + an "exact" result in practice it produces an interval that guarantees + at least the coverage required, and may produce pessimistic + estimates for some combinations of failures and successes. + See: +

+

+ Yong + Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some + Discrete Distributions. Computational statistics and data analysis, 2005, + vol. 48, no3, 605-621. +

+
+ + Estimating + Number of Trials to Ensure at Least a Certain Number of Failures +
+
static RealType find_minimum_number_of_trials(
+   RealType k,     // number of failures.
+   RealType p,     // success fraction.
+   RealType alpha); // probability threshold (0.05 equivalent to 95%).
+
+

+ This functions estimates the number of trials required to achieve a certain + probability that more than k + failures will be observed. +

+
+

+
+
k
+

+ The target number of failures to be observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable risk that only k + failures or fewer will be observed. +

+
+
+

+ For example: +

+
geometric_distribution<RealType>::find_minimum_number_of_trials(10, 0.5, 0.05);
+
+

+ Returns the smallest number of trials we must conduct to be 95% (1-0.05) + sure of seeing 10 failures that occur with frequency one half. +

+

+ Worked + Example. +

+

+ This function uses numeric inversion of the geometric distribution to obtain + the result: another interpretation of the result is that it finds the number + of trials (failures) that will lead to an alpha probability + of observing k failures or fewer. +

+
+ + Estimating + Number of Trials to Ensure a Maximum Number of Failures or Less +
+
static RealType find_maximum_number_of_trials(
+   RealType k,     // number of failures.
+   RealType p,     // success fraction.
+   RealType alpha); // probability threshold (0.05 equivalent to 95%).
+
+

+ This functions estimates the maximum number of trials we can conduct and + achieve a certain probability that k failures or + fewer will be observed. +

+
+

+
+
k
+

+ The maximum number of failures to be observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable risk that more than + k failures will be observed. +

+
+
+

+ For example: +

+
geometric_distribution<RealType>::find_maximum_number_of_trials(0, 1.0-1.0/1000000, 0.05);
+
+

+ Returns the largest number of trials we can conduct and still be 95% sure + of seeing no failures that occur with frequency one in one million. +

+

+ This function uses numeric inversion of the geometric distribution to obtain + the result: another interpretation of the result, is that it finds the + number of trials that will lead to an alpha probability + of observing more than k failures. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ However it's worth taking a moment to define what these actually mean in + the context of this distribution: +

+
+

Table 5.2. Meaning of the non-member accessors.

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Meaning +

+
+

+ Probability Density + Function +

+
+

+ The probability of obtaining exactly k + failures from k trials with success + fraction p. For example: +

+
pdf(geometric(p), k)
+
+

+ Cumulative Distribution + Function +

+
+

+ The probability of obtaining k failures + or fewer from k trials with success + fraction p and success on the last trial. For example: +

+
cdf(geometric(p), k)
+
+

+ Complement of + the Cumulative Distribution Function +

+
+

+ The probability of obtaining more than + k failures from k trials with + success fraction p and success on the last trial. For example: +

+
cdf(complement(geometric(p), k))
+
+

+ Quantile +

+
+

+ The greatest number of failures + k expected to be observed from k + trials with success fraction p, at probability + P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the real result. For example: +

+
quantile(geometric(p), P)
+
+

+ Quantile + from the complement of the probability +

+
+

+ The smallest number of failures + k expected to be observed from k + trials with success fraction p, at probability + P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the real result. For example: +

+
quantile(complement(geometric(p), P))
+
+
+
+ + Accuracy +
+

+ This distribution is implemented using the pow and exp functions, so most + results are accurate within a few epsilon for the RealType. For extreme + values of double p, + for example 0.9999999999, accuracy can fall significantly, for example + to 10 decimal digits (from 16). +

+
+ + Implementation +
+

+ In the following table, p is the probability that + any one trial will be successful (the success fraction), k + is the number of failures, p is the probability and + q = 1-p, x is the given probability + to estimate the expected number of failures using the quantile. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ pdf = p * pow(q, k) +

+
+

+ cdf +

+
+

+ cdf = 1 - qk=1 +

+
+

+ cdf complement +

+
+

+ exp(log1p(-p) * (k+1)) +

+
+

+ quantile +

+
+

+ k = log1p(-x) / log1p(-p) -1 +

+
+

+ quantile from the complement +

+
+

+ k = log(x) / log1p(-p) -1 +

+
+

+ mean +

+
+

+ (1-p)/p +

+
+

+ variance +

+
+

+ (1-p)/p² +

+
+

+ mode +

+
+

+ 0 +

+
+

+ skewness +

+
+

+ (2-p)/√q +

+
+

+ kurtosis +

+
+

+ 9+p²/q +

+
+

+ kurtosis excess +

+
+

+ 6 +p²/q +

+
+

+ parameter estimation member functions +

+
+

+ See Negative + Binomial Distribution +

+
+

+ find_lower_bound_on_p +

+
+

+ See Negative + Binomial Distribution +

+
+

+ find_upper_bound_on_p +

+
+

+ See Negative + Binomial Distribution +

+
+

+ find_minimum_number_of_trials +

+
+

+ See Negative + Binomial Distribution +

+
+

+ find_maximum_number_of_trials +

+
+

+ See Negative + Binomial Distribution +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hyperexponential_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hyperexponential_dist.html new file mode 100644 index 00000000..fef5ffd4 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hyperexponential_dist.html @@ -0,0 +1,1460 @@ + + + +Hyperexponential Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/hyperexponential.hpp>
+
namespace boost{ namespace math{
+
+template <typename RealType = double,
+          typename Policy   = policies::policy<> >
+class hyperexponential_distribution;
+
+typedef hyperexponential_distribution<> hyperexponential;
+
+template <typename RealType, typename Policy>
+class hyperexponential_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   // Constructors:
+   hyperexponential_distribution();  // Default.
+
+   template <typename RateIterT, typename RateIterT2>
+   hyperexponential_distribution(  // Default equal probabilities.
+                                 RateIterT const& rate_first,
+                                 RateIterT2 const& rate_last);  // Rates using Iterators.
+
+   template <typename ProbIterT, typename RateIterT>
+   hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last,
+                                 RateIterT rate_first, RateIterT rate_last);   // Iterators.
+
+   template <typename ProbRangeT, typename RateRangeT>
+   hyperexponential_distribution(ProbRangeT const& prob_range,
+                                 RateRangeT const& rate_range);  // Ranges.
+
+   template <typename RateRangeT>
+   hyperexponential_distribution(RateRangeT const& rate_range);
+
+ #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)     // C++11 initializer lists supported.
+   hyperexponential_distribution(std::initializer_list<RealType> l1, std::initializer_list<RealType> l2);
+   hyperexponential_distribution(std::initializer_list<RealType> l1);
+ #endif
+
+   // Accessors:
+   std::size_t num_phases() const;
+   std::vector<RealType> probabilities() const;
+   std::vector<RealType> rates() const;
+};
+
+}} // namespaces
+
+
+ + + + + +
[Note]Note

+ An implementation-defined mechanism is provided to avoid ambiguity between + constructors accepting ranges, iterators and constants as parameters. + This should be transparent to the user. See below and the header file + hyperexponential.hpp for details and explanatory comments. +

+

+ The class type hyperexponential_distribution + represents a hyperexponential + distribution. +

+

+ A k-phase hyperexponential distribution is a continuous + probability distribution obtained as a mixture of k + Exponential Distributions. + It is also referred to as mixed exponential distribution + or parallel k-phase exponential distribution. +

+

+ A k-phase hyperexponential distribution is characterized + by two parameters, namely a phase probability vector + α=(α1,...,αk) and a + rate vector λ=(λ1,...,λk). +

+

+ The probability + density function for random variate x in a + hyperexponential distribution is given by: +

+

+ +

+

+ The following graph illustrates the PDF of the hyperexponential distribution + with five different parameters, namely: +

+
    +
  1. + α=(1.0) and λ=(1.0) (which degenerates to a simple + exponential distribution), +
  2. +
  3. + α=(0.1, 0.9) and + λ=(0.5, 1.5), +
  4. +
  5. + α=(0.9, 0.1) and + λ=(0.5, 1.5), +
  6. +
  7. + α=(0.2, 0.3, 0.5) + and λ=(0.5, 1.0, 1.5), +
  8. +
  9. + α=(0.5, 0.3, 0.2) + and λ=(0.5, 1.0, 1.5). +
  10. +
+

+ +

+

+ Also, the following graph illustrates the PDF of the hyperexponential distribution + (solid lines) where only the phase probability vector + changes together with the PDF of the two limiting exponential distributions + (dashed lines): +

+
    +
  1. + α=(0.1, 0.9) and + λ=(0.5, 1.5), +
  2. +
  3. + α=(0.6, 0.4) and + λ=(0.5, 1.5), +
  4. +
  5. + α=(0.9, 0.1) and + λ=(0.5, 1.5), +
  6. +
  7. + Exponential distribution with parameter λ=0.5, +
  8. +
  9. + Exponential distribution with parameter λ=1.5. +
  10. +
+

+ As expected, as the first element α1 of the phase + probability vector approaches to 1 (or, + equivalently, α2 approaches to 0), + the resulting hyperexponential distribution nears the exponential distribution + with parameter λ=0.5. Conversely, as the first element + α2 of the phase probability vector + approaches to 1 (or, equivalently, α1 + approaches to 0), the resulting hyperexponential distribution + nears the exponential distribution with parameter λ=1.5. +

+

+ +

+

+ Finally, the following graph compares the PDF of the hyperexponential distribution + with different number of phases but with the same mean value equal to + 2: +

+
    +
  1. + α=(1.0) and λ=(2.0) (which degenerates to a simple + exponential distribution), +
  2. +
  3. + α=(0.5, 0.5) and + λ=(0.3, 1.5), +
  4. +
  5. + α=(1.0/3.0, 1.0/3.0, 1.0/3.0) + and λ=(0.2, 1.5, 3.0), +
  6. +
+

+ +

+

+ As can be noted, even if the three distributions have the same mean value, + the two hyperexponential distributions have a longer + tail with respect to the one of the exponential distribution. Indeed, the + hyperexponential distribution has a larger variability than the exponential + distribution, thus resulting in a Coefficient + of Variation greater than 1 (as opposed to + the one of the exponential distribution which is exactly 1). +

+

+ + Applications +

+

+ A k-phase hyperexponential distribution is frequently + used in queueing + theory to model the distribution of the superposition of k + independent events, like, for instance, the service time distribution of + a queueing station with k servers in parallel where + the i-th server is chosen with probability αi + and its service time distribution is an exponential distribution with rate + λi (Allen,1990; Papadopolous et al.,1993; Trivedi,2002). +

+

+ For instance, CPUs service-time distribution in a computing system has + often been observed to possess such a distribution (Rosin,1965). Also, + the arrival of different types of customer to a single queueing station + is often modeled as a hyperexponential distribution (Papadopolous et al.,1993). + Similarly, if a product manufactured in several parallel assembly lines + and the outputs are merged, the failure density of the overall product + is likely to be hyperexponential (Trivedi,2002). +

+

+ Finally, since the hyperexponential distribution exhibits a high Coefficient + of Variation (CoV), that is a CoV > 1, it is especially suited to fit + empirical data with large CoV (Feitelson,2014; Wolski et al.,2013) and + to approximate long-tail + probability distributions (Feldmann et al.,1998). +

+

+ + Related + distributions +

+
    +
  • + When the number of phases k is equal to 1, the hyperexponential distribution + is simply an Exponential + Distribution. +
  • +
  • + When the k rates are all equal to λ, + the hyperexponential distribution is simple an Exponential + Distribution with rate λ. +
  • +
+

+ + Examples +

+
+ + Lifetime + of Appliances +
+

+ Suppose a customer is buying an appliance and is choosing at random between + an appliance with average lifetime of 10 years and an appliance with average + lifetime of 12 years. Assuming the lifetime of this appliance follows an + exponential distribution, the lifetime distribution of the purchased appliance + can be modeled as a hyperexponential distribution with phase probability + vector α=(1/2,1/2) + and rate vector λ=(1/10,1/12) + (Wolfram,2014). +

+

+ In the rest of this section, we provide an example C++ implementation for + computing the average lifetime and the probability that the appliance will + work for more than 15 years. +

+
#include <boost/math/distributions/hyperexponential.hpp>
+#include <iostream>
+int main()
+{
+   const double rates[] = { 1.0 / 10.0, 1.0 / 12.0 };
+
+   boost::math::hyperexponential he(rates);
+
+   std::cout << "Average lifetime: "
+      << boost::math::mean(he)
+      << " years" << std::endl;
+   std::cout << "Probability that the appliance will work for more than 15 years: "
+      << boost::math::cdf(boost::math::complement(he, 15.0))
+      << std::endl;
+}
+
+

+ The resulting output is: +

+
Average lifetime: 11 years
+Probability that the appliance will work for more than 15 years: 0.254817
+
+
+ + Workloads + of Private Cloud Computing Systems +
+

+ Cloud computing + has become a popular metaphor for dynamic and secure self-service access + to computational and storage capabilities. In (Wolski et al.,2013), the + authors analyze and model workloads gathered from enterprise-operated commercial + private + clouds and show that 3-phase hyperexponential distributions (fitted + using the Expectation + Maximization algorithm) capture workload attributes accurately. +

+

+ In this type of computing system, user requests consist in demanding the + provisioning of one or more Virtual + Machines (VMs). In particular, in (Wolski et al.,2013) the workload + experienced by each cloud system is a function of four distributions, one + for each of the following workload attributes: +

+
    +
  • + Request Interarrival Time: the amount of time + until the next request, +
  • +
  • + VM Lifetime: the time duration over which a VM + is provisioned to a physical machine, +
  • +
  • + Request Size: the number of VMs in the request, + and +
  • +
  • + Core Count: the CPU core count requested for each + VM. +
  • +
+

+ The authors assume that all VMs in a request have the same core count, + but request sizes and core counts can vary from request to request. Moreover, + all VMs within a request are assumed to have the same lifetime. Given these + assumptions, the authors build a statistical model for the request interarrival + time and VM lifetime attributes by fitting their respective data to a 3-phase + hyperexponential distribution. +

+

+ In the following table, we show the sample mean and standard deviation + (SD), in seconds, of the request interarrival time and of the VM lifetime + distributions of the three datasets collected by authors: +

+
++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Dataset +

+
+

+ Mean Request Interarrival Time (SD) +

+
+

+ Mean Multi-core VM Lifetime (SD) +

+
+

+ Mean Single-core VM Lifetime (SD) +

+
+

+ DS1 +

+
+

+ 2202.1 (2.2e+04) +

+
+

+ 257173 (4.6e+05) +

+
+

+ 28754.4 (1.6e+05) +

+
+

+ DS2 +

+
+

+ 41285.7 (1.1e+05) +

+
+

+ 144669.0 (7.9e+05) +

+
+

+ 599815.0 (1.7e+06) +

+
+

+ DS3 +

+
+

+ 11238.8 (3.0e+04) +

+
+

+ 30739.2 (1.6e+05) +

+
+

+ 44447.8 (2.2e+05) +

+
+

+ Whereas in the following table we show the hyperexponential distribution + parameters resulting from the fit: +

+
++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Dataset +

+
+

+ Request Interarrival Time +

+
+

+ Multi-core VM Lifetime +

+
+

+ Single-core VM Lifetime +

+
+

+ DS1 +

+
+

+ α=(0.34561,0.08648,0.56791), + λ=(0.008,0.00005,0.02894) +

+
+

+ α=(0.24667,0.37948,0.37385), + λ=(0.00004,0.000002,0.00059) +

+
+

+ α=(0.09325,0.22251,0.68424), + λ=(0.000003,0.00109,0.00109) +

+
+

+ DS2 +

+
+

+ α=(0.38881,0.18227,0.42892), + λ=(0.000006,0.05228,0.00081) +

+
+

+ α=(0.42093,0.43960,0.13947), + λ=(0.00186,0.00008,0.0000008) +

+
+

+ α=(0.44885,0.30675,0.2444), + λ=(0.00143,0.00005,0.0000004) +

+
+

+ DS3 +

+
+

+ α=(0.39442,0.24644,0.35914), + λ=(0.00030,0.00003,0.00257) +

+
+

+ α=(0.37621,0.14838,0.47541), + λ=(0.00498,0.000005,0.00022) +

+
+

+ α=(0.34131,0.12544,0.53325), + λ=(0.000297,0.000003,0.00410) +

+
+

+ In the rest of this section, we provide an example C++ implementation for + computing some statistical properties of the fitted distributions for each + of the analyzed dataset. +

+
#include <boost/math/distributions.hpp>
+#include <iostream>
+#include <string>
+
+struct ds_info
+{
+   std::string name;
+   double iat_sample_mean;
+   double iat_sample_sd;
+   boost::math::hyperexponential iat_he;
+   double multi_lt_sample_mean;
+   double multi_lt_sample_sd;
+   boost::math::hyperexponential multi_lt_he;
+   double single_lt_sample_mean;
+   double single_lt_sample_sd;
+   boost::math::hyperexponential single_lt_he;
+};
+
+// DS1 dataset
+ds_info make_ds1()
+{
+   ds_info ds;
+
+   ds.name = "DS1";
+
+   // VM interarrival time distribution
+   const double iat_fit_probs[] = { 0.34561,0.08648,0.56791 };
+   const double iat_fit_rates[] = { 0.0008,0.00005,0.02894 };
+   ds.iat_sample_mean = 2202.1;
+   ds.iat_sample_sd = 2.2e+4;
+   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);
+
+   // Multi-core VM lifetime distribution
+   const double multi_lt_fit_probs[] = { 0.24667,0.37948,0.37385 };
+   const double multi_lt_fit_rates[] = { 0.00004,0.000002,0.00059 };
+   ds.multi_lt_sample_mean = 257173;
+   ds.multi_lt_sample_sd = 4.6e+5;
+   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);
+
+   // Single-core VM lifetime distribution
+   const double single_lt_fit_probs[] = { 0.09325,0.22251,0.68424 };
+   const double single_lt_fit_rates[] = { 0.000003,0.00109,0.00109 };
+   ds.single_lt_sample_mean = 28754.4;
+   ds.single_lt_sample_sd = 1.6e+5;
+   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);
+
+   return ds;
+}
+
+// DS2 dataset
+ds_info make_ds2()
+{
+   ds_info ds;
+
+   ds.name = "DS2";
+
+   // VM interarrival time distribution
+   const double iat_fit_probs[] = { 0.38881,0.18227,0.42892 };
+   const double iat_fit_rates[] = { 0.000006,0.05228,0.00081 };
+   ds.iat_sample_mean = 41285.7;
+   ds.iat_sample_sd = 1.1e+05;
+   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);
+
+   // Multi-core VM lifetime distribution
+   const double multi_lt_fit_probs[] = { 0.42093,0.43960,0.13947 };
+   const double multi_lt_fit_rates[] = { 0.00186,0.00008,0.0000008 };
+   ds.multi_lt_sample_mean = 144669.0;
+   ds.multi_lt_sample_sd = 7.9e+05;
+   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);
+
+   // Single-core VM lifetime distribution
+   const double single_lt_fit_probs[] = { 0.44885,0.30675,0.2444 };
+   const double single_lt_fit_rates[] = { 0.00143,0.00005,0.0000004 };
+   ds.single_lt_sample_mean = 599815.0;
+   ds.single_lt_sample_sd = 1.7e+06;
+   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);
+
+   return ds;
+}
+
+// DS3 dataset
+ds_info make_ds3()
+{
+   ds_info ds;
+
+   ds.name = "DS3";
+
+   // VM interarrival time distribution
+   const double iat_fit_probs[] = { 0.39442,0.24644,0.35914 };
+   const double iat_fit_rates[] = { 0.00030,0.00003,0.00257 };
+   ds.iat_sample_mean = 11238.8;
+   ds.iat_sample_sd = 3.0e+04;
+   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);
+
+   // Multi-core VM lifetime distribution
+   const double multi_lt_fit_probs[] = { 0.37621,0.14838,0.47541 };
+   const double multi_lt_fit_rates[] = { 0.00498,0.000005,0.00022 };
+   ds.multi_lt_sample_mean = 30739.2;
+   ds.multi_lt_sample_sd = 1.6e+05;
+   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);
+
+   // Single-core VM lifetime distribution
+   const double single_lt_fit_probs[] = { 0.34131,0.12544,0.53325 };
+   const double single_lt_fit_rates[] = { 0.000297,0.000003,0.00410 };
+   ds.single_lt_sample_mean = 44447.8;
+   ds.single_lt_sample_sd = 2.2e+05;
+   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);
+
+   return ds;
+}
+
+void print_fitted(ds_info const& ds)
+{
+   const double secs_in_a_hour = 3600;
+   const double secs_in_a_month = 30 * 24 * secs_in_a_hour;
+
+   std::cout << "### " << ds.name << std::endl;
+   std::cout << "* Fitted Request Interarrival Time" << std::endl;
+   std::cout << " - Mean (SD): " << boost::math::mean(ds.iat_he) << " (" << boost::math::standard_deviation(ds.iat_he) << ") seconds." << std::endl;
+   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.iat_he, 0.99) << " seconds." << std::endl;
+   std::cout << " - Probability that a VM will arrive within 30 minutes: " << boost::math::cdf(ds.iat_he, secs_in_a_hour / 2.0) << std::endl;
+   std::cout << " - Probability that a VM will arrive after 1 hour: " << boost::math::cdf(boost::math::complement(ds.iat_he, secs_in_a_hour)) << std::endl;
+   std::cout << "* Fitted Multi-core VM Lifetime" << std::endl;
+   std::cout << " - Mean (SD): " << boost::math::mean(ds.multi_lt_he) << " (" << boost::math::standard_deviation(ds.multi_lt_he) << ") seconds." << std::endl;
+   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.multi_lt_he, 0.99) << " seconds." << std::endl;
+   std::cout << " - Probability that a VM will last for less than 1 month: " << boost::math::cdf(ds.multi_lt_he, secs_in_a_month) << std::endl;
+   std::cout << " - Probability that a VM will last for more than 3 months: " << boost::math::cdf(boost::math::complement(ds.multi_lt_he, 3.0*secs_in_a_month)) << std::endl;
+   std::cout << "* Fitted Single-core VM Lifetime" << std::endl;
+   std::cout << " - Mean (SD): " << boost::math::mean(ds.single_lt_he) << " (" << boost::math::standard_deviation(ds.single_lt_he) << ") seconds." << std::endl;
+   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.single_lt_he, 0.99) << " seconds." << std::endl;
+   std::cout << " - Probability that a VM will last for less than 1 month: " << boost::math::cdf(ds.single_lt_he, secs_in_a_month) << std::endl;
+   std::cout << " - Probability that a VM will last for more than 3 months: " << boost::math::cdf(boost::math::complement(ds.single_lt_he, 3.0*secs_in_a_month)) << std::endl;
+}
+
+int main()
+{
+   print_fitted(make_ds1());
+
+   print_fitted(make_ds2());
+
+   print_fitted(make_ds3());
+}
+
+

+ The resulting output (with floating-point precision set to 2) is: +

+
### DS1
+* Fitted Request Interarrival Time
+ - Mean (SD): 2.2e+03 (8.1e+03) seconds.
+ - 99th Percentile: 4.3e+04 seconds.
+ - Probability that a VM will arrive within 30 minutes: 0.84
+ - Probability that a VM will arrive after 1 hour: 0.092
+* Fitted Multi-core VM Lifetime
+ - Mean (SD): 2e+05 (3.9e+05) seconds.
+ - 99th Percentile: 1.8e+06 seconds.
+ - Probability that a VM will last for less than 1 month: 1
+ - Probability that a VM will last for more than 3 months: 6.7e-08
+* Fitted Single-core VM Lifetime
+ - Mean (SD): 3.2e+04 (1.4e+05) seconds.
+ - 99th Percentile: 7.4e+05 seconds.
+ - Probability that a VM will last for less than 1 month: 1
+ - Probability that a VM will last for more than 3 months: 6.9e-12
+### DS2
+* Fitted Request Interarrival Time
+ - Mean (SD): 6.5e+04 (1.3e+05) seconds.
+ - 99th Percentile: 6.1e+05 seconds.
+ - Probability that a VM will arrive within 30 minutes: 0.52
+ - Probability that a VM will arrive after 1 hour: 0.4
+* Fitted Multi-core VM Lifetime
+ - Mean (SD): 1.8e+05 (6.4e+05) seconds.
+ - 99th Percentile: 3.3e+06 seconds.
+ - Probability that a VM will last for less than 1 month: 0.98
+ - Probability that a VM will last for more than 3 months: 0.00028
+* Fitted Single-core VM Lifetime
+ - Mean (SD): 6.2e+05 (1.6e+06) seconds.
+ - 99th Percentile: 8e+06 seconds.
+ - Probability that a VM will last for less than 1 month: 0.91
+ - Probability that a VM will last for more than 3 months: 0.011
+### DS3
+* Fitted Request Interarrival Time
+ - Mean (SD): 9.7e+03 (2.2e+04) seconds.
+ - 99th Percentile: 1.1e+05 seconds.
+ - Probability that a VM will arrive within 30 minutes: 0.53
+ - Probability that a VM will arrive after 1 hour: 0.36
+* Fitted Multi-core VM Lifetime
+ - Mean (SD): 3.2e+04 (1e+05) seconds.
+ - 99th Percentile: 5.4e+05 seconds.
+ - Probability that a VM will last for less than 1 month: 1
+ - Probability that a VM will last for more than 3 months: 1.9e-18
+* Fitted Single-core VM Lifetime
+ - Mean (SD): 4.3e+04 (1.6e+05) seconds.
+ - 99th Percentile: 8.4e+05 seconds.
+ - Probability that a VM will last for less than 1 month: 1
+ - Probability that a VM will last for more than 3 months: 9.3e-12
+
+
+ + + + + +
[Note]Note

+ The above results differ from the ones shown in Tables III, V, and VII + of (Wolski et al.,2013). We carefully double-checked them with Wolfram + Mathematica 10, which confirmed our results. +

+

+ + Member + Functions +

+
+ + Default + Constructor +
+
hyperexponential_distribution();
+
+

+ Constructs a 1-phase hyperexponential distribution + (i.e., an exponential distribution) with rate 1. +

+
+ + Constructor + from Iterators +
+
template <typename ProbIterT, typename RateIterT>
+hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last,
+                              RateIterT rate_first, RateIterT rate_last);
+
+

+ Constructs a hyperexponential distribution with phase probability + vector parameter given by the range defined by [prob_first, prob_last) + iterator pair, and rate vector parameter given by + the range defined by the [rate_first, + rate_last) iterator pair. +

+
+ + Parameters +
+
    +
  • + prob_first, prob_last: the range of non-negative + real elements representing the phase probabilities; elements are normalized + to sum to unity. +
  • +
  • + rate_first, rate_last: the range of positive + elements representing the rates. +
  • +
+
+ + Type + Requirements +
+
  • + ProbIterT, RateIterT: must meet the requirements + of the InputIterator + concept. +
+
+ + Example +
+
std::array<double, 2> phase_prob = { 0.5, 0.5 };
+std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };
+
+hyperexponential he(phase_prob.begin(), phase_prob.end(), rates.begin(), rates.end());
+
+
+ + Construction + from Ranges/Containers +
+
template <typename ProbRangeT, typename RateRangeT>
+hyperexponential_distribution(ProbRangeT const& prob_range,
+                              RateRangeT const& rate_range);
+
+

+ Constructs a hyperexponential distribution with phase probability + vector parameter given by the range defined by prob_range, and rate vector + parameter given by the range defined by rate_range. +

+
+ + + + + +
[Note]Note

+ As an implementation detail, this constructor uses Boost's enable_if/disable_if + mechanism to disambiguate between this and other 2-argument constructors. + Refer to the source code for more details. +

+
+ + Parameters +
+
    +
  • + prob_range: the range + of non-negative real elements representing the phase probabilities; + elements are normalized to sum to unity. +
  • +
  • + rate_range: the range + of positive real elements representing the rates. +
  • +
+
+ + Type + Requirements +
+
  • + ProbRangeT, RateRangeT: must meet the requirements + of the Range + concept: that includes native C++ arrays, standard library containers, + or a std::pair or iterators. +
+
+ + Examples +
+
// We could be using any standard library container here... vector, deque, array, list etc:
+std::array<double, 2> phase_prob = { 0.5, 0.5 };
+std::array<double, 2> rates      = { 1.0 / 10, 1.0 / 12 };
+
+hyperexponential he1(phase_prob, rates);    // Construct from standard library container.
+
+double phase_probs2[] = { 0.5, 0.5 };
+double rates2[]       = { 1.0 / 10, 1.0 / 12 };
+
+hyperexponential he2(phase_probs2, rates2);  // Construct from native C++ array.
+
+
+ + Construction + with rates-iterators (and all phase probabilities equal) +
+
template <typename RateIterT, typename RateIterT2>
+hyperexponential_distribution(RateIterT const& rate_first,
+                              RateIterT2 const& rate_last);
+
+

+ Constructs a hyperexponential distribution with rate vector + parameter given by the range defined by the [rate_first, + rate_last) iterator pair, + and phase probability vector set to the equal phase + probabilities (i.e., to a vector of the same length n + of the rate vector and with each element set to 1.0/n). +

+
+ + + + + +
[Note]Note

+ As an implementation detail, this constructor uses Boost's enable_if/disable_if + mechanism to disambiguate between this and other 2-argument constructors. + Refer to the source code for more details. +

+
+ + Parameters +
+
  • + rate_first, rate_last: the range of positive + elements representing the rates. +
+
+ + Type + Requirements +
+
  • + RateIterT, RateIterT2: must meet the requirements + of the InputIterator + concept. +
+
+ + Example +
+
// We could be using any standard library container here... vector, deque, array, list etc:
+std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };
+
+hyperexponential he(rates.begin(), rates.end());
+
+assert(he.probabilities()[0] == 0.5); // Phase probabilities will be equal and normalised to unity.
+
+
+ + Construction + from a single range of rates (all phase probabilities will be equal) +
+
template <typename RateRangeT>
+hyperexponential_distribution(RateRangeT const& rate_range);
+
+

+ Constructs a hyperexponential distribution with rate vector + parameter given by the range defined by rate_range, + and phase probability vector set to the equal phase + probabilities (i.e., to a vector of the same length n + of the rate vector and with each element set to 1.0/n). +

+
+ + Parameters +
+
  • + rate_range: the range + of positive real elements representing the rates. +
+
+ + Type + Requirements +
+
  • + RateRangeT: must meet + the requirements of the Range + concept: this includes native C++ array, standard library containers, + and a std::pair of iterators. +
+
+ + Examples +
+
std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };
+
+hyperexponential he(rates);
+
+assert(he.probabilities()[0] == 0.5); // Phase probabilities will be equal and normalised to unity.
+
+
+ + Construction + from Initializer lists +
+
hyperexponential_distribution(std::initializer_list<RealType> l1, std::initializer_list<RealType> l2);
+
+

+ Constructs a hyperexponential distribution with phase probability + vector parameter given by the brace-init-list + defined by l1, and rate + vector parameter given by the brace-init-list + defined by l2. +

+
+ + Parameters +
+
    +
  • + l1: the brace-init-list + of non-negative real elements representing the phase probabilities; + elements are normalized to sum to unity. +
  • +
  • + l2: the brace-init-list + of positive real elements representing the rates. +
  • +
+

+ The number of elements of the phase probabilities list and the rates list + must be the same. +

+
+ + Example +
+
hyperexponential he = { { 0.5, 0.5 }, { 1.0 / 10, 1.0 / 12 } };
+
+
+ + Construction + from a single initializer list (all phase probabilities will be equal) +
+
hyperexponential_distribution(std::initializer_list<RealType> l1);
+
+

+ Constructs a hyperexponential distribution with rate vector + parameter given by the brace-init-list + defined by l1, and phase + probability vector set to the equal phase probabilities (i.e., + to a vector of the same length n + of the rate vector and with each element set to 1.0/n). +

+
+ + Parameters +
+
  • + l1: the brace-init-list + of non-negative real elements representing the phase probabilities; + they are normalized to ensure that they sum to unity. +
+
+ + Example +
+
hyperexponential he = { 1.0 / 10, 1.0 / 12 };
+
+assert(he.probabilities()[0] == 0.5);
+
+
+ + Accessors +
+
std::size_t num_phases() const;
+
+

+ Gets the number of phases of this distribution (the size of both the rate + and probability vectors). +

+
+ + Return + Value +
+

+ An non-negative integer number representing the number of phases of this + distribution. +

+
std::vector<RealType> probabilities() const;
+
+

+ Gets the phase probability vector parameter of this + distribution. +

+
+ + + + + +
[Note]Note

+ The returned probabilities are the normalized + versions of the probability parameter values passed at construction time. +

+
+ + Return + Value +
+

+ A vector of non-negative real numbers representing the phase + probability vector parameter of this distribution. +

+
std::vector<RealType> rates() const;
+
+

+ Gets the rate vector parameter of this distribution. +

+
+ + Return + Value +
+

+ A vector of positive real numbers representing the rate vector + parameter of this distribution. +

+
+ + + + + +
[Warning]Warning
+

+ The return type of these functions is a vector-by-value. This is deliberate + as we wish to hide the actual container used internally which may be + subject to future changes (for example to facilitate vectorization of + the cdf code etc). Users should note that some code that might otherwise + have been expected to work does not. For example, an attempt to output + the (normalized) probabilities: +

+
std::copy(he.probabilities().begin(), he.probabilities().end(), std::ostream_iterator<double>(std::cout, " "));
+
+

+ fails at compile or runtime because iterator types are incompatible, + but, for example, +

+
std::cout << he.probabilities()[0] << ' ' << he.probabilities()[1] << std::endl;
+
+

+ outputs the expected values. +

+

+ In general if you want to access a member of the returned container, + then assign to a variable first, and then access those members: +

+
std::vector<double> t = he.probabilities();
+std::copy(t.begin(), t.end(), std::ostream_iterator<double>(std::cout, " "));
+
+
+

+ + Non-member + Accessor Functions +

+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The formulae for calculating these are shown in the table below. +

+

+ + Accuracy +

+

+ The hyperexponential distribution is implemented in terms of the Exponential Distribution + and as such should have very small errors, usually an epsilon + or few. +

+

+ + Implementation +

+

+ In the following table: +

+
    +
  • + α=(α1,...,αk) is + the phase probability vector parameter of the + k-phase hyperexponential distribution, +
  • +
  • + λ=(λ1,...,λk) is + the rate vector parameter of the k-phase + hyperexponential distribution, +
  • +
  • + x is the random variate. +
  • +
+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ support +

+
+

+ x ∈ [0,∞) +

+
+

+ pdf +

+
+

+ +

+
+

+ cdf +

+
+

+ +

+
+

+ cdf complement +

+
+

+ +

+
+

+ quantile +

+
+

+ No closed form available. Computed numerically. +

+
+

+ quantile from the complement +

+
+

+ No closed form available. Computed numerically. +

+
+

+ mean +

+
+

+ +

+
+

+ variance +

+
+

+ +

+
+

+ mode +

+
+

+ 0 +

+
+

+ skewness +

+
+

+ +

+
+

+ kurtosis +

+
+

+ +

+
+

+ kurtosis excess +

+
+

+ kurtosis - 3 +

+
+

+ + References +

+
    +
  • + A.O. Allen, Probability, Statistics, and Queuing Theory with + Computer Science Applications, Second Edition, Academic + Press, 1990. +
  • +
  • + D.G. Feitelson, Workload Modeling for Computer Systems Performance + Evaluation, Cambridge University Press, 2014 +
  • +
  • + A. Feldmann and W. Whitt, Fitting mixtures of exponentials + to long-tail distributions to analyze network performance models, + Performance Evaluation 31(3-4):245, doi:10.1016/S0166-5316(97)00003-5, + 1998. +
  • +
  • + H.T. Papadopolous, C. Heavey and J. Browne, Queueing Theory + in Manufacturing Systems Analysis and Design, Chapman & + Hall/CRC, 1993, p. 35. +
  • +
  • + R.F. Rosin, Determining a computing center environment, + Communications of the ACM 8(7):463-468, 1965. +
  • +
  • + K.S. Trivedi, Probability and Statistics with Reliability, + Queueing, and Computer Science Applications, John Wiley + & Sons, Inc., 2002. +
  • +
  • + Wikipedia, Hyperexponential Distribution, Online: + http://en.wikipedia.org/wiki/Hyperexponential_distribution, + 2014 +
  • +
  • + R. Wolski and J. Brevik, Using Parametric Models to Represent + Private Cloud Workloads, IEEE TSC, PrePrint, DOI: 10.1109/TSC.2013.48, + 2013. +
  • +
  • + Wolfram Mathematica, Hyperexponential Distribution, + Online: http://reference.wolfram.com/language/ref/HyperexponentialDistribution.html, + 2014. +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html new file mode 100644 index 00000000..bf0e8e62 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html @@ -0,0 +1,339 @@ + + + +Hypergeometric Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/hypergeometric.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class hypergeometric_distribution;
+
+template <class RealType, class Policy>
+class hypergeometric_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   hypergeometric_distribution(unsigned r, unsigned n, unsigned N);
+   // Accessors:
+   unsigned total()const;
+   unsigned defective()const;
+   unsigned sample_count()const;
+};
+
+typedef hypergeometric_distribution<> hypergeometric;
+
+}} // namespaces
+
+

+ The hypergeometric distribution describes the number of "events" + k from a sample n drawn from + a total population N without replacement. +

+

+ Imagine we have a sample of N objects of which r + are "defective" and N-r are "not defective" (the terms + "success/failure" or "red/blue" are also used). If + we sample n items without replacement + then what is the probability that exactly k items + in the sample are defective? The answer is given by the pdf of the hypergeometric + distribution f(k; r, n, + N), + whilst the probability of k defectives or fewer is + given by F(k; r, n, N), where F(k) is the CDF of the hypergeometric distribution. +

+
+ + + + + +
[Note]Note

+ Unlike almost all of the other distributions in this library, the hypergeometric + distribution is strictly discrete: it can not be extended to real valued + arguments of its parameters or random variable. +

+

+ The following graph shows how the distribution changes as the proportion + of "defective" items changes, while keeping the population and + sample sizes constant: +

+

+ +

+

+ Note that since the distribution is symmetrical in parameters n + and r, if we change the sample size and keep the population + and proportion "defective" the same then we obtain basically + the same graphs: +

+

+ +

+
+ + Member + Functions +
+
hypergeometric_distribution(unsigned r, unsigned n, unsigned N);
+
+

+ Constructs a hypergeometric distribution with a population of N + objects, of which r are defective, and from which + n are sampled. +

+
unsigned total()const;
+
+

+ Returns the total number of objects N. +

+
unsigned defective()const;
+
+

+ Returns the number of objects r in population N + which are defective. +

+
unsigned sample_count()const;
+
+

+ Returns the number of objects n which are sampled + from the population N. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is the unsigned integers in the range + [max(0, n + r - N), min(n, r)]. A domain_error + is raised if the random variable is outside this range, or is not an integral + value. +

+
+ + + + + +
[Caution]Caution
+

+ The quantile function will by default return an integer result that has + been rounded outwards. That is to say lower quantiles + (where the probability is less than 0.5) are rounded downward, and upper + quantiles (where the probability is greater than 0.5) are rounded upwards. + This behaviour ensures that if an X% quantile is requested, then at + least the requested coverage will be present in the central + region, and no more than the requested coverage + will be present in the tails. +

+

+ This behaviour can be changed so that the quantile functions are rounded + differently using Policies. + It is strongly recommended that you read the tutorial Understanding + Quantiles of Discrete Distributions before using the quantile + function on the Hypergeometric distribution. The reference + docs describe how to change the rounding policy for these distributions. +

+

+ However, note that the implementation method of the quantile function + always returns an integral value, therefore attempting to use a Policy that requires (or produces) a real valued + result will result in a compile time error. +

+
+
+ + Accuracy +
+

+ For small N such that N < boost::math::max_factorial<RealType>::value + then table based lookup of the results gives an accuracy to a few epsilon. + boost::math::max_factorial<RealType>::value is 170 at double or long double + precision. +

+

+ For larger N such that N < boost::math::prime(boost::math::max_prime) then only basic arithmetic is required + for the calculation and the accuracy is typically < 20 epsilon. This + takes care of N up to 104729. +

+

+ For N > + boost::math::prime(boost::math::max_prime) + then accuracy quickly degrades, with 5 or 6 decimal digits being lost for + N = 110000. +

+

+ In general for very large N, the user should expect to lose log10N decimal + digits of precision during the calculation, with the results becoming meaningless + for N >= 1015. +

+
+ + Testing +
+

+ There are three sets of tests: our implementation is tested against a table + of values produced by Mathematica's implementation of this distribution. + We also sanity check our implementation against some spot values computed + using the online calculator here http://stattrek.com/Tables/Hypergeometric.aspx. + Finally we test accuracy against some high precision test data using this + implementation and NTL::RR. +

+
+ + Implementation +
+

+ The PDF can be calculated directly using the formula: +

+

+ +

+

+ However, this can only be used directly when the largest of the factorials + is guaranteed not to overflow the floating point representation used. This + formula is used directly when N + < max_factorial<RealType>::value + in which case table lookup of the factorials gives a rapid and accurate + implementation method. +

+

+ For larger N the method described in "An Accurate + Computation of the Hypergeometric Distribution Function", Trong Wu, + ACM Transactions on Mathematical Software, Vol. 19, No. 1, March 1993, + Pages 33-43 is used. The method relies on the fact that there is an easy + method for factorising a factorial into the product of prime numbers: +

+

+ +

+

+ Where pi is the i'th prime number, and ei is a small positive integer or + zero, which can be calculated via: +

+

+ +

+

+ Further we can combine the factorials in the expression for the PDF to + yield the PDF directly as the product of prime numbers: +

+

+ +

+

+ With this time the exponents ei being either positive, negative or zero. + Indeed such a degree of cancellation occurs in the calculation of the ei that + many are zero, and typically most have a magnitude or no more than 1 or + 2. +

+

+ Calculation of the product of the primes requires some care to prevent + numerical overflow, we use a novel recursive method which splits the calculation + into a series of sub-products, with a new sub-product started each time + the next multiplication would cause either overflow or underflow. The sub-products + are stored in a linked list on the program stack, and combined in an order + that will guarantee no overflow or unnecessary-underflow once the last + sub-product has been calculated. +

+

+ This method can be used as long as N is smaller than the largest prime + number we have stored in our table of primes (currently 104729). The method + is relatively slow (calculating the exponents requires the most time), + but requires only a small number of arithmetic operations to calculate + the result (indeed there is no shorter method involving only basic arithmetic + once the exponents have been found), the method is therefore much more + accurate than the alternatives. +

+

+ For much larger N, we can calculate the PDF from the factorials using either + lgamma, or by directly combining lanczos approximations to avoid calculating + via logarithms. We use the latter method, as it is usually 1 or 2 decimal + digits more accurate than computing via logarithms with lgamma. However, + in this area where N > 104729, the user should expect to lose around + log10N decimal digits during the calculation in the worst case. +

+

+ The CDF and its complement is calculated by directly summing the PDF's. + We start by deciding whether the CDF, or its complement, is likely to be + the smaller of the two and then calculate the PDF at k + (or k+1 if we're calculating the complement) and calculate + successive PDF values via the recurrence relations: +

+

+ +

+

+ Until we either reach the end of the distributions domain, or the next + PDF value to be summed would be too small to affect the result. +

+

+ The quantile is calculated in a similar manner to the CDF: we first guess + which end of the distribution we're nearer to, and then sum PDFs starting + from the end of the distribution this time, until we have some value k + that gives the required CDF. +

+

+ The median is simply the quantile at 0.5, and the remaining properties + are calculated via: +

+

+ +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_chi_squared_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_chi_squared_dist.html new file mode 100644 index 00000000..5f0727e7 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_chi_squared_dist.html @@ -0,0 +1,471 @@ + + + +Inverse Chi Squared Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/inverse_chi_squared.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class inverse_chi_squared_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   inverse_chi_squared_distribution(RealType df = 1); // Not explicitly scaled, default 1/df.
+   inverse_chi_squared_distribution(RealType df, RealType scale = 1/df);  // Scaled.
+
+   RealType degrees_of_freedom()const; // Default 1.
+   RealType scale()const; // Optional scale [xi] (variance), default 1/degrees_of_freedom.
+};
+
+}} // namespace boost // namespace math
+
+

+ The inverse chi squared distribution is a continuous probability distribution + of the reciprocal of a variable distributed + according to the chi squared distribution. +

+

+ The sources below give confusingly different formulae using different symbols + for the distribution pdf, but they are all the same, or related by a change + of variable, or choice of scale. +

+

+ Two constructors are available to implement both the scaled and (implicitly) + unscaled versions. +

+

+ The main version has an explicit scale parameter which implements the + scaled + inverse chi_squared distribution. +

+

+ A second version has an implicit scale = 1/degrees of freedom and gives + the 1st definition in the Wikipedia + inverse chi_squared distribution. The 2nd Wikipedia inverse chi_squared + distribution definition can be implemented by explicitly specifying a scale + = 1. +

+

+ Both definitions are also available in Wolfram Mathematica and in The R Project for Statistical Computing + (geoR) with default scale = 1/degrees of freedom. +

+

+ See +

+
+

+ The inverse_chi_squared distribution is used in Bayesian + statistics: the scaled inverse chi-square is conjugate prior for + the normal distribution with known mean, model parameter σ² (variance). +

+

+ See conjugate + priors including a table of distributions and their priors. +

+

+ See also Inverse + Gamma Distribution and Chi + Squared Distribution. +

+

+ The inverse_chi_squared distribution is a special case of a inverse_gamma + distribution with ν (degrees_of_freedom) shape (α) and scale (β) where +

+

+    α= ν /2 and β = ½. +

+
+ + + + + +
[Note]Note
+

+ This distribution does provide the typedef: +

+
typedef inverse_chi_squared_distribution<double> inverse_chi_squared;
+

+ If you want a double precision + inverse_chi_squared distribution you can use +

+
boost::math::inverse_chi_squared_distribution<>
+

+ or you can write inverse_chi_squared + my_invchisqr(2, 3); +

+
+

+ For degrees of freedom parameter ν, the (unscaled) + inverse chi_squared distribution is defined by the probability density + function (PDF): +

+

+    f(x;ν) = 2-ν/2 x-ν/2-1 e-1/2x / Γ(ν/2) +

+

+ and Cumulative Density Function (CDF) +

+

+    F(x;ν) = Γ(ν/2, 1/2x) / Γ(ν/2) +

+

+ For degrees of freedom parameter ν and scale parameter ξ, the scaled + inverse chi_squared distribution is defined by the probability density + function (PDF): +

+

+    f(x;ν, ξ) = (ξν/2)ν/2 e-νξ/2x x-1-ν/2 / Γ(ν/2) +

+

+ and Cumulative Density Function (CDF) +

+

+    F(x;ν, ξ) = Γ(ν/2, νξ/2x) / Γ(ν/2) +

+

+ The following graphs illustrate how the PDF and CDF of the inverse chi_squared + distribution varies for a few values of parameters ν and ξ: +

+

+ +

+

+ +

+
+ + Member + Functions +
+
inverse_chi_squared_distribution(RealType df = 1); // Implicitly scaled 1/df.
+inverse_chi_squared_distribution(RealType df = 1, RealType scale); // Explicitly scaled.
+
+

+ Constructs an inverse chi_squared distribution with ν degrees of freedom + df, and scale scale with default + value 1/df. +

+

+ Requires that the degrees of freedom ν parameter is greater than zero, otherwise + calls domain_error. +

+
RealType degrees_of_freedom()const;
+
+

+ Returns the degrees_of_freedom ν parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale ξ parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variate is [0,+∞]. +

+
+ + + + + +
[Note]Note

+ Unlike some definitions, this implementation supports a random variate + equal to zero as a special case, returning zero for both pdf and cdf. +

+
+ + Accuracy +
+

+ The inverse gamma distribution is implemented in terms of the incomplete + gamma functions like the Inverse + Gamma Distribution that use gamma_p + and gamma_q and their + inverses gamma_p_inv + and gamma_q_inv: + refer to the accuracy data for those functions for more information. But + in general, gamma (and thus inverse gamma) results are often accurate to + a few epsilon, >14 decimal digits accuracy for 64-bit double. unless + iteration is involved, as for the estimation of degrees of freedom. +

+
+ + Implementation +
+

+ In the following table ν is the degrees of freedom parameter and ξ is the scale + parameter of the distribution, x is the random variate, + p is the probability and q = 1-p + its complement. Parameters α for shape and β for scale are used for the inverse + gamma function: α = ν/2 and β = ν * ξ/2. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(α, + β/ x, β) / x * x +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_q(α, + β / x) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_p(α, + β / x) +

+
+

+ quantile +

+
+

+ Using the relation: x = β  / gamma_q_inv(α, + p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = α  / gamma_p_inv(α, + q) +

+
+

+ mode +

+
+

+ ν * ξ / (ν + 2) +

+
+

+ median +

+
+

+ no closed form analytic equation is known, but is evaluated as + quantile(0.5) +

+
+

+ mean +

+
+

+ νξ / (ν - 2) for ν > 2, else a domain_error +

+
+

+ variance +

+
+

+ 2 ν² ξ² / ((ν -2)² (ν -4)) for ν >4, else a domain_error +

+
+

+ skewness +

+
+

+ 4 √2 √(ν-4) /(ν-6) for ν >6, else a domain_error +

+
+

+ kurtosis_excess +

+
+

+ 12 * (5ν - 22) / ((ν - 6) * (ν - 8)) for ν >8, else a domain_error +

+
+

+ kurtosis +

+
+

+ 3 + 12 * (5ν - 22) / ((ν - 6) * (ν-8)) for ν >8, else a domain_error +

+
+
+ + References +
+
    +
  1. + Bayesian Data Analysis, Andrew Gelman, John B. Carlin, Hal S. Stern, + Donald B. Rubin, ISBN-13: 978-1584883883, Chapman & Hall; 2 edition + (29 July 2003). +
  2. +
  3. + Bayesian Computation with R, Jim Albert, ISBN-13: 978-0387922973, Springer; + 2nd ed. edition (10 Jun 2009) +
  4. +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gamma_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gamma_dist.html new file mode 100644 index 00000000..47b1de29 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gamma_dist.html @@ -0,0 +1,367 @@ + + + +Inverse Gamma Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/inverse_gamma.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class inverse_gamma_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   inverse_gamma_distribution(RealType shape, RealType scale = 1)
+
+   RealType shape()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The inverse_gamma distribution is a continuous probability distribution + of the reciprocal of a variable distributed according to the gamma distribution. +

+

+ The inverse_gamma distribution is used in Bayesian statistics. +

+

+ See inverse + gamma distribution. +

+

+ R + inverse gamma distribution functions. +

+

+ Wolfram + inverse gamma distribution. +

+

+ See also Gamma Distribution. +

+
+ + + + + +
[Note]Note
+

+ In spite of potential confusion with the inverse gamma function, this + distribution does provide the typedef: +

+
typedef inverse_gamma_distribution<double> gamma;
+

+ If you want a double precision + gamma distribution you can use +

+
boost::math::inverse_gamma_distribution<>
+

+ or you can write inverse_gamma + my_ig(2, 3); +

+
+

+ For shape parameter α and scale parameter β, it is defined by the probability + density function (PDF): +

+

+    f(x;α, β) = βα * (1/x) α+1 exp(-β/x) / Γ(α) +

+

+ and cumulative density function (CDF) +

+

+    F(x;α, β) = Γ(α, β/x) / Γ(α) +

+

+ The following graphs illustrate how the PDF and CDF of the inverse gamma + distribution varies as the parameters vary: +

+

+ +

+

+ +

+
+ + Member + Functions +
+
inverse_gamma_distribution(RealType shape = 1, RealType scale = 1);
+
+

+ Constructs an inverse gamma distribution with shape α and scale β. +

+

+ Requires that the shape and scale parameters are greater than zero, otherwise + calls domain_error. +

+
RealType shape()const;
+
+

+ Returns the α shape parameter of this inverse gamma distribution. +

+
RealType scale()const;
+
+

+ Returns the β scale parameter of this inverse gamma distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variate is [0,+∞]. +

+
+ + + + + +
[Note]Note

+ Unlike some definitions, this implementation supports a random variate + equal to zero as a special case, returning zero for pdf and cdf. +

+
+ + Accuracy +
+

+ The inverse gamma distribution is implemented in terms of the incomplete + gamma functions gamma_p + and gamma_q and their + inverses gamma_p_inv + and gamma_q_inv: + refer to the accuracy data for those functions for more information. But + in general, inverse_gamma results are accurate to a few epsilon, >14 + decimal digits accuracy for 64-bit double. +

+
+ + Implementation +
+

+ In the following table α is the shape parameter of the distribution, α   is its + scale parameter, x is the random variate, p + is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = gamma_p_derivative(α, + β/ x, β) / x * x +

+
+

+ cdf +

+
+

+ Using the relation: p = gamma_q(α, + β / x) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_p(α, + β / x) +

+
+

+ quantile +

+
+

+ Using the relation: x = β  / gamma_q_inv(α, + p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = α  / gamma_p_inv(α, + q) +

+
+

+ mode +

+
+

+ β / (α + 1) +

+
+

+ median +

+
+

+ no analytic equation is known, but is evaluated as quantile(0.5) +

+
+

+ mean +

+
+

+ β / (α - 1) for α > 1, else a domain_error +

+
+

+ variance +

+
+

+ (β * β) / ((α - 1) * (α - 1) * (α - 2)) for α >2, else a domain_error +

+
+

+ skewness +

+
+

+ 4 * sqrt (α -2) / (α -3) for α >3, else a domain_error +

+
+

+ kurtosis_excess +

+
+

+ (30 * α - 66) / ((α-3)*(α - 4)) for α >4, else a domain_error +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gaussian_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gaussian_dist.html new file mode 100644 index 00000000..3da08f2e --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gaussian_dist.html @@ -0,0 +1,445 @@ + + + +Inverse Gaussian (or Inverse Normal) Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/inverse_gaussian.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class inverse_gaussian_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   inverse_gaussian_distribution(RealType mean = 1, RealType scale = 1);
+
+   RealType mean()const; // mean default 1.
+   RealType scale()const; // Optional scale, default 1 (unscaled).
+   RealType shape()const; // Shape = scale/mean.
+};
+typedef inverse_gaussian_distribution<double> inverse_gaussian;
+
+}} // namespace boost // namespace math
+
+

+ The Inverse Gaussian distribution distribution is a continuous probability + distribution. +

+

+ The distribution is also called 'normal-inverse Gaussian distribution', + and 'normal Inverse' distribution. +

+

+ It is also convenient to provide unity as default for both mean and scale. + This is the Standard form for all distributions. The Inverse Gaussian distribution + was first studied in relation to Brownian motion. In 1956 M.C.K. Tweedie + used the name Inverse Gaussian because there is an inverse relationship + between the time to cover a unit distance and distance covered in unit + time. The inverse Gaussian is one of family of distributions that have + been called the Tweedie + distributions. +

+

+ (So inverse in the name may mislead: it does not relate to the inverse of a distribution). +

+

+ The tails of the distribution decrease more slowly than the normal distribution. + It is therefore suitable to model phenomena where numerically large values + are more probable than is the case for the normal distribution. For stock + market returns and prices, a key characteristic is that it models that + extremely large variations from typical (crashes) can occur even when almost + all (normal) variations are small. +

+

+ Examples are returns from financial assets and turbulent wind speeds. +

+

+ The normal-inverse Gaussian distributions form a subclass of the generalised + hyperbolic distributions. +

+

+ See distribution. + Weisstein, + Eric W. "Inverse Gaussian Distribution." From MathWorld--A Wolfram + Web Resource. +

+

+ If you want a double precision + inverse_gaussian distribution you can use +

+
boost::math::inverse_gaussian_distribution<>
+

+ or, more conveniently, you can write +

+
using boost::math::inverse_gaussian;
+inverse_gaussian my_ig(2, 3);
+
+

+ For mean parameters μ and scale (also called precision) parameter λ, and random + variate x, the inverse_gaussian distribution is defined by the probability + density function (PDF): +

+

+    f(x;μ, λ) = √(λ/2πx3) e-λ(x-μ)²/2μ²x +

+

+ and Cumulative Density Function (CDF): +

+

+    F(x;μ, λ) = Φ{√(λx) (xμ-1)} + e2μ/λ Φ{-√(λ/μ) (1+x/μ)} +

+

+ where Φ is the standard normal distribution CDF. +

+

+ The following graphs illustrate how the PDF and CDF of the inverse_gaussian + distribution varies for a few values of parameters μ and λ: +

+

+ +

+

+ +

+

+ Tweedie also provided 3 other parameterisations where (μ and λ) are replaced + by their ratio φ = λ/μ and by 1/μ: these forms may be more suitable for Bayesian + applications. These can be found on Seshadri, page 2 and are also discussed + by Chhikara and Folks on page 105. Another related parameterisation, the + __wald_distrib (where mean μ is unity) is also provided. +

+
+ + Member + Functions +
+
inverse_gaussian_distribution(RealType df = 1, RealType scale = 1); // optionally scaled.
+
+

+ Constructs an inverse_gaussian distribution with μ mean, and scale λ, with + both default values 1. +

+

+ Requires that both the mean μ parameter and scale λ are greater than zero, + otherwise calls domain_error. +

+
RealType mean()const;
+
+

+ Returns the mean μ parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale λ parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variate is [0,+∞). +

+
+ + + + + +
[Note]Note

+ Unlike some definitions, this implementation supports a random variate + equal to zero as a special case, returning zero for both pdf and cdf. +

+
+ + Accuracy +
+

+ The inverse_gaussian distribution is implemented in terms of the exponential + function and standard normal distribution N0,1 Φ : refer + to the accuracy data for those functions for more information. But in general, + gamma (and thus inverse gamma) results are often accurate to a few epsilon, + >14 decimal digits accuracy for 64-bit double. +

+
+ + Implementation +
+

+ In the following table μ is the mean parameter and λ is the scale parameter + of the inverse_gaussian distribution, x is the random + variate, p is the probability and q = 1-p + its complement. Parameters μ for shape and λ for scale are used for the inverse + gaussian function. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ √(λ/ 2πx3) e-λ(x - μ)²/ 2μ²x +

+
+

+ cdf +

+
+

+ Φ{√(λx) (xμ-1)} + e2μ/λ Φ{-√(λ/μ) (1+x/μ)} +

+
+

+ cdf complement +

+
+

+ using complement of Φ above. +

+
+

+ quantile +

+
+

+ No closed form known. Estimated using a guess refined by Newton-Raphson + iteration. +

+
+

+ quantile from the complement +

+
+

+ No closed form known. Estimated using a guess refined by Newton-Raphson + iteration. +

+
+

+ mode +

+
+

+ μ {√(1+9μ²/4λ²)² - 3μ/2λ} +

+
+

+ median +

+
+

+ No closed form analytic equation is known, but is evaluated as + quantile(0.5) +

+
+

+ mean +

+
+

+ μ +

+
+

+ variance +

+
+

+ μ³/λ +

+
+

+ skewness +

+
+

+ 3 √ (μ/λ) +

+
+

+ kurtosis_excess +

+
+

+ 15μ/λ +

+
+

+ kurtosis +

+
+

+ 12μ/λ +

+
+
+ + References +
+
    +
  1. + Wald, A. (1947). Sequential analysis. Wiley, NY. +
  2. +
  3. + The Inverse Gaussian distribution : theory, methodology, and applications, + Raj S. Chhikara, J. Leroy Folks. ISBN 0824779975 (1989). +
  4. +
  5. + The Inverse Gaussian distribution : statistical theory and applications, + Seshadri, V , ISBN - 0387986189 (pbk) (Dewey 519.2) (1998). +
  6. +
  7. + Numpy + and Scipy Documentation. +
  8. +
  9. + R + statmod invgauss functions. +
  10. +
  11. + R + SuppDists invGauss functions. (Note that these R implementations + names differ in case). +
  12. +
  13. + StatSci.org invgauss + help. +
  14. +
  15. + invgauss + R source. +
  16. +
  17. + pwald, + qwald. +
  18. +
  19. + Brighton + Webs wald. +
  20. +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/laplace_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/laplace_dist.html new file mode 100644 index 00000000..dbd8b4ad --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/laplace_dist.html @@ -0,0 +1,360 @@ + + + +Laplace Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/laplace.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class laplace_distribution;
+
+typedef laplace_distribution<> laplace;
+
+template <class RealType, class Policy>
+class laplace_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   laplace_distribution(RealType location = 0, RealType scale = 1);
+   // Accessors:
+   RealType location()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ Laplace distribution is the distribution of differences between two independent + variates with identical exponential distributions (Abramowitz and Stegun + 1972, p. 930). It is also called the double exponential distribution. +

+

+ For location parameter μ   and scale parameter σ  , it is defined by the probability + density function: +

+

+ +

+

+ The location and scale parameters are equivalent to the mean and standard + deviation of the normal or Gaussian distribution. +

+

+ The following graph illustrates the effect of the parameters μ   and σ   on the + PDF. Note that the domain of the random variable remains [-∞,+∞] irrespective + of the value of the location parameter: +

+

+ +

+
+ + Member + Functions +
+
laplace_distribution(RealType location = 0, RealType scale = 1);
+
+

+ Constructs a laplace distribution with location location + and scale scale. +

+

+ The location parameter is the same as the mean of the random variate. +

+

+ The scale parameter is proportional to the standard deviation of the random + variate. +

+

+ Requires that the scale parameter is greater than zero, otherwise calls + domain_error. +

+
RealType location()const;
+
+

+ Returns the location parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [-∞,+∞]. +

+
+ + Accuracy +
+

+ The laplace distribution is implemented in terms of the standard library + log and exp functions and as such should have very small errors. +

+
+ + Implementation +
+

+ In the following table μ is the location parameter of the distribution, σ is + its scale parameter, x is the random variate, p + is the probability and its complement q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = e-abs(x-μ) / σ / (2 * σ) +

+
+

+ cdf +

+
+

+ Using the relations: +

+

+ x < μ : p = e(x-μ)/σ / σ +

+

+ x >= μ : p = 1 - e(μ-x)/σ / σ + +

+
+

+ cdf complement +

+
+

+ Using the relation: +

+

+ -x < μ : q = e(-x-μ)/σ / σ +

+

+ -x >= μ : q = 1 - e(μ+x)/σ / σ + +

+
+

+ quantile +

+
+

+ Using the relations: +

+

+ p < 0.5 : x = μ + σ * log(2*p) +

+

+ p >= 0.5 : x = μ - σ * log(2-2*p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: +

+

+ q > 0.5: x = μ + σ*log(2-2*q) +

+

+ q <=0.5: x = μ - σ*log( 2*q ) +

+
+

+ mean +

+
+

+ μ +

+
+

+ variance +

+
+

+ 2 * σ2 +

+
+

+ mode +

+
+

+ μ +

+
+

+ skewness +

+
+

+ 0 +

+
+

+ kurtosis +

+
+

+ 6 +

+
+

+ kurtosis excess +

+
+

+ 3 +

+
+
+ + References +
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/logistic_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/logistic_dist.html new file mode 100644 index 00000000..c2594dd7 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/logistic_dist.html @@ -0,0 +1,298 @@ + + + +Logistic Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/logistic.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class logistic_distribution;
+
+template <class RealType, class Policy>
+class logistic_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   logistic_distribution(RealType location = 0, RealType scale = 1);
+   // Accessors:
+   RealType location()const; // location.
+   RealType scale()const; // scale.
+
+};
+
+typedef logistic_distribution<> logistic;
+
+}} // namespaces
+
+

+ The logistic distribution is a continous probability distribution. It has + two parameters - location and scale. The cumulative distribution function + of the logistic distribution appears in logistic regression and feedforward + neural networks. Among other applications, United State Chess Federation + and FIDE use it to calculate chess ratings. +

+

+ The following graph shows how the distribution changes as the parameters + change: +

+

+ +

+
+ + Member + Functions +
+
logistic_distribution(RealType u = 0, RealType s = 1);
+
+

+ Constructs a logistic distribution with location u + and scale s. +

+

+ Requires scale > + 0, otherwise a domain_error + is raised. +

+
RealType location()const;
+
+

+ Returns the location of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [-[max_value], +[min_value]]. However, + the pdf and cdf support inputs of +∞ and -∞ +as special cases if RealType permits. +

+

+ At p=1 and p=0, the quantile + function returns the result of +overflow_error + and -overflow_error, + while the complement quantile function returns the result of -overflow_error + and +overflow_error + respectively. +

+
+ + Accuracy +
+

+ The logistic distribution is implemented in terms of the std::exp and the std::log + functions, so its accuracy is related to the accurate implementations of + those functions on a given platform. When calculating the quantile with + a non-zero position parameter catastrophic cancellation + errors can occur: in such cases, only a low absolute error + can be guaranteed. +

+
+ + Implementation +
+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = e-(x-u)/s / (s*(1+e-(x-u)/s)2) +

+
+

+ cdf +

+
+

+ Using the relation: p = 1/(1+e-(x-u)/s) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = 1/(1+e(x-u)/s) +

+
+

+ quantile +

+
+

+ Using the relation: x = u - s*log(1/p-1) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = u + s*log(p/1-p) +

+
+

+ mean +

+
+

+ u +

+
+

+ mode +

+
+

+ The same as the mean. +

+
+

+ skewness +

+
+

+ 0 +

+
+

+ kurtosis excess +

+
+

+ 6/5 +

+
+

+ variance +

+
+

+ (π*s)2 / 3 +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/lognormal_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/lognormal_dist.html new file mode 100644 index 00000000..323a452f --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/lognormal_dist.html @@ -0,0 +1,330 @@ + + + +Log Normal Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/lognormal.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class lognormal_distribution;
+
+typedef lognormal_distribution<> lognormal;
+
+template <class RealType, class Policy>
+class lognormal_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   lognormal_distribution(RealType location = 0, RealType scale = 1);
+   // Accessors:
+   RealType location()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The lognormal distribution is the distribution that arises when the logarithm + of the random variable is normally distributed. A lognormal distribution + results when the variable is the product of a large number of independent, + identically-distributed variables. +

+

+ For location and scale parameters m and s + it is defined by the probability density function: +

+

+ +

+

+ The location and scale parameters are equivalent to the mean and standard + deviation of the logarithm of the random variable. +

+

+ The following graph illustrates the effect of the location parameter on + the PDF, note that the range of the random variable remains [0,+∞] irrespective + of the value of the location parameter: +

+

+ +

+

+ The next graph illustrates the effect of the scale parameter on the PDF: +

+

+ +

+
+ + Member + Functions +
+
lognormal_distribution(RealType location = 0, RealType scale = 1);
+
+

+ Constructs a lognormal distribution with location location + and scale scale. +

+

+ The location parameter is the same as the mean of the logarithm of the + random variate. +

+

+ The scale parameter is the same as the standard deviation of the logarithm + of the random variate. +

+

+ Requires that the scale parameter is greater than zero, otherwise calls + domain_error. +

+
RealType location()const;
+
+

+ Returns the location parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0,+∞]. +

+
+ + Accuracy +
+

+ The lognormal distribution is implemented in terms of the standard library + log and exp functions, plus the error + function, and as such should have very low error rates. +

+
+ + Implementation +
+

+ In the following table m is the location parameter + of the distribution, s is its scale parameter, x + is the random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = e-(ln(x) - m)2 / 2s2 / (x * s * sqrt(2pi)) +

+
+

+ cdf +

+
+

+ Using the relation: p = cdf(normal_distribtion<RealType>(m, + s), log(x)) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = cdf(complement(normal_distribtion<RealType>(m, + s), log(x))) +

+
+

+ quantile +

+
+

+ Using the relation: x = exp(quantile(normal_distribtion<RealType>(m, + s), p)) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = exp(quantile(complement(normal_distribtion<RealType>(m, + s), q))) +

+
+

+ mean +

+
+

+ em + s2 / 2 +

+
+

+ variance +

+
+

+ (es2 - 1) * e2m + s2 +

+
+

+ mode +

+
+

+ em - s2 +

+
+

+ skewness +

+
+

+ sqrt(es2 - 1) * (2 + es2 ) +

+
+

+ kurtosis +

+
+

+ e4s2 + 2e3s2 + 3e2s2 - 3 +

+
+

+ kurtosis excess +

+
+

+ e4s2 + 2e3s2 + 3e2s2 - 6 +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_beta_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_beta_dist.html new file mode 100644 index 00000000..0e5b8a8f --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_beta_dist.html @@ -0,0 +1,484 @@ + + + +Noncentral Beta Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/non_central_beta.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class non_central_beta_distribution;
+
+typedef non_central_beta_distribution<> non_central_beta;
+
+template <class RealType, class Policy>
+class non_central_beta_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor:
+   non_central_beta_distribution(RealType alpha, RealType beta, RealType lambda);
+
+   // Accessor to shape parameters:
+   RealType alpha()const;
+   RealType beta()const;
+
+   // Accessor to non-centrality parameter lambda:
+   RealType non_centrality()const;
+};
+
+}} // namespaces
+
+

+ The noncentral beta distribution is a generalization of the Beta + Distribution. +

+

+ It is defined as the ratio X = χm2(λ) / (χm2(λ) + χn2) where χm2(λ) is a noncentral + χ2 +random variable with m degrees of freedom, and χn2 +is + a central χ2 random variable with n degrees of freedom. +

+

+ This gives a PDF that can be expressed as a Poisson mixture of beta distribution + PDFs: +

+

+ +

+

+ where P(i;λ/2) is the discrete Poisson probablity at i, + with mean λ/2, and Ix'(α, β) is the derivative of the incomplete beta function. + This leads to the usual form of the CDF as: +

+

+ +

+

+ The following graph illustrates how the distribution changes for different + values of λ: +

+

+ +

+
+ + Member + Functions +
+
non_central_beta_distribution(RealType a, RealType b, RealType lambda);
+
+

+ Constructs a noncentral beta distribution with shape parameters a + and b and non-centrality parameter lambda. +

+

+ Requires a > 0, b > 0 and lambda >= 0, otherwise calls domain_error. +

+
RealType alpha()const;
+
+

+ Returns the parameter a from which this object was + constructed. +

+
RealType beta()const;
+
+

+ Returns the parameter b from which this object was + constructed. +

+
RealType non_centrality()const;
+
+

+ Returns the parameter lambda from which this object + was constructed. +

+
+ + Non-member + Accessors +
+

+ Most of the usual non-member + accessor functions are supported: Cumulative + Distribution Function, Probability + Density Function, Quantile, + mean, variance, + standard deviation, + median, mode, + Hazard Function, + Cumulative Hazard Function, + range and support. +

+

+ Mean and variance are implemented using hypergeometric pfq functions and + relations given in Wolfram + Noncentral Beta Distribution. +

+

+ However, the following are not currently implemented: skewness, + kurtosis and + kurtosis_excess. +

+

+ The domain of the random variable is [0, 1]. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) + found on various platforms with various floating point types. The failures + in the comparison to the R Math + library, seem to be mostly in the corner cases when the probablity + would be very small. Unless otherwise specified any floating-point type + that is narrower than the one shown will have effectively + zero error. +

+
+

Table 5.4. Error rates for non central beta CDF

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central Beta, medium parameters +

+
+

+ Max = 240ε (Mean = 31ε) +

+
+

+ Max = 0.998ε (Mean = 0.0659ε)
+
(Rmath 3.0.2: Max + = 1.46e+26ε (Mean = 3.5e+24ε) And + other failures.) +

+
+

+ Max = 825ε (Mean = 27.4ε) +

+
+

+ Max = 832ε (Mean = 38.1ε) +

+
+

+ Non Central Beta, large parameters +

+
+

+ Max = 3.41e+003ε (Mean = 475ε) +

+
+

+ Max = 1.18ε (Mean = 0.175ε)
+
(Rmath 3.0.2: Max + = 1.01e+36ε (Mean = 1.19e+35ε) And + other failures.) +

+
+

+ Max = 2.5e+04ε (Mean = 3.78e+03ε) +

+
+

+ Max = 2.57e+04ε (Mean = 4.43e+03ε) +

+
+
+
+

Table 5.5. Error rates for non central beta CDF complement

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central Beta, medium parameters +

+
+

+ Max = 619ε (Mean = 62.7ε) +

+
+

+ Max = 0.998ε (Mean = 0.0957ε)
+
(Rmath 3.0.2: Max + = 7.5e+97ε (Mean = 1.37e+96ε) And + other failures.) +

+
+

+ Max = 396ε (Mean = 50.7ε) +

+
+

+ Max = 554ε (Mean = 57.3ε) +

+
+

+ Non Central Beta, large parameters +

+
+

+ Max = 8.67e+003ε (Mean = 1.04e+003ε) +

+
+

+ Max = 0.986ε (Mean = 0.188ε)
+
(Rmath 3.0.2: Max + = +INFε (Mean = +INFε) And + other failures.) +

+
+

+ Max = 6.83e+03ε (Mean = 993ε) +

+
+

+ Max = 3.56e+03ε (Mean = 704ε) +

+
+
+

+ Error rates for the PDF, the complement of the CDF and for the quantile + functions are broadly similar. +

+
+ + Tests +
+

+ There are two sets of test data used to verify this implementation: firstly + we can compare with a few sample values generated by the R + library. Secondly, we have tables of test data, computed with this + implementation and using interval arithmetic - this data should be accurate + to at least 50 decimal digits - and is the used for our accuracy tests. +

+
+ + Implementation +
+

+ The CDF and its complement are evaluated as follows: +

+

+ First we determine which of the two values (the CDF or its complement) + is likely to be the smaller, the crossover point is taken to be the mean + of the distribution: for this we use the approximation due to: R. Chattamvelli + and R. Shanmugam, "Algorithm AS 310: Computing the Non-Central Beta + Distribution Function", Applied Statistics, Vol. 46, No. 1. (1997), + pp. 146-156. +

+

+ +

+

+ Then either the CDF or its complement is computed using the relations: +

+

+ +

+

+ The summation is performed by starting at i = λ/2, and then recursing in + both directions, using the usual recurrence relations for the Poisson PDF + and incomplete beta functions. This is the "Method 2" described + by: +

+

+ Denise Benton and K. Krishnamoorthy, "Computing discrete mixtures + of continuous distributions: noncentral chisquare, noncentral t and the + distribution of the square of the sample multiple correlation coefficient", + Computational Statistics & Data Analysis 43 (2003) 249-267. +

+

+ Specific applications of the above formulae to the noncentral beta distribution + can be found in: +

+

+ Russell V. Lenth, "Algorithm AS 226: Computing Noncentral Beta Probabilities", + Applied Statistics, Vol. 36, No. 2. (1987), pp. 241-244. +

+

+ H. Frick, "Algorithm AS R84: A Remark on Algorithm AS 226: Computing + Non-Central Beta Probabilities", Applied Statistics, Vol. 39, No. + 2. (1990), pp. 311-312. +

+

+ Ming Long Lam, "Remark AS R95: A Remark on Algorithm AS 226: Computing + Non-Central Beta Probabilities", Applied Statistics, Vol. 44, No. + 4. (1995), pp. 551-552. +

+

+ Harry O. Posten, "An Effective Algorithm for the Noncentral Beta Distribution + Function", The American Statistician, Vol. 47, No. 2. (May, 1993), + pp. 129-131. +

+

+ R. Chattamvelli, "A Note on the Noncentral Beta Distribution Function", + The American Statistician, Vol. 49, No. 2. (May, 1995), pp. 231-234. +

+

+ Of these, the Posten reference provides the most complete overview, and + includes the modification starting iteration at λ/2. +

+

+ The main difference between this implementation and the above references + is the direct computation of the complement when most efficient to do so, + and the accumulation of the sum to -1 rather than subtracting the result + from 1 at the end: this can substantially reduce the number of iterations + required when the result is near 1. +

+

+ The PDF is computed using the methodology of Benton and Krishnamoorthy + and the relation: +

+

+ +

+

+ Quantiles are computed using a specially modified version of bracket + and solve, starting the search for the root at the mean of the distribution. + (A Cornish-Fisher type expansion was also tried, but while this gets quite + close to the root in many cases, when it is wrong it tends to introduce + quite pathological behaviour: more investigation in this area is probably + warranted). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_chi_squared_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_chi_squared_dist.html new file mode 100644 index 00000000..068ee2fc --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_chi_squared_dist.html @@ -0,0 +1,572 @@ + + + +Noncentral Chi-Squared Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/non_central_chi_squared.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class non_central_chi_squared_distribution;
+
+typedef non_central_chi_squared_distribution<> non_central_chi_squared;
+
+template <class RealType, class Policy>
+class non_central_chi_squared_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor:
+   non_central_chi_squared_distribution(RealType v, RealType lambda);
+
+   // Accessor to degrees of freedom parameter v:
+   RealType degrees_of_freedom()const;
+
+   // Accessor to non centrality parameter lambda:
+   RealType non_centrality()const;
+
+   // Parameter finders:
+   static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
+   template <class A, class B, class C>
+   static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
+
+   static RealType find_non_centrality(RealType v, RealType x, RealType p);
+   template <class A, class B, class C>
+   static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
+};
+
+}} // namespaces
+
+

+ The noncentral chi-squared distribution is a generalization of the Chi Squared Distribution. + If Xi are ν independent, normally distributed random variables with means + μi and variances σi2, then the random variable +

+

+ +

+

+ is distributed according to the noncentral chi-squared distribution. +

+

+ The noncentral chi-squared distribution has two parameters: ν which specifies + the number of degrees of freedom (i.e. the number of Xi), and λ which is + related to the mean of the random variables Xi by: +

+

+ +

+

+ (Note that some references define λ as one half of the above sum). +

+

+ This leads to a PDF of: +

+

+ +

+

+ where f(x;k) is the central chi-squared distribution + PDF, and Iv(x) is a modified Bessel function of the + first kind. +

+

+ The following graph illustrates how the distribution changes for different + values of λ: +

+

+ +

+
+ + Member + Functions +
+
non_central_chi_squared_distribution(RealType v, RealType lambda);
+
+

+ Constructs a Chi-Squared distribution with v degrees + of freedom and non-centrality parameter lambda. +

+

+ Requires v > 0 and lambda >= 0, otherwise calls domain_error. +

+
RealType degrees_of_freedom()const;
+
+

+ Returns the parameter v from which this object was + constructed. +

+
RealType non_centrality()const;
+
+

+ Returns the parameter lambda from which this object + was constructed. +

+
static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
+
+

+ This function returns the number of degrees of freedom v + such that: cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p +

+
template <class A, class B, class C>
+static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
+
+

+ When called with argument boost::math::complement(lambda, x, + q) + this function returns the number of degrees of freedom v + such that: +

+

+ cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q. +

+
static RealType find_non_centrality(RealType v, RealType x, RealType p);
+
+

+ This function returns the non centrality parameter lambda + such that: +

+

+ cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p +

+
template <class A, class B, class C>
+static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
+
+

+ When called with argument boost::math::complement(v, + x, + q) + this function returns the non centrality parameter lambda + such that: +

+

+ cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, +∞]. +

+
+ + Examples +
+

+ There is a worked example + for the noncentral chi-squared distribution. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) + found on various platforms with various floating point types. The failures + in the comparison to the R Math + library, seem to be mostly in the corner cases when the probablity + would be very small. Unless otherwise specified any floating-point type + that is narrower than the one shown will have effectively + zero error. +

+
+

Table 5.6. Error rates for non central chi squared CDF

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central Chi Squared, medium parameters +

+
+

+ Max = 48.9ε (Mean = 10ε) +

+
+

+ Max = 0.99ε (Mean = 0.0529ε)
+
(Rmath 3.0.2: Max = 727ε (Mean = 121ε)) +

+
+

+ Max = 46.5ε (Mean = 10.3ε) +

+
+

+ Max = 115ε (Mean = 13.9ε) +

+
+

+ Non Central Chi Squared, large parameters +

+
+

+ Max = 9.79e+003ε (Mean = 723ε) +

+
+

+ Max = 1.07ε (Mean = 0.102ε)
+
(Rmath 3.0.2: Max + = 3.27e+08ε (Mean = 2.23e+07ε)) +

+
+

+ Max = 3.07e+03ε (Mean = 336ε) +

+
+

+ Max = 6.17e+03ε (Mean = 677ε) +

+
+
+
+

Table 5.7. Error rates for non central chi squared CDF complement

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central Chi Squared, medium parameters +

+
+

+ Max = 98.6ε (Mean = 15.8ε) +

+
+

+ Max = 0.96ε (Mean = 0.0635ε)
+
(Rmath 3.0.2: Max + = +INFε (Mean = +INFε) And + other failures.) +

+
+

+ Max = 107ε (Mean = 17.1ε) +

+
+

+ Max = 171ε (Mean = 22.8ε) +

+
+

+ Non Central Chi Squared, large parameters +

+
+

+ Max = 5.43e+003ε (Mean = 705ε) +

+
+

+ Max = 2.11ε (Mean = 0.278ε)
+
(Rmath 3.0.2: Max + = +INFε (Mean = +INFε) And + other failures.) +

+
+

+ Max = 5.02e+03ε (Mean = 630ε) +

+
+

+ Max = 5.1e+03ε (Mean = 577ε) +

+
+
+

+ Error rates for the quantile functions are broadly similar. Special mention + should go to the mode function: + there is no closed form for this function, so it is evaluated numerically + by finding the maxima of the PDF: in principal this can not produce an + accuracy greater than the square root of the machine epsilon. +

+
+ + Tests +
+

+ There are two sets of test data used to verify this implementation: firstly + we can compare with published data, for example with Table 6 of "Self-Validating + Computations of Probabilities for Selected Central and Noncentral Univariate + Probability Functions", Morgan C. Wang and William J. Kennedy, Journal + of the American Statistical Association, Vol. 89, No. 427. (Sep., 1994), + pp. 878-887. Secondly, we have tables of test data, computed with this + implementation and using interval arithmetic - this data should be accurate + to at least 50 decimal digits - and is the used for our accuracy tests. +

+
+ + Implementation +
+

+ The CDF and its complement are evaluated as follows: +

+

+ First we determine which of the two values (the CDF or its complement) + is likely to be the smaller: for this we can use the relation due to Temme + (see "Asymptotic and Numerical Aspects of the Noncentral Chi-Square + Distribution", N. M. Temme, Computers Math. Applic. Vol 25, No. 5, + 55-63, 1993) that: +

+

+ F(ν,λ;ν+λ) ≈ 0.5 +

+

+ and so compute the CDF when the random variable is less than ν+λ, and its + complement when the random variable is greater than ν+λ. If necessary the + computed result is then subtracted from 1 to give the desired result (the + CDF or its complement). +

+

+ For small values of the non centrality parameter, the CDF is computed using + the method of Ding (see "Algorithm AS 275: Computing the Non-Central + #2 Distribution Function", Cherng G. Ding, Applied Statistics, Vol. + 41, No. 2. (1992), pp. 478-482). This uses the following series representation: +

+

+ +

+

+ which requires just one call to gamma_p_derivative + with the subsequent terms being computed by recursion as shown above. +

+

+ For larger values of the non-centrality parameter, Ding's method can take + an unreasonable number of terms before convergence is achieved. Furthermore, + the largest term is not the first term, so in extreme cases the first term + may be zero, leading to a zero result, even though the true value may be + non-zero. +

+

+ Therefore, when the non-centrality parameter is greater than 200, the method + due to Krishnamoorthy (see "Computing discrete mixtures of continuous + distributions: noncentral chisquare, noncentral t and the distribution + of the square of the sample multiple correlation coefficient", Denise + Benton and K. Krishnamoorthy, Computational Statistics & Data Analysis, + 43, (2003), 249-267) is used. +

+

+ This method uses the well known sum: +

+

+ +

+

+ Where Pa(x) is the incomplete gamma function. +

+

+ The method starts at the λth term, which is where the Poisson weighting + function achieves its maximum value, although this is not necessarily the + largest overall term. Subsequent terms are calculated via the normal recurrence + relations for the incomplete gamma function, and iteration proceeds both + forwards and backwards until sufficient precision has been achieved. It + should be noted that recurrence in the forwards direction of Pa(x) is numerically + unstable. However, since we always start after the + largest term in the series, numeric instability is introduced more slowly + than the series converges. +

+

+ Computation of the complement of the CDF uses an extension of Krishnamoorthy's + method, given that: +

+

+ +

+

+ we can again start at the λ'th term and proceed in both directions from + there until the required precision is achieved. This time it is backwards + recursion on the incomplete gamma function Qa(x) which is unstable. However, + as long as we start well before the largest term, + this is not an issue in practice. +

+

+ The PDF is computed directly using the relation: +

+

+ +

+

+ Where f(x; v) is the PDF of the central Chi + Squared Distribution and Iv(x) is a modified + Bessel function, see cyl_bessel_i. + For small values of the non-centrality parameter the relation in terms + of cyl_bessel_i is used. + However, this method fails for large values of the non-centrality parameter, + so in that case the infinite sum is evaluated using the method of Benton + and Krishnamoorthy, and the usual recurrence relations for successive terms. +

+

+ The quantile functions are computed by numeric inversion of the CDF. An + improve starting quess is from Thomas Luu, Fast + and accurate parallel computation of quantile functions for random number + generation, Doctorial Thesis, 2016. +

+

+ There is no closed + form for the mode of the noncentral chi-squared distribution: it + is computed numerically by finding the maximum of the PDF. Likewise, the + median is computed numerically via the quantile. +

+

+ The remaining non-member functions use the following formulas: +

+

+ +

+

+ Some analytic properties of noncentral distributions (particularly unimodality, + and monotonicity of their modes) are surveyed and summarized by: +

+

+ Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, + 141 (2003) 3-12. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_f_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_f_dist.html new file mode 100644 index 00000000..a3eed8ea --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_f_dist.html @@ -0,0 +1,410 @@ + + + +Noncentral F Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/non_central_f.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class non_central_f_distribution;
+
+typedef non_central_f_distribution<> non_central_f;
+
+template <class RealType, class Policy>
+class non_central_f_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor:
+   non_central_f_distribution(RealType v1, RealType v2, RealType lambda);
+
+   // Accessor to degrees_of_freedom parameters v1 & v2:
+   RealType degrees_of_freedom1()const;
+   RealType degrees_of_freedom2()const;
+
+   // Accessor to non-centrality parameter lambda:
+   RealType non_centrality()const;
+};
+
+}} // namespaces
+
+

+ The noncentral F distribution is a generalization of the Fisher + F Distribution. It is defined as the ratio +

+
F = (X/v1) / (Y/v2)
+
+

+ where X is a noncentral χ2 +random variable with v1 degrees + of freedom and non-centrality parameter λ, and Y is a central χ2 random variable + with v2 degrees of freedom. +

+

+ This gives the following PDF: +

+

+ +

+

+ where Lab(c) is a generalised Laguerre polynomial and B(a,b) is the beta function, or +

+

+ +

+

+ The following graph illustrates how the distribution changes for different + values of λ: +

+

+ +

+
+ + Member + Functions +
+
non_central_f_distribution(RealType v1, RealType v2, RealType lambda);
+
+

+ Constructs a non-central beta distribution with parameters v1 + and v2 and non-centrality parameter lambda. +

+

+ Requires v1 > 0, v2 > 0 and lambda >= 0, otherwise calls domain_error. +

+
RealType degrees_of_freedom1()const;
+
+

+ Returns the parameter v1 from which this object was + constructed. +

+
RealType degrees_of_freedom2()const;
+
+

+ Returns the parameter v2 from which this object was + constructed. +

+
RealType non_centrality()const;
+
+

+ Returns the non-centrality parameter lambda from which + this object was constructed. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, +∞]. +

+
+ + Accuracy +
+

+ This distribution is implemented in terms of the Noncentral + Beta Distribution: refer to that distribution for accuracy data. +

+
+ + Tests +
+

+ Since this distribution is implemented by adapting another distribution, + the tests consist of basic sanity checks computed by the R-2.5.1 + Math library statistical package and its pbeta and dbeta functions. +

+
+ + Implementation +
+

+ In the following table v1 and v2 + are the first and second degrees of freedom parameters of the distribution, + λ +is the non-centrality parameter, x is the random variate, + p is the probability, and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Implemented in terms of the non-central beta PDF using the relation: +

+

+ f(x;v1,v2;λ) = (v1/v2) / ((1+y)*(1+y)) * g(y/(1+y);v1/2,v2/2;λ) +

+

+ where g(x; a, b; λ) is the non central beta PDF, and: +

+

+ y = x * v1 / v2 +

+
+

+ cdf +

+
+

+ Using the relation: +

+

+ p = By(v1/2, v2/2; λ) +

+

+ where Bx(a, b; λ) is the noncentral beta distribution CDF and +

+

+ y = x * v1 / v2 +

+
+

+ cdf complement +

+
+

+ Using the relation: +

+

+ q = 1 - By(v1/2, v2/2; λ) +

+

+ where 1 - Bx(a, b; λ) is the complement of the noncentral beta + distribution CDF and +

+

+ y = x * v1 / v2 +

+
+

+ quantile +

+
+

+ Using the relation: +

+

+ x = (bx / (1-bx)) * (v1 / v2) +

+

+ where +

+

+ bx = Qp-1(v1/2, v2/2; λ) +

+

+ and +

+

+ Qp-1(v1/2, v2/2; λ) +

+

+ is the noncentral beta quantile. +

+
+

+ quantile +

+

+ from the complement +

+
+

+ Using the relation: +

+

+ x = (bx / (1-bx)) * (v1 / v2) +

+

+ where +

+

+ bx = QCq-1(v1/2, v2/2; λ) +

+

+ and +

+

+ QCq-1(v1/2, v2/2; λ) +

+

+ is the noncentral beta quantile from the complement. +

+
+

+ mean +

+
+

+ v2 * (v1 + l) / (v1 * (v2 - 2)) +

+
+

+ mode +

+
+

+ By numeric maximalisation of the PDF. +

+
+

+ variance +

+
+

+ Refer to, Weisstein, + Eric W. "Noncentral F-Distribution." From MathWorld--A + Wolfram Web Resource. +

+
+

+ skewness +

+
+

+ Refer to, Weisstein, + Eric W. "Noncentral F-Distribution." From MathWorld--A + Wolfram Web Resource., and to the Mathematica + documentation +

+
+

+ kurtosis and kurtosis excess +

+
+

+ Refer to, Weisstein, + Eric W. "Noncentral F-Distribution." From MathWorld--A + Wolfram Web Resource., and to the Mathematica + documentation +

+
+

+ Some analytic properties of noncentral distributions (particularly unimodality, + and monotonicity of their modes) are surveyed and summarized by: +

+

+ Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, + 141 (2003) 3-12. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_t_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_t_dist.html new file mode 100644 index 00000000..e1a57332 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/nc_t_dist.html @@ -0,0 +1,566 @@ + + + +Noncentral T Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/non_central_t.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class non_central_t_distribution;
+
+typedef non_central_t_distribution<> non_central_t;
+
+template <class RealType, class Policy>
+class non_central_t_distribution
+{
+public:
+   typedef RealType  value_type;
+   typedef Policy    policy_type;
+
+   // Constructor:
+   non_central_t_distribution(RealType v, RealType delta);
+
+   // Accessor to degrees_of_freedom parameter v:
+   RealType degrees_of_freedom()const;
+
+   // Accessor to non-centrality parameter delta:
+   RealType non_centrality()const;
+};
+
+}} // namespaces
+
+

+ The noncentral T distribution is a generalization of the Students + t Distribution. Let X have a normal distribution with mean δ and variance + 1, and let ν S2 have a chi-squared distribution with degrees of freedom ν. + Assume that X and S2 are independent. The distribution of tν(δ)=X/S is called + a noncentral t distribution with degrees of freedom ν and noncentrality parameter + δ. +

+

+ This gives the following PDF: +

+

+ +

+

+ where 1F1(a;b;x) is a confluent hypergeometric function. +

+

+ The following graph illustrates how the distribution changes for different + values of ν and δ: +

+

+ + +

+
+ + Member + Functions +
+
non_central_t_distribution(RealType v, RealType delta);
+
+

+ Constructs a non-central t distribution with degrees of freedom parameter + v and non-centrality parameter delta. +

+

+ Requires v > 0 (including positive infinity) and + finite delta, otherwise calls domain_error. +

+
RealType degrees_of_freedom()const;
+
+

+ Returns the parameter v from which this object was + constructed. +

+
RealType non_centrality()const;
+
+

+ Returns the non-centrality parameter delta from which + this object was constructed. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [-∞, +∞]. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) + found on various platforms with various floating-point types. Unless otherwise + specified, any floating-point type that is narrower than the one shown + will have effectively + zero error. +

+
+

Table 5.8. Error rates for non central t CDF

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central T +

+
+

+ Max = 138ε (Mean = 31.5ε) +

+
+

+ Max = 0.796ε (Mean = 0.0691ε)
+
(Rmath 3.0.2: Max + = 5.28e+15ε (Mean = 8.49e+14ε) And + other failures.) +

+
+

+ Max = 141ε (Mean = 31.1ε) +

+
+

+ Max = 145ε (Mean = 30.2ε) +

+
+

+ Non Central T (small non-centrality) +

+
+

+ Max = 3.61ε (Mean = 1.03ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = 2.09e+03ε (Mean = 244ε)) +

+
+

+ Max = 7.86ε (Mean = 1.69ε) +

+
+

+ Max = 9.15ε (Mean = 2.25ε) +

+
+

+ Non Central T (large parameters) +

+
+

+ Max = 286ε (Mean = 62.8ε) +

+
+

+ Max = 257ε (Mean = 72.1ε)

+ (Rmath 3.0.2: Max = 2.46ε (Mean = 0.657ε)) +

+
+

+ Max = 5.26e+05ε (Mean = 1.48e+05ε) +

+
+

+ Max = 5.24e+05ε (Mean = 1.47e+05ε) +

+
+
+
+

Table 5.9. Error rates for non central t CDF complement

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Non Central T +

+
+

+ Max = 150ε (Mean = 32.3ε) +

+
+

+ Max = 0.707ε (Mean = 0.0497ε)
+
(Rmath 3.0.2: Max + = 6.19e+15ε (Mean = 6.72e+14ε) And + other failures.) +

+
+

+ Max = 203ε (Mean = 31.8ε) +

+
+

+ Max = 340ε (Mean = 43.6ε) +

+
+

+ Non Central T (small non-centrality) +

+
+

+ Max = 5.21ε (Mean = 1.43ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = 1.87e+03ε (Mean = 263ε)) +

+
+

+ Max = 7.48ε (Mean = 1.86ε) +

+
+

+ Max = 10.9ε (Mean = 2.43ε) +

+
+

+ Non Central T (large parameters) +

+
+

+ Max = 227ε (Mean = 50.4ε) +

+
+

+ Max = 478ε (Mean = 96.3ε)

+ (Rmath 3.0.2: Max = 2.24ε (Mean = 0.945ε)) +

+
+

+ Max = 9.79e+05ε (Mean = 1.97e+05ε) +

+
+

+ Max = 9.79e+05ε (Mean = 1.97e+05ε) +

+
+
+
+ + + + + +
[Caution]Caution

+ The complexity of the current algorithm is dependent upon δ2: consequently + the time taken to evaluate the CDF increases rapidly for δ > 500, likewise + the accuracy decreases rapidly for very large δ. +

+

+ Accuracy for the quantile and PDF functions should be broadly similar. + The mode is determined numerically and cannot in principal + be more accurate than the square root of floating-point type FPT epsilon, + accessed using boost::math::tools::epsilon<FPT>(). + For 64-bit double, epsilon + is about 1e-16, so the fractional accuracy is limited to 1e-8. +

+
+ + Tests +
+

+ There are two sets of tests of this distribution: +

+

+ Basic sanity checks compare this implementation to the test values given + in "Computing discrete mixtures of continuous distributions: noncentral + chisquare, noncentral t and the distribution of the square of the sample + multiple correlation coefficient." Denise Benton, K. Krishnamoorthy, + Computational Statistics & Data Analysis 43 (2003) 249-267. +

+

+ Accuracy checks use test data computed with this implementation and arbitary + precision interval arithmetic: this test data is believed to be accurate + to at least 50 decimal places. +

+

+ The cases of large (or infinite) ν and/or large δ has received special treatment + to avoid catastrophic loss of accuracy. New tests have been added to confirm + the improvement achieved. +

+

+ From Boost 1.52, degrees of freedom ν can be +∞ +when the normal distribution + located at δ +(equivalent to the central Student's t distribution) is used + in place for accuracy and speed. +

+
+ + Implementation +
+

+ The CDF is computed using a modification of the method described in "Computing + discrete mixtures of continuous distributions: noncentral chisquare, noncentral + t and the distribution of the square of the sample multiple correlation + coefficient." Denise Benton, K. Krishnamoorthy, Computational Statistics + & Data Analysis 43 (2003) 249-267. +

+

+ This uses the following formula for the CDF: +

+

+ +

+

+ Where Ix(a,b) is the incomplete beta function, and Φ(x) is the normal CDF + at x. +

+

+ Iteration starts at the largest of the Poisson weighting terms (at i = + δ2 / 2) and then proceeds in both directions as per Benton and Krishnamoorthy's + paper. +

+

+ Alternatively, by considering what happens when t = ∞, we have x = 1, and + therefore Ix(a,b) = 1 and: +

+

+ +

+

+ From this we can easily show that: +

+

+ +

+

+ and therefore we have a means to compute either the probability or its + complement directly without the risk of cancellation error. The crossover + criterion for choosing whether to calculate the CDF or its complement is + the same as for the Noncentral + Beta Distribution. +

+

+ The PDF can be computed by a very similar method using: +

+

+ +

+

+ Where Ix'(a,b) is the derivative of the incomplete beta function. +

+

+ For both the PDF and CDF we switch to approximating the distribution by + a Student's t distribution centred on δ when ν is very large. The crossover + location appears to be when δ/(4ν) < ε, this location was estimated by + inspection of equation 2.6 in "A Comparison of Approximations To Percentiles + of the Noncentral t-Distribution". H. Sahai and M. M. Ojeda, Revista + Investigacion Operacional Vol 21, No 2, 2000, page 123. +

+

+ Equation 2.6 is a Fisher-Cornish expansion by Eeden and Johnson. The second + term includes the ratio δ/(4ν), so when this term become negligible, this + and following terms can be ignored, leaving just Student's t distribution + centred on δ. +

+

+ This was also confirmed by experimental testing. +

+

+ See also +

+
    +
  • + "Some Approximations to the Percentage Points of the Noncentral + t-Distribution". C. van Eeden. International Statistical Review, + 29, 4-31. +
  • +
  • + "Continuous Univariate Distributions". N.L. Johnson, S. Kotz + and N. Balkrishnan. 1995. John Wiley and Sons New York. +
  • +
+

+ The quantile is calculated via the usual root-finding + without derivatives method with the initial guess taken as the quantile + of a normal approximation to the noncentral T. +

+

+ There is no closed form for the mode, so this is computed via functional + maximisation of the PDF. +

+

+ The remaining functions (mean, variance etc) are implemented using the + formulas given in Weisstein, Eric W. "Noncentral Student's t-Distribution." + From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html + and in the Mathematica + documentation. +

+

+ Some analytic properties of noncentral distributions (particularly unimodality, + and monotonicity of their modes) are surveyed and summarized by: +

+

+ Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, + 141 (2003) 3-12. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/negative_binomial_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/negative_binomial_dist.html new file mode 100644 index 00000000..9635c895 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/negative_binomial_dist.html @@ -0,0 +1,883 @@ + + + +Negative Binomial Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/negative_binomial.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class negative_binomial_distribution;
+
+typedef negative_binomial_distribution<> negative_binomial;
+
+template <class RealType, class Policy>
+class negative_binomial_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Constructor from successes and success_fraction:
+   negative_binomial_distribution(RealType r, RealType p);
+
+   // Parameter accessors:
+   RealType success_fraction() const;
+   RealType successes() const;
+
+   // Bounds on success fraction:
+   static RealType find_lower_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability); // alpha
+   static RealType find_upper_bound_on_p(
+      RealType trials,
+      RealType successes,
+      RealType probability); // alpha
+
+   // Estimate min/max number of trials:
+   static RealType find_minimum_number_of_trials(
+      RealType k,     // Number of failures.
+      RealType p,     // Success fraction.
+      RealType probability); // Probability threshold alpha.
+   static RealType find_maximum_number_of_trials(
+      RealType k,     // Number of failures.
+      RealType p,     // Success fraction.
+      RealType probability); // Probability threshold alpha.
+};
+
+}} // namespaces
+
+

+ The class type negative_binomial_distribution + represents a negative_binomial + distribution: it is used when there are exactly two mutually exclusive + outcomes of a Bernoulli + trial: these outcomes are labelled "success" and "failure". +

+

+ For k + r Bernoulli trials each with success fraction p, the negative_binomial + distribution gives the probability of observing k failures and r successes + with success on the last trial. The negative_binomial distribution assumes + that success_fraction p is fixed for all (k + r) trials. +

+
+ + + + + +
[Note]Note

+ The random variable for the negative binomial distribution is the number + of trials, (the number of successes is a fixed property of the distribution) + whereas for the binomial, the random variable is the number of successes, + for a fixed number of trials. +

+

+ It has the PDF: +

+

+ +

+

+ The following graph illustrate how the PDF varies as the success fraction + p changes: +

+

+ +

+

+ Alternatively, this graph shows how the shape of the PDF varies as the + number of successes changes: +

+

+ +

+
+ + Related + Distributions +
+

+ The name negative binomial distribution is reserved by some to the case + where the successes parameter r is an integer. This integer version is + also called the Pascal + distribution. +

+

+ This implementation uses real numbers for the computation throughout (because + it uses the real-valued incomplete beta + function family of functions). This real-valued version is also called + the Polya Distribution. +

+

+ The Poisson distribution is a generalization of the Pascal distribution, + where the success parameter r is an integer: to obtain the Pascal distribution + you must ensure that an integer value is provided for r, and take integer + values (floor or ceiling) from functions that return a number of successes. +

+

+ For large values of r (successes), the negative binomial distribution converges + to the Poisson distribution. +

+

+ The geometric distribution is a special case where the successes parameter + r = 1, so only a first and only success is required. geometric(p) = negative_binomial(1, + p). +

+

+ The Poisson distribution is a special case for large successes +

+

+ poisson(λ) = lim r → ∞   negative_binomial(r, r / (λ + r))) +

+
+ + + + + +
[Caution]Caution
+

+ The Negative Binomial distribution is a discrete distribution: internally, + functions like the cdf + and pdf are treated "as + if" they are continuous functions, but in reality the results returned + from these functions only have meaning if an integer value is provided + for the random variate argument. +

+

+ The quantile function will by default return an integer result that has + been rounded outwards. That is to say lower quantiles + (where the probability is less than 0.5) are rounded downward, and upper + quantiles (where the probability is greater than 0.5) are rounded upwards. + This behaviour ensures that if an X% quantile is requested, then at + least the requested coverage will be present in the central + region, and no more than the requested coverage + will be present in the tails. +

+

+ This behaviour can be changed so that the quantile functions are rounded + differently, or even return a real-valued result using Policies. + It is strongly recommended that you read the tutorial Understanding + Quantiles of Discrete Distributions before using the quantile + function on the Negative Binomial distribution. The reference + docs describe how to change the rounding policy for these distributions. +

+
+
+ + Member + Functions +
+
+ + Construct +
+
negative_binomial_distribution(RealType r, RealType p);
+
+

+ Constructor: r is the total number of successes, + p is the probability of success of a single trial. +

+

+ Requires: r > + 0 and 0 + <= p + <= 1. +

+
+ + Accessors +
+
RealType success_fraction() const; // successes / trials (0 <= p <= 1)
+
+

+ Returns the parameter p from which this distribution + was constructed. +

+
RealType successes() const; // required successes (r > 0)
+
+

+ Returns the parameter r from which this distribution + was constructed. +

+

+ The best method of calculation for the following functions is disputed: + see Binomial + Distribution for more discussion. +

+
+ + Lower + Bound on Parameter p +
+
static RealType find_lower_bound_on_p(
+  RealType failures,
+  RealType successes,
+  RealType probability) // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
+
+

+ Returns a lower bound on the success fraction: +

+
+

+
+
failures
+

+ The total number of failures before the rth + success. +

+
successes
+

+ The number of successes required. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is less than the value + returned. +

+
+
+

+ For example, if you observe k failures and r + successes from n = k + r trials the best estimate + for the success fraction is simply r/n, but if you + want to be 95% sure that the true value is greater + than some value, pmin, then: +

+
pmin = negative_binomial_distribution<RealType>::find_lower_bound_on_p(
+                    failures, successes, 0.05);
+
+

+ See + negative binomial confidence interval example. +

+

+ This function uses the Clopper-Pearson method of computing the lower bound + on the success fraction, whilst many texts refer to this method as giving + an "exact" result in practice it produces an interval that guarantees + at least the coverage required, and may produce pessimistic + estimates for some combinations of failures and successes. + See: +

+

+ Yong + Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some + Discrete Distributions. Computational statistics and data analysis, 2005, + vol. 48, no3, 605-621. +

+
+ + Upper + Bound on Parameter p +
+
static RealType find_upper_bound_on_p(
+   RealType trials,
+   RealType successes,
+   RealType alpha); // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
+
+

+ Returns an upper bound on the success + fraction: +

+
+

+
+
trials
+

+ The total number of trials conducted. +

+
successes
+

+ The number of successes that occurred. +

+
alpha
+

+ The largest acceptable probability that the true value of the success + fraction is greater than the value + returned. +

+
+
+

+ For example, if you observe k successes from n + trials the best estimate for the success fraction is simply k/n, + but if you want to be 95% sure that the true value is less + than some value, pmax, then: +

+
pmax = negative_binomial_distribution<RealType>::find_upper_bound_on_p(
+                    r, k, 0.05);
+
+

+ See + negative binomial confidence interval example. +

+

+ This function uses the Clopper-Pearson method of computing the lower bound + on the success fraction, whilst many texts refer to this method as giving + an "exact" result in practice it produces an interval that guarantees + at least the coverage required, and may produce pessimistic + estimates for some combinations of failures and successes. + See: +

+

+ Yong + Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some + Discrete Distributions. Computational statistics and data analysis, 2005, + vol. 48, no3, 605-621. +

+
+ + Estimating + Number of Trials to Ensure at Least a Certain Number of Failures +
+
static RealType find_minimum_number_of_trials(
+   RealType k,     // number of failures.
+   RealType p,     // success fraction.
+   RealType alpha); // probability threshold (0.05 equivalent to 95%).
+
+

+ This functions estimates the number of trials required to achieve a certain + probability that more than k failures will be observed. +

+
+

+
+
k
+

+ The target number of failures to be observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable risk that only k failures or fewer will be + observed. +

+
+
+

+ For example: +

+
negative_binomial_distribution<RealType>::find_minimum_number_of_trials(10, 0.5, 0.05);
+
+

+ Returns the smallest number of trials we must conduct to be 95% sure of + seeing 10 failures that occur with frequency one half. +

+

+ Worked + Example. +

+

+ This function uses numeric inversion of the negative binomial distribution + to obtain the result: another interpretation of the result, is that it + finds the number of trials (success+failures) that will lead to an alpha + probability of observing k failures or fewer. +

+
+ + Estimating + Number of Trials to Ensure a Maximum Number of Failures or Less +
+
static RealType find_maximum_number_of_trials(
+   RealType k,     // number of failures.
+   RealType p,     // success fraction.
+   RealType alpha); // probability threshold (0.05 equivalent to 95%).
+
+

+ This functions estimates the maximum number of trials we can conduct and + achieve a certain probability that k failures or + fewer will be observed. +

+
+

+
+
k
+

+ The maximum number of failures to be observed. +

+
p
+

+ The probability of success for each trial. +

+
alpha
+

+ The maximum acceptable risk that more than k + failures will be observed. +

+
+
+

+ For example: +

+
negative_binomial_distribution<RealType>::find_maximum_number_of_trials(0, 1.0-1.0/1000000, 0.05);
+
+

+ Returns the largest number of trials we can conduct and still be 95% sure + of seeing no failures that occur with frequency one in one million. +

+

+ This function uses numeric inversion of the negative binomial distribution + to obtain the result: another interpretation of the result, is that it + finds the number of trials (success+failures) that will lead to an alpha + probability of observing more than k failures. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ However it's worth taking a moment to define what these actually mean in + the context of this distribution: +

+
+

Table 5.3. Meaning of the non-member accessors.

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Meaning +

+
+

+ Probability Density + Function +

+
+

+ The probability of obtaining exactly k + failures from k+r trials with success fraction p. + For example: +

+
pdf(negative_binomial(r, p), k)
+
+

+ Cumulative Distribution + Function +

+
+

+ The probability of obtaining k failures + or fewer from k+r trials with success fraction p and + success on the last trial. For example: +

+
cdf(negative_binomial(r, p), k)
+
+

+ Complement of + the Cumulative Distribution Function +

+
+

+ The probability of obtaining more than + k failures from k+r trials with success fraction p + and success on the last trial. For example: +

+
cdf(complement(negative_binomial(r, p), k))
+
+

+ Quantile +

+
+

+ The greatest number of failures + k expected to be observed from k+r trials with success fraction + p, at probability P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the real result. For example: +

+
quantile(negative_binomial(r, p), P)
+
+

+ Quantile + from the complement of the probability +

+
+

+ The smallest number of failures + k expected to be observed from k+r trials with success fraction + p, at probability P. Note that the value returned is a real-number, + and not an integer. Depending on the use case you may want to + take either the floor or ceiling of the real result. For example: +

+
quantile(complement(negative_binomial(r, p), P))
+
+
+
+ + Accuracy +
+

+ This distribution is implemented using the incomplete beta functions ibeta and ibetac: + please refer to these functions for information on accuracy. +

+
+ + Implementation +
+

+ In the following table, p is the probability that + any one trial will be successful (the success fraction), r + is the number of successes, k is the number of failures, + p is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ pdf = exp(lgamma(r + k) - lgamma(r) - lgamma(k+1)) * pow(p, r) + * pow((1-p), k) +

+

+ Implementation is in terms of ibeta_derivative: +

+

+ (p/(r + k)) * ibeta_derivative(r, static_cast<RealType>(k+1), + p) The function ibeta_derivative + is used here, since it has already been optimised for the lowest + possible error - indeed this is really just a thin wrapper around + part of the internals of the incomplete beta function. +

+
+

+ cdf +

+
+

+ Using the relation: +

+

+ cdf = Ip(r, k+1) = ibeta(r, k+1, p) +

+

+ = ibeta(r, static_cast<RealType>(k+1), p) +

+
+

+ cdf complement +

+
+

+ Using the relation: +

+

+ 1 - cdf = Ip(k+1, r) +

+

+ = ibetac(r, static_cast<RealType>(k+1), p) +

+
+

+ quantile +

+
+

+ ibeta_invb(r, p, P) - 1 +

+
+

+ quantile from the complement +

+
+

+ ibetac_invb(r, p, Q) -1) +

+
+

+ mean +

+
+

+ r(1-p)/p +

+
+

+ variance +

+
+

+ r (1-p) + / p + * p +

+
+

+ mode +

+
+

+ floor((r-1) * (1 - p)/p) +

+
+

+ skewness +

+
+

+ (2 + - p) / + sqrt(r * + (1 + - p)) +

+
+

+ kurtosis +

+
+

+ 6 / + r + + (p + * p) / + r * + (1 + - p + ) +

+
+

+ kurtosis excess +

+
+

+ 6 / + r + + (p + * p) / + r * + (1 + - p + ) -3 +

+
+

+ parameter estimation member functions +

+
+
+

+ find_lower_bound_on_p +

+
+

+ ibeta_inv(successes, failures + 1, alpha) +

+
+

+ find_upper_bound_on_p +

+
+

+ ibetac_inv(successes, failures, alpha) plus see comments in code. +

+
+

+ find_minimum_number_of_trials +

+
+

+ ibeta_inva(k + 1, p, alpha) +

+
+

+ find_maximum_number_of_trials +

+
+

+ ibetac_inva(k + 1, p, alpha) +

+
+

+ Implementation notes: +

+
    +
  • + The real concept type (that deliberately lacks the Lanczos approximation), + was found to take several minutes to evaluate some extreme test values, + so the test has been disabled for this type. +
  • +
  • + Much greater speed, and perhaps greater accuracy, might be achieved + for extreme values by using a normal approximation. This is NOT been + tested or implemented. +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/normal_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/normal_dist.html new file mode 100644 index 00000000..34e4a1ba --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/normal_dist.html @@ -0,0 +1,325 @@ + + + +Normal (Gaussian) Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/normal.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class normal_distribution;
+
+typedef normal_distribution<> normal;
+
+template <class RealType, class Policy>
+class normal_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   normal_distribution(RealType mean = 0, RealType sd = 1);
+   // Accessors:
+   RealType mean()const; // location.
+   RealType standard_deviation()const; // scale.
+   // Synonyms, provided to allow generic use of find_location and find_scale.
+   RealType location()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The normal distribution is probably the most well known statistical distribution: + it is also known as the Gaussian Distribution. A normal distribution with + mean zero and standard deviation one is known as the Standard + Normal Distribution. +

+

+ Given mean μ  and standard deviation σ  it has the PDF: +

+

+   +

+

+ The variation the PDF with its parameters is illustrated in the following + graph: +

+

+ +

+

+ The cumulative distribution function is given by +

+

+   +

+

+ and illustrated by this graph +

+

+ +

+
+ + Member + Functions +
+
normal_distribution(RealType mean = 0, RealType sd = 1);
+
+

+ Constructs a normal distribution with mean mean and + standard deviation sd. +

+

+ Requires sd > 0, otherwise domain_error + is called. +

+
RealType mean()const;
+RealType location()const;
+
+

+ both return the mean of this distribution. +

+
RealType standard_deviation()const;
+RealType scale()const;
+
+

+ both return the standard deviation of this distribution. + (Redundant location and scale function are provided to match other similar + distributions, allowing the functions find_location and find_scale to be + used generically). +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [-[max_value], +[min_value]]. However, + the pdf of +∞ and -∞ = 0 is also supported, and cdf at -∞ = 0, cdf at +∞ = 1, and + complement cdf -∞ = 1 and +∞ = 0, if RealType permits. +

+
+ + Accuracy +
+

+ The normal distribution is implemented in terms of the error + function, and as such should have very low error rates. +

+
+ + Implementation +
+

+ In the following table m is the mean of the distribution, + and s is its standard deviation. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = e-(x-m)2/(2s2) / (s * sqrt(2*pi)) +

+
+

+ cdf +

+
+

+ Using the relation: p = 0.5 * erfc(-(x-m)/(s*sqrt(2))) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = 0.5 * erfc((x-m)/(s*sqrt(2))) +

+
+

+ quantile +

+
+

+ Using the relation: x = m - s * sqrt(2) * erfc_inv(2*p) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = m + s * sqrt(2) * erfc_inv(2*p) +

+
+

+ mean and standard deviation +

+
+

+ The same as dist.mean() and dist.standard_deviation() +

+
+

+ mode +

+
+

+ The same as the mean. +

+
+

+ median +

+
+

+ The same as the mean. +

+
+

+ skewness +

+
+

+ 0 +

+
+

+ kurtosis +

+
+

+ 3 +

+
+

+ kurtosis excess +

+
+

+ 0 +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/pareto.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/pareto.html new file mode 100644 index 00000000..9abcbf9b --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/pareto.html @@ -0,0 +1,350 @@ + + + +Pareto Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/pareto.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class pareto_distribution;
+
+typedef pareto_distribution<> pareto;
+
+template <class RealType, class Policy>
+class pareto_distribution
+{
+public:
+   typedef RealType value_type;
+   // Constructor:
+   pareto_distribution(RealType scale = 1, RealType shape = 1)
+   // Accessors:
+   RealType scale()const;
+   RealType shape()const;
+};
+
+}} // namespaces
+
+

+ The Pareto + distribution is a continuous distribution with the probability + density function (pdf): +

+

+ f(x; α, β) = αβα / xα+ 1 +

+

+ For shape parameter α   > 0, and scale parameter β   > 0. If x < β  , the + pdf is zero. +

+

+ The Pareto + distribution often describes the larger compared to the smaller. + A classic example is that 80% of the wealth is owned by 20% of the population. +

+

+ The following graph illustrates how the PDF varies with the scale parameter + β: +

+

+ +

+

+ And this graph illustrates how the PDF varies with the shape parameter + α: +

+

+ +

+
+ + Related + distributions +
+
+ + Member Functions +
+
pareto_distribution(RealType scale = 1, RealType shape = 1);
+
+

+ Constructs a pareto + distribution with shape shape and scale scale. +

+

+ Requires that the shape and scale + parameters are both greater than zero, otherwise calls domain_error. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of this distribution. +

+
RealType shape()const;
+
+

+ Returns the shape parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The supported domain of the random variable is [scale, ∞]. +

+
+ + Accuracy +
+

+ The Pareto distribution is implemented in terms of the standard library + exp functions plus expm1 and so should have very + small errors, usually only a few epsilon. +

+

+ If probability is near to unity (or the complement of a probability near + zero) see also why complements?. +

+
+ + Implementation +
+

+ In the following table α   is the shape parameter of the distribution, and + β   is its scale parameter, x is the random variate, + p is the probability and its complement q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf p = αβα/xα +1 +

+
+

+ cdf +

+
+

+ Using the relation: cdf p = 1 - (β   / x)α +

+
+

+ cdf complement +

+
+

+ Using the relation: q = 1 - p = -(β   / x)α +

+
+

+ quantile +

+
+

+ Using the relation: x = β / (1 - p)1/α +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = β / (q)1/α +

+
+

+ mean +

+
+

+ αβ / (β - 1) +

+
+

+ variance +

+
+

+ βα2 / (β - 1)2 (β - 2) +

+
+

+ mode +

+
+

+ α +

+
+

+ skewness +

+
+

+ Refer to Weisstein, + Eric W. "Pareto Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis +

+
+

+ Refer to Weisstein, + Eric W. "Pareto Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis excess +

+
+

+ Refer to Weisstein, + Eric W. "pareto Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+
+ + References +
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/poisson_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/poisson_dist.html new file mode 100644 index 00000000..daebe42b --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/poisson_dist.html @@ -0,0 +1,330 @@ + + + +Poisson Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/poisson.hpp>
+
namespace boost { namespace math {
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class poisson_distribution;
+
+typedef poisson_distribution<> poisson;
+
+template <class RealType, class Policy>
+class poisson_distribution
+{
+public:
+  typedef RealType value_type;
+  typedef Policy   policy_type;
+
+  poisson_distribution(RealType mean = 1); // Constructor.
+  RealType mean()const; // Accessor.
+}
+
+}} // namespaces boost::math
+
+

+ The Poisson + distribution is a well-known statistical discrete distribution. + It expresses the probability of a number of events (or failures, arrivals, + occurrences ...) occurring in a fixed period of time, provided these events + occur with a known mean rate λ   +(events/time), and are independent of the + time since the last event. +

+

+ The distribution was discovered by Simé on-Denis Poisson (1781 to 1840). +

+

+ It has the Probability Mass Function: +

+

+ +

+

+ for k events, with an expected number of events λ. +

+

+ The following graph illustrates how the PDF varies with the parameter λ: +

+

+ +

+
+ + + + + +
[Caution]Caution
+

+ The Poisson distribution is a discrete distribution: internally, functions + like the cdf and pdf are treated "as if" they + are continuous functions, but in reality the results returned from these + functions only have meaning if an integer value is provided for the random + variate argument. +

+

+ The quantile function will by default return an integer result that has + been rounded outwards. That is to say lower quantiles + (where the probability is less than 0.5) are rounded downward, and upper + quantiles (where the probability is greater than 0.5) are rounded upwards. + This behaviour ensures that if an X% quantile is requested, then at + least the requested coverage will be present in the central + region, and no more than the requested coverage + will be present in the tails. +

+

+ This behaviour can be changed so that the quantile functions are rounded + differently, or even return a real-valued result using Policies. + It is strongly recommended that you read the tutorial Understanding + Quantiles of Discrete Distributions before using the quantile + function on the Poisson distribution. The reference + docs describe how to change the rounding policy for these distributions. +

+
+
+ + Member + Functions +
+
poisson_distribution(RealType mean = 1);
+
+

+ Constructs a poisson distribution with mean mean. +

+
RealType mean()const;
+
+

+ Returns the mean of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, ∞]. +

+
+ + Accuracy +
+

+ The Poisson distribution is implemented in terms of the incomplete gamma + functions gamma_p and + gamma_q and as such + should have low error rates: but refer to the documentation of those functions + for more information. The quantile and its complement use the inverse gamma + functions and are therefore probably slightly less accurate: this is because + the inverse gamma functions are implemented using an iterative method with + a lower tolerance to avoid excessive computation. +

+
+ + Implementation +
+

+ In the following table λ   is the mean of the distribution, k + is the random variable, p is the probability and + q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = e-λ λk / k! +

+
+

+ cdf +

+
+

+ Using the relation: p = Γ(k+1, λ) / k! = gamma_q(k+1, + λ) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = gamma_p(k+1, + λ) +

+
+

+ quantile +

+
+

+ Using the relation: k = gamma_q_inva(λ, + p) - 1 +

+
+

+ quantile from the complement +

+
+

+ Using the relation: k = gamma_p_inva(λ, + q) - 1 +

+
+

+ mean +

+
+

+ λ +

+
+

+ mode +

+
+

+ floor (λ) or ⌊λ⌋ +

+
+

+ skewness +

+
+

+ 1/√λ +

+
+

+ kurtosis +

+
+

+ 3 + 1/λ +

+
+

+ kurtosis excess +

+
+

+ 1/λ +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/rayleigh.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/rayleigh.html new file mode 100644 index 00000000..8a158c09 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/rayleigh.html @@ -0,0 +1,347 @@ + + + +Rayleigh Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/rayleigh.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class rayleigh_distribution;
+
+typedef rayleigh_distribution<> rayleigh;
+
+template <class RealType, class Policy>
+class rayleigh_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   rayleigh_distribution(RealType sigma = 1)
+   // Accessors:
+   RealType sigma()const;
+};
+
+}} // namespaces
+
+

+ The Rayleigh + distribution is a continuous distribution with the probability + density function: +

+

+ f(x; sigma) = x * exp(-x2/2 σ2) / σ2 +

+

+ For sigma parameter σ   > 0, and x > 0. +

+

+ The Rayleigh distribution is often used where two orthogonal components + have an absolute value, for example, wind velocity and direction may be + combined to yield a wind speed, or real and imaginary components may have + absolute values that are Rayleigh distributed. +

+

+ The following graph illustrates how the Probability density Function(pdf) + varies with the shape parameter σ: +

+

+ +

+

+ and the Cumulative Distribution Function (cdf) +

+

+ +

+
+ + Related + distributions +
+

+ The absolute value of two independent normal distributions X and Y, √ (X2 + + Y2) is a Rayleigh distribution. +

+

+ The Chi, + Rice + and Weibull + distributions are generalizations of the Rayleigh + distribution. +

+
+ + Member + Functions +
+
rayleigh_distribution(RealType sigma = 1);
+
+

+ Constructs a Rayleigh + distribution with σ sigma. +

+

+ Requires that the σ parameter is greater than zero, otherwise calls domain_error. +

+
RealType sigma()const;
+
+

+ Returns the sigma parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, max_value]. +

+
+ + Accuracy +
+

+ The Rayleigh distribution is implemented in terms of the standard library + sqrt and exp and as such should have very low + error rates. Some constants such as skewness and kurtosis were calculated + using NTL RR type with 150-bit accuracy, about 50 decimal digits. +

+
+ + Implementation +
+

+ In the following table σ   is the sigma parameter of the distribution, x + is the random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = x * exp(-x2)/2 σ2 +

+
+

+ cdf +

+
+

+ Using the relation: p = 1 - exp(-x2/2) σ2   = -expm1(-x2/2) + σ2 +

+
+

+ cdf complement +

+
+

+ Using the relation: q = exp(-x2/ 2) * σ2 +

+
+

+ quantile +

+
+

+ Using the relation: x = sqrt(-2 * σ 2) * log(1 - p)) = sqrt(-2 + * σ 2) * log1p(-p)) +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = sqrt(-2 * σ 2) * log(q)) +

+
+

+ mean +

+
+

+ σ * sqrt(π/2) +

+
+

+ variance +

+
+

+ σ2 * (4 - π/2) +

+
+

+ mode +

+
+

+ σ +

+
+

+ skewness +

+
+

+ Constant from Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis +

+
+

+ Constant from Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis excess +

+
+

+ Constant from Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/skew_normal_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/skew_normal_dist.html new file mode 100644 index 00000000..b07c4961 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/skew_normal_dist.html @@ -0,0 +1,498 @@ + + + +Skew Normal Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/skew_normal.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class skew_normal_distribution;
+
+typedef skew_normal_distribution<> normal;
+
+template <class RealType, class Policy>
+class skew_normal_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Constructor:
+   skew_normal_distribution(RealType location = 0, RealType scale = 1, RealType shape = 0);
+   // Accessors:
+   RealType location()const; // mean if normal.
+   RealType scale()const; // width, standard deviation if normal.
+   RealType shape()const; // The distribution is right skewed if shape > 0 and is left skewed if shape < 0.
+                          // The distribution is normal if shape is zero.
+};
+
+}} // namespaces
+
+

+ The skew normal distribution is a variant of the most well known Gaussian + statistical distribution. +

+

+ The skew normal distribution with shape zero resembles the Normal + Distribution, hence the latter can be regarded as a special case + of the more generic skew normal distribution. +

+

+ If the standard (mean = 0, scale = 1) normal distribution probability density + function is +

+

+     +

+

+ and the cumulative distribution function +

+

+     +

+

+ then the PDF + of the skew + normal distribution with shape parameter α, defined by O'Hagan and + Leonhard (1976) is +

+

+     +

+

+ Given location + ξ, scale + ω, and shape + α, it can be transformed, + to the form: +

+

+     +

+

+ and CDF: +

+

+     +

+

+ where T(h,a) is Owen's T function, and Φ(x) + is the normal distribution. +

+

+ The variation the PDF and CDF with its parameters is illustrated in the + following graphs: +

+

+ + +

+
+ + Member + Functions +
+
skew_normal_distribution(RealType location = 0, RealType scale = 1, RealType shape = 0);
+
+

+ Constructs a skew_normal distribution with location ξ, scale ω and shape α. +

+

+ Requires scale > 0, otherwise domain_error + is called. +

+
RealType location()const;
+
+

+ returns the location ξ of this distribution, +

+
RealType scale()const;
+
+

+ returns the scale ω of this distribution, +

+
RealType shape()const;
+
+

+ returns the shape α of this distribution. +

+

+ (Location and scale function match other similar distributions, allowing + the functions find_location + and find_scale to be used + generically). +

+
+ + + + + +
[Note]Note
+

+ While the shape parameter may be chosen arbitrarily (finite), the resulting + skewness of the distribution is in fact + limited to about (-1, 1); strictly, the interval is (-0.9952717, 0.9952717). +

+

+ A parameter δ is related to the shape α by δ = α / (1 + α²), and used in the expression + for skewness + +

+
+
+ + References +
+
+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is -[max_value], +[min_value]. + Infinite values are not supported. +

+

+ There are no closed-form + expression known for the mode and median, but these are computed + for the +

+
    +
  • + mode - by finding the maximum of the PDF. +
  • +
  • + median - by computing quantile(1/2). +
  • +
+

+ The maximum of the PDF is sought through searching the root of f'(x)=0. +

+

+ Both involve iterative methods that will have lower accuracy than other + estimates. +

+
+ + Testing +
+

+ The R Project for Statistical Computing + using library(sn) described at Skew-Normal + Probability Distribution, and at R + skew-normal(sn) package. +

+

+ Package sn provides functions related to the skew-normal (SN) and the skew-t + (ST) probability distributions, both for the univariate and for the the + multivariate case, including regression models. +

+

+ Wolfram + Mathematica was also used to generate some more accurate spot test + data. +

+
+ + Accuracy +
+

+ The skew_normal distribution with shape = zero is implemented as a special + case, equivalent to the normal distribution in terms of the error + function, and therefore should have excellent accuracy. +

+

+ The PDF and mean, variance, skewness and kurtosis are also accurately evaluated + using analytical + expressions. The CDF requires Owen's + T function that is evaluated using a Boost C++ Owens + T implementation of the algorithms of M. Patefield and D. Tandy, + Journal of Statistical Software, 5(5), 1-25 (2000); the complicated accuracy + of this function is discussed in detail at Owens + T. +

+

+ The median and mode are calculated by iterative root finding, and both + will be less accurate. +

+
+ + Implementation +
+

+ In the following table, ξ is the location of the distribution, and ω is its + scale, and α is its shape. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using: +

+
+

+ cdf +

+
+

+ Using:
where T(h,a) + is Owen's T function, and Φ(x) is the normal + distribution. +

+
+

+ cdf complement +

+
+

+ Using: complement of normal distribution + 2 * Owens_t +

+
+

+ quantile +

+
+

+ Maximum of the pdf is sought through searching the root of f'(x)=0 +

+
+

+ quantile from the complement +

+
+

+ -quantile(SN(-location ξ, scale ω, -shapeα), p) +

+
+

+ location +

+
+

+ location ξ +

+
+

+ scale +

+
+

+ scale ω +

+
+

+ shape +

+
+

+ shape α +

+
+

+ median +

+
+

+ quantile(1/2) +

+
+

+ mean +

+
+

+ +

+
+

+ mode +

+
+

+ Maximum of the pdf is sought through searching the root of f'(x)=0 +

+
+

+ variance +

+
+

+ +

+
+

+ skewness +

+
+

+ +

+
+

+ kurtosis +

+
+

+ kurtosis excess-3 +

+
+

+ kurtosis excess +

+
+

+ +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/students_t_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/students_t_dist.html new file mode 100644 index 00000000..d671f14e --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/students_t_dist.html @@ -0,0 +1,430 @@ + + + +Students t Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/students_t.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class students_t_distribution;
+
+typedef students_t_distribution<> students_t;
+
+template <class RealType, class Policy>
+class students_t_distribution
+{
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+
+   // Construct:
+   students_t_distribution(const RealType& v);
+
+   // Accessor:
+   RealType degrees_of_freedom()const;
+
+   // degrees of freedom estimation:
+   static RealType find_degrees_of_freedom(
+      RealType difference_from_mean,
+      RealType alpha,
+      RealType beta,
+      RealType sd,
+      RealType hint = 100);
+};
+
+}} // namespaces
+
+

+ A statistical distribution published by William Gosset in 1908. His employer, + Guinness Breweries, required him to publish under a pseudonym (possibly + to hide that they were using statistics), so he chose "Student". + Given N independent measurements, let +

+

+ +

+

+ where M is the population mean,μ + is the sample mean, and s is the sample variance. +

+

+ Student's t-distribution is defined as the distribution of the random variable + t which is - very loosely - the "best" that we can do not knowing + the true standard deviation of the sample. It has the PDF: +

+

+ +

+

+ The Student's t-distribution takes a single parameter: the number of degrees + of freedom of the sample. When the degrees of freedom is one + then this distribution is the same as the Cauchy-distribution. As the number + of degrees of freedom tends towards infinity, then this distribution approaches + the normal-distribution. The following graph illustrates how the PDF varies + with the degrees of freedom ν: +

+

+ +

+
+ + Member + Functions +
+
students_t_distribution(const RealType& v);
+
+

+ Constructs a Student's t-distribution with v degrees + of freedom. +

+

+ Requires v > 0, otherwise calls domain_error. + Note that non-integral degrees of freedom are supported, and are meaningful + under certain circumstances. +

+
RealType degrees_of_freedom()const;
+
+

+ Returns the number of degrees of freedom of this distribution. +

+
static RealType find_degrees_of_freedom(
+   RealType difference_from_mean,
+   RealType alpha,
+   RealType beta,
+   RealType sd,
+   RealType hint = 100);
+
+

+ Returns the number of degrees of freedom required to observe a significant + result in the Student's t test when the mean differs from the "true" + mean by difference_from_mean. +

+
+

+
+
difference_from_mean
+

+ The difference between the true mean and the sample mean that we + wish to show is significant. +

+
alpha
+

+ The maximum acceptable probability of rejecting the null hypothesis + when it is in fact true. +

+
beta
+

+ The maximum acceptable probability of failing to reject the null + hypothesis when it is in fact false. +

+
sd
+

+ The sample standard deviation. +

+
hint
+

+ A hint for the location to start looking for the result, a good choice + for this would be the sample size of a previous borderline Student's + t test. +

+
+
+
+ + + + + +
[Note]Note

+ Remember that for a two-sided test, you must divide alpha by two before + calling this function. +

+

+ For more information on this function see the NIST + Engineering Statistics Handbook. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [-∞, +∞]. +

+
+ + Examples +
+

+ Various worked examples + are available illustrating the use of the Student's t distribution. +

+
+ + Accuracy +
+

+ The normal distribution is implemented in terms of the incomplete + beta function and its + inverses, refer to accuracy data on those functions for more information. +

+
+ + Implementation +
+

+ In the following table v is the degrees of freedom + of the distribution, t is the random variate, p + is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = (v / (v + t2))(1+v)/2 / (sqrt(v) * + beta(v/2, + 0.5)) +

+
+

+ cdf +

+
+

+ Using the relations: +

+

+ p = 1 - z iff t > 0 +

+

+ p = z otherwise +

+

+ where z is given by: +

+

+ ibeta(v + / 2, 0.5, v / (v + t2)) / 2 iff v < 2t2 +

+

+ ibetac(0.5, + v / 2, t2 / (v + t2) / 2 otherwise +

+
+

+ cdf complement +

+
+

+ Using the relation: q = cdf(-t) +

+
+

+ quantile +

+
+

+ Using the relation: t = sign(p - 0.5) * sqrt(v * y / x) +

+

+ where: +

+

+ x = ibeta_inv(v + / 2, 0.5, 2 * min(p, q)) +

+

+ y = 1 - x +

+

+ The quantities x and y + are both returned by ibeta_inv + without the subtraction implied above. +

+
+

+ quantile from the complement +

+
+

+ Using the relation: t = -quantile(q) +

+
+

+ mode +

+
+

+ 0 +

+
+

+ mean +

+
+

+ 0 +

+
+

+ variance +

+
+

+ if (v > 2) v / (v - 2) else NaN +

+
+

+ skewness +

+
+

+ if (v > 3) 0 else NaN +

+
+

+ kurtosis +

+
+

+ if (v > 4) 3 * (v - 2) / (v - 4) else NaN +

+
+

+ kurtosis excess +

+
+

+ if (v > 4) 6 / (df - 4) else NaN +

+
+

+ If the moment index k is less than v, + then the moment is undefined. Evaluating the moment will throw a domain_error + unless ignored by a policy, when it will return std::numeric_limits<>::quiet_NaN(); +

+

+ (For simplicity, we have not implemented the return of infinity in some + cases as suggested by Wikipedia + Student's t. See also https://svn.boost.org/trac/boost/ticket/7177.) +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/triangular_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/triangular_dist.html new file mode 100644 index 00000000..3fff3219 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/triangular_dist.html @@ -0,0 +1,446 @@ + + + +Triangular Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/triangular.hpp>
+
namespace boost{ namespace math{
+ template <class RealType = double,
+           class Policy   = policies::policy<> >
+ class triangular_distribution;
+
+ typedef triangular_distribution<> triangular;
+
+ template <class RealType, class Policy>
+ class triangular_distribution
+ {
+ public:
+    typedef RealType value_type;
+    typedef Policy   policy_type;
+
+    triangular_distribution(RealType lower = -1, RealType mode = 0) RealType upper = 1); // Constructor.
+       : m_lower(lower), m_mode(mode), m_upper(upper) // Default is -1, 0, +1 symmetric triangular distribution.
+    // Accessor functions.
+    RealType lower()const;
+    RealType mode()const;
+    RealType upper()const;
+ }; // class triangular_distribution
+
+}} // namespaces
+
+

+ The triangular + distribution is a continuous + probability + distribution with a lower limit a, mode + c, and upper limit b. +

+

+ The triangular distribution is often used where the distribution is only + vaguely known, but, like the uniform + distribution, upper and limits are 'known', but a 'best guess', + the mode or center point, is also added. It has been recommended as a + proxy + for the beta distribution. The distribution is used in business + decision making and project planning. +

+

+ The triangular + distribution is a distribution with the probability + density function: +

+

+    f(x) = +

+
    +
  • + 2(x-a)/(b-a) (c-a) for a <= x <= c +
  • +
  • + 2(b-x)/(b-a)(b-c) for c < x <= b +
  • +
+

+ Parameter a (lower) can be any finite value. Parameter + b (upper) can be any finite value > a (lower). + Parameter c (mode) a <= c <= b. This is the + most probable value. +

+

+ The random variate + x must also be finite, and is supported lower <= x <= upper. +

+

+ The triangular distribution may be appropriate when an assumption of a + normal distribution is unjustified because uncertainty is caused by rounding + and quantization from analog to digital conversion. Upper and lower limits + are known, and the most probable value lies midway. +

+

+ The distribution simplifies when the 'best guess' is either the lower or + upper limit - a 90 degree angle triangle. The 001 triangular distribution + which expresses an estimate that the lowest value is the most likely; for + example, you believe that the next-day quoted delivery date is most likely + (knowing that a quicker delivery is impossible - the postman only comes + once a day), and that longer delays are decreasingly likely, and delivery + is assumed to never take more than your upper limit. +

+

+ The following graph illustrates how the probability + density function PDF varies with the various parameters: +

+

+ +

+

+ and cumulative distribution function +

+

+ +

+
+ + Member + Functions +
+
triangular_distribution(RealType lower = 0, RealType mode = 0 RealType upper = 1);
+
+

+ Constructs a triangular + distribution with lower lower (a) and upper + upper (b). +

+

+ Requires that the lower, mode + and upper parameters are all finite, otherwise calls + domain_error. +

+
+ + + + + +
[Warning]Warning
+

+ These constructors are slightly different from the analogs provided by + Wolfram MathWorld + Triangular + distribution, where +

+

+ TriangularDistribution[{min, max}] represents a symmetric triangular statistical distribution + giving values between min and max.
TriangularDistribution[] + represents a symmetric triangular statistical + distribution giving values between 0 and 1.
TriangularDistribution[{min, + max}, c] represents a triangular distribution with mode at + c (usually asymmetric).
+

+

+ So, for example, to compute a variance using Wolfram + Alpha, use N[variance[TriangularDistribution{1, +2}], + 50] +

+
+

+ The parameters of a distribution can be obtained using these member functions: +

+
RealType lower()const;
+
+

+ Returns the lower parameter of this distribution (default + -1). +

+
RealType mode()const;
+
+

+ Returns the mode parameter of this distribution (default + 0). +

+
RealType upper()const;
+
+

+ Returns the upper parameter of this distribution (default+1). +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is \lowerto \upper, and the supported + range is lower <= x <= upper. +

+
+ + Accuracy +
+

+ The triangular distribution is implemented with simple arithmetic operators + and so should have errors within an epsilon or two, except quantiles with + arguments nearing the extremes of zero and unity. +

+
+ + Implementation +
+

+ In the following table, a is the lower parameter of + the distribution, c is the mode parameter, b is the + upper parameter, x is the random + variate, p is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = 0 for x < mode, 2(x-a)/(b-a)(c-a) + else 2*(b-x)/((b-a)(b-c)) +

+
+

+ cdf +

+
+

+ Using the relation: cdf = 0 for x < mode (x-a)2/((b-a)(c-a)) + else 1 - (b-x)2/((b-a)(b-c)) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = 1 - p +

+
+

+ quantile +

+
+

+ let p0 = (c-a)/(b-a) the point of inflection on the cdf, then + given probability p and q = 1-p: +

+

+ x = sqrt((b-a)(c-a)p) + a ; for p < p0 +

+

+ x = c ; for p == p0 +

+

+ x = b - sqrt((b-a)(b-c)q) ; for p > p0 +

+

+ (See /boost/math/distributions/triangular.hpp + for details.) +

+
+

+ quantile from the complement +

+
+

+ As quantile (See /boost/math/distributions/triangular.hpp + for details.) +

+
+

+ mean +

+
+

+ (a + b + 3) / 3 +

+
+

+ variance +

+
+

+ (a2+b2+c2 - ab - ac - bc)/18 +

+
+

+ mode +

+
+

+ c +

+
+

+ skewness +

+
+

+ (See /boost/math/distributions/triangular.hpp + for details). +

+
+

+ kurtosis +

+
+

+ 12/5 +

+
+

+ kurtosis excess +

+
+

+ -3/5 +

+
+

+ Some 'known good' test values were obtained using Wolfram + Alpha. +

+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/uniform_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/uniform_dist.html new file mode 100644 index 00000000..ef30e3d9 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/uniform_dist.html @@ -0,0 +1,367 @@ + + + +Uniform Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/uniform.hpp>
+
namespace boost{ namespace math{
+ template <class RealType = double,
+           class Policy   = policies::policy<> >
+ class uniform_distribution;
+
+ typedef uniform_distribution<> uniform;
+
+ template <class RealType, class Policy>
+ class uniform_distribution
+ {
+ public:
+    typedef RealType value_type;
+
+    uniform_distribution(RealType lower = 0, RealType upper = 1); // Constructor.
+       : m_lower(lower), m_upper(upper) // Default is standard uniform distribution.
+    // Accessor functions.
+    RealType lower()const;
+    RealType upper()const;
+ }; // class uniform_distribution
+
+}} // namespaces
+
+

+ The uniform distribution, also known as a rectangular distribution, is + a probability distribution that has constant probability. +

+

+ The continuous + uniform distribution is a distribution with the probability + density function: +

+

+ f(x) = +

+
    +
  • + 1 / (upper - lower) for lower < x < upper +
  • +
  • + zero for x < lower or x > upper +
  • +
+

+ and in this implementation: +

+
  • + 1 / (upper - lower) for x = lower or x = upper +
+

+ The choice of x = lower or x = upper is made because statistical use of + this distribution judged is most likely: the method of maximum likelihood + uses this definition. +

+

+ There is also a discrete uniform distribution. +

+

+ Parameters lower and upper can be any finite value. +

+

+ The random variate + x must also be finite, and is supported lower <= x <= upper. +

+

+ The lower parameter is also called the location + parameter, that + is where the origin of a plot will lie, and (upper - lower) is + also called the scale + parameter. +

+

+ The following graph illustrates how the probability + density function PDF varies with the shape parameter: +

+

+ +

+

+ Likewise for the CDF: +

+

+ +

+
+ + Member + Functions +
+
uniform_distribution(RealType lower = 0, RealType upper = 1);
+
+

+ Constructs a uniform + distribution with lower lower (a) and upper + upper (b). +

+

+ Requires that the lower and upper + parameters are both finite; otherwise if infinity or NaN then calls domain_error. +

+
RealType lower()const;
+
+

+ Returns the lower parameter of this distribution. +

+
RealType upper()const;
+
+

+ Returns the upper parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is any finite value, but the supported + range is only lower <= x <= upper. +

+
+ + Accuracy +
+

+ The uniform distribution is implemented with simple arithmetic operators + and so should have errors within an epsilon or two. +

+
+ + Implementation +
+

+ In the following table a is the lower parameter of + the distribution, b is the upper parameter, x + is the random variate, p is the probability and q + = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = 0 for x < a, 1 / (b - a) for a <= + x <= b, 0 for x > b +

+
+

+ cdf +

+
+

+ Using the relation: cdf = 0 for x < a, (x - a) / (b - a) for + a <= x <= b, 1 for x > b +

+
+

+ cdf complement +

+
+

+ Using the relation: q = 1 - p, (b - x) / (b - a) +

+
+

+ quantile +

+
+

+ Using the relation: x = p * (b - a) + a; +

+
+

+ quantile from the complement +

+
+

+ x = -q * (b - a) + b +

+
+

+ mean +

+
+

+ (a + b) / 2 +

+
+

+ variance +

+
+

+ (b - a) 2 / 12 +

+
+

+ mode +

+
+

+ any value in [a, b] but a is chosen. (Would NaN be better?) +

+
+

+ skewness +

+
+

+ 0 +

+
+

+ kurtosis excess +

+
+

+ -6/5 = -1.2 exactly. (kurtosis - 3) +

+
+

+ kurtosis +

+
+

+ 9/5 +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/weibull_dist.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/weibull_dist.html new file mode 100644 index 00000000..0d3b0764 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/weibull_dist.html @@ -0,0 +1,369 @@ + + + +Weibull Distribution + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/distributions/weibull.hpp>
+
namespace boost{ namespace math{
+
+template <class RealType = double,
+          class Policy   = policies::policy<> >
+class weibull_distribution;
+
+typedef weibull_distribution<> weibull;
+
+template <class RealType, class Policy>
+class weibull_distribution
+{
+public:
+   typedef RealType value_type;
+   typedef Policy   policy_type;
+   // Construct:
+   weibull_distribution(RealType shape, RealType scale = 1)
+   // Accessors:
+   RealType shape()const;
+   RealType scale()const;
+};
+
+}} // namespaces
+
+

+ The Weibull + distribution is a continuous distribution with the probability + density function: +

+

+ f(x; α, β) = (α/β) * (x / β)α - 1 * e-(x/β)α +

+

+ For shape parameter α   > 0, and scale parameter β   > 0, and x > 0. +

+

+ The Weibull distribution is often used in the field of failure analysis; + in particular it can mimic distributions where the failure rate varies + over time. If the failure rate is: +

+
    +
  • + constant over time, then α   = 1, suggests that items are failing from + random events. +
  • +
  • + decreases over time, then α   < 1, suggesting "infant mortality". +
  • +
  • + increases over time, then α   > 1, suggesting "wear out" - + more likely to fail as time goes by. +
  • +
+

+ The following graph illustrates how the PDF varies with the shape parameter + α: +

+

+ +

+

+ While this graph illustrates how the PDF varies with the scale parameter + β: +

+

+ +

+
+ + Related + distributions +
+

+ When α   = 3, the Weibull + distribution appears similar to the normal + distribution. When α   = 1, the Weibull distribution reduces to the + exponential + distribution. The relationship of the types of extreme value distributions, + of which the Weibull is but one, is discussed by Extreme + Value Distributions, Theory and Applications Samuel Kotz & Saralees + Nadarajah. +

+
+ + Member + Functions +
+
weibull_distribution(RealType shape, RealType scale = 1);
+
+

+ Constructs a Weibull + distribution with shape shape and scale scale. +

+

+ Requires that the shape and scale + parameters are both greater than zero, otherwise calls domain_error. +

+
RealType shape()const;
+
+

+ Returns the shape parameter of this distribution. +

+
RealType scale()const;
+
+

+ Returns the scale parameter of this distribution. +

+
+ + Non-member + Accessors +
+

+ All the usual non-member accessor + functions that are generic to all distributions are supported: + Cumulative Distribution Function, + Probability Density Function, + Quantile, Hazard Function, Cumulative Hazard Function, + mean, median, + mode, variance, + standard deviation, + skewness, kurtosis, kurtosis_excess, + range and support. +

+

+ The domain of the random variable is [0, ∞]. +

+
+ + Accuracy +
+

+ The Weibull distribution is implemented in terms of the standard library + log and exp + functions plus expm1 and + log1p and as such should + have very low error rates. +

+
+ + Implementation +
+

+ In the following table α   is the shape parameter of the distribution, β   is its + scale parameter, x is the random variate, p + is the probability and q = 1-p. +

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Function +

+
+

+ Implementation Notes +

+
+

+ pdf +

+
+

+ Using the relation: pdf = αβ-α xα - 1 e-(x/beta)alpha +

+
+

+ cdf +

+
+

+ Using the relation: p = -expm1(-(x/β)α) +

+
+

+ cdf complement +

+
+

+ Using the relation: q = e-(x/β)α +

+
+

+ quantile +

+
+

+ Using the relation: x = β * (-log1p(-p))1/α +

+
+

+ quantile from the complement +

+
+

+ Using the relation: x = β * (-log(q))1/α +

+
+

+ mean +

+
+

+ β * Γ(1 + 1/α) +

+
+

+ variance +

+
+

+ β2(Γ(1 + 2/α) - Γ2(1 + 1/α)) +

+
+

+ mode +

+
+

+ β((α - 1) / α)1/α +

+
+

+ skewness +

+
+

+ Refer to Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis +

+
+

+ Refer to Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+

+ kurtosis excess +

+
+

+ Refer to Weisstein, + Eric W. "Weibull Distribution." From MathWorld--A Wolfram + Web Resource. +

+
+
+ + References +
+ +
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/dist_ref/nmp.html b/boost/libs/math/doc/html/math_toolkit/dist_ref/nmp.html new file mode 100644 index 00000000..b199263c --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/dist_ref/nmp.html @@ -0,0 +1,706 @@ + + + +Non-Member Properties + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Properties that are common to all distributions are accessed via non-member + getter functions: non-membership allows more of these functions to be added + over time, as the need arises. Unfortunately the literature uses many different + and confusing names to refer to a rather small number of actual concepts; + refer to the concept + index to find the property you want by the name you are most familiar + with. Or use the function + index to go straight to the function you want if you already know + its name. +

+
+ + Function + Index +
+ +
+ + Conceptual + Index +
+ +
+ + Cumulative + Distribution Function +
+
template <class RealType, class Policy>
+RealType cdf(const Distribution-Type<RealType, Policy>& dist, const RealType& x);
+
+

+ The Cumulative Distribution + Function is the probability that the variable takes a value less than + or equal to x. It is equivalent to the integral from -infinity to x of the + Probability Density Function. +

+

+ This function may return a domain_error + if the random variable is outside the defined range for the distribution. +

+

+ For example, the following graph shows the cdf for the normal distribution: +

+

+ +

+
+ + Complement + of the Cumulative Distribution Function +
+
template <class Distribution, class RealType>
+RealType cdf(const Unspecified-Complement-Type<Distribution, RealType>& comp);
+
+

+ The complement of the Cumulative + Distribution Function is the probability that the variable takes a + value greater than x. It is equivalent to the integral from x to infinity + of the Probability Density + Function, or 1 minus the Cumulative + Distribution Function of x. +

+

+ This is also known as the survival function. +

+

+ This function may return a domain_error + if the random variable is outside the defined range for the distribution. +

+

+ In this library, it is obtained by wrapping the arguments to the cdf function in a call to complement, for example: +

+
// standard normal distribution object:
+boost::math::normal norm;
+// print survival function for x=2.0:
+std::cout << cdf(complement(norm, 2.0)) << std::endl;
+
+

+ For example, the following graph shows the __complement of the cdf for the + normal distribution: +

+

+ +

+

+ See why complements? for why the complement + is useful and when it should be used. +

+
+ + Hazard + Function +
+
template <class RealType, class Policy>
+RealType hazard(const Distribution-Type<RealType, Policy>& dist, const RealType& x);
+
+

+ Returns the Hazard Function + of x and distibution dist. +

+

+ This function may return a domain_error + if the random variable is outside the defined range for the distribution. +

+

+ +

+
+ + + + + +
[Caution]Caution

+ Some authors refer to this as the conditional failure density function + rather than the hazard function. +

+
+ + Cumulative + Hazard Function +
+
template <class RealType, class Policy>
+RealType chf(const Distribution-Type<RealType, Policy>& dist, const RealType& x);
+
+

+ Returns the Cumulative Hazard + Function of x and distibution dist. +

+

+ This function may return a domain_error + if the random variable is outside the defined range for the distribution. +

+

+ +

+
+ + + + + +
[Caution]Caution

+ Some authors refer to this as simply the "Hazard Function". +

+
+ + mean +
+
template<class RealType, class Policy>
+RealType mean(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the mean of the distribution dist. +

+

+ This function may return a domain_error + if the distribution does not have a defined mean (for example the Cauchy + distribution). +

+
+ + median +
+
template<class RealType, class Policy>
+RealType median(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the median of the distribution dist. +

+
+ + mode +
+
template<class RealType, Policy>
+RealType mode(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the mode of the distribution dist. +

+

+ This function may return a domain_error + if the distribution does not have a defined mode. +

+
+ + Probability + Density Function +
+
template <class RealType, class Policy>
+RealType pdf(const Distribution-Type<RealType, Policy>& dist, const RealType& x);
+
+

+ For a continuous function, the probability density function (pdf) returns + the probability that the variate has the value x. Since for continuous distributions + the probability at a single point is actually zero, the probability is better + expressed as the integral of the pdf between two points: see the Cumulative + Distribution Function. +

+

+ For a discrete distribution, the pdf is the probability that the variate + takes the value x. +

+

+ This function may return a domain_error + if the random variable is outside the defined range for the distribution. +

+

+ For example, for a standard normal distribution the pdf looks like this: +

+

+ +

+
+ + Range +
+
template<class RealType, class Policy>
+std::pair<RealType, RealType> range(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the valid range of the random variable over distribution dist. +

+
+ + Quantile +
+
template <class RealType, class Policy>
+RealType quantile(const Distribution-Type<RealType, Policy>& dist, const RealType& p);
+
+

+ The quantile is best viewed as the inverse of the Cumulative + Distribution Function, it returns a value x such + that cdf(dist, x) == + p. +

+

+ This is also known as the percent point function, or + percentile, or fractile, it is + also the same as calculating the lower critical value + of a distribution. +

+

+ This function returns a domain_error + if the probability lies outside [0,1]. The function may return an overflow_error + if there is no finite value that has the specified probability. +

+

+ The following graph shows the quantile function for a standard normal distribution: +

+

+ +

+
+ + Quantile + from the complement of the probability. +
+

+ See also complements. +

+
template <class Distribution, class RealType>
+RealType quantile(const Unspecified-Complement-Type<Distribution, RealType>& comp);
+
+

+ This is the inverse of the Complement + of the Cumulative Distribution Function. It is calculated by wrapping + the arguments in a call to the quantile function in a call to complement. + For example: +

+
// define a standard normal distribution:
+boost::math::normal norm;
+// print the value of x for which the complement
+// of the probability is 0.05:
+std::cout << quantile(complement(norm, 0.05)) << std::endl;
+
+

+ The function computes a value x such that cdf(complement(dist, + x)) == q where + q is complement of the probability. +

+

+ Why complements? +

+

+ This function is also called the inverse survival function, and is the same + as calculating the upper critical value of a distribution. +

+

+ This function returns a domain_error + if the probablity lies outside [0,1]. The function may return an overflow_error + if there is no finite value that has the specified probability. +

+

+ The following graph show the inverse survival function for the normal distribution: +

+

+ +

+
+ + Standard + Deviation +
+
template <class RealType, class Policy>
+RealType standard_deviation(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the standard deviation of distribution dist. +

+

+ This function may return a domain_error + if the distribution does not have a defined standard deviation. +

+
+ + support +
+
template<class RealType, class Policy>
+std::pair<RealType, RealType> support(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the supported range of random variable over the distribution dist. +

+

+ The distribution is said to be 'supported' over a range that is "the + smallest closed set whose complement has probability zero". + Non-mathematicians might say it means the 'interesting' smallest range of + random variate x that has the cdf going from zero to unity. Outside are uninteresting + zones where the pdf is zero, and the cdf zero or unity. +

+
+ + Variance +
+
template <class RealType, class Policy>
+RealType variance(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the variance of the distribution dist. +

+

+ This function may return a domain_error + if the distribution does not have a defined variance. +

+
+ + Skewness +
+
template <class RealType, class Policy>
+RealType skewness(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the skewness of the distribution dist. +

+

+ This function may return a domain_error + if the distribution does not have a defined skewness. +

+
+ + Kurtosis +
+
template <class RealType, class Policy>
+RealType kurtosis(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the 'proper' kurtosis (normalized fourth moment) of the distribution + dist. +

+

+ kertosis = β2  = μ4   / μ22 +

+

+ Where μi   is the i'th central moment of the distribution, and in particular + μ2   is the variance of the distribution. +

+

+ The kurtosis is a measure of the "peakedness" of a distribution. +

+

+ Note that the literature definition of kurtosis is confusing. The definition + used here is that used by for example Wolfram + MathWorld (that includes a table of formulae for kurtosis excess + for various distributions) but NOT the definition of kurtosis + used by Wikipedia which treats "kurtosis" and "kurtosis + excess" as the same quantity. +

+
kurtosis_excess = 'proper' kurtosis - 3
+
+

+ This subtraction of 3 is convenient so that the kurtosis excess + of a normal distribution is zero. +

+

+ This function may return a domain_error + if the distribution does not have a defined kurtosis. +

+

+ 'Proper' kurtosis can have a value from zero to + infinity. +

+
+ + Kurtosis + excess +
+
template <class RealType, Policy>
+RealType kurtosis_excess(const Distribution-Type<RealType, Policy>& dist);
+
+

+ Returns the kurtosis excess of the distribution dist. +

+

+ kurtosis excess = γ2  = μ4   / μ22  - 3 = kurtosis - 3 +

+

+ Where μi   is the i'th central moment of the distribution, and in particular + μ2   is the variance of the distribution. +

+

+ The kurtosis excess is a measure of the "peakedness" of a distribution, + and is more widely used than the "kurtosis proper". It is defined + so that the kurtosis excess of a normal distribution is zero. +

+

+ This function may return a domain_error + if the distribution does not have a defined kurtosis excess. +

+

+ Kurtosis excess can have a value from -2 to + infinity. +

+
kurtosis = kurtosis_excess +3;
+
+

+ The kurtosis excess of a normal distribution is zero. +

+
+ + P + and Q +
+

+ The terms P and Q are sometimes used to refer to the Cumulative + Distribution Function and its complement + respectively. Lowercase p and q are sometimes used to refer to the values + returned by these functions. +

+
+ + Percent + Point Function or Percentile +
+

+ The percent point function, also known as the percentile, is the same as + the Quantile. +

+
+ + Inverse + CDF Function. +
+

+ The inverse of the cumulative distribution function, is the same as the + Quantile. +

+
+ + Inverse + Survival Function. +
+

+ The inverse of the survival function, is the same as computing the quantile from the complement + of the probability. +

+
+ + Probability + Mass Function +
+

+ The Probability Mass Function is the same as the Probability + Density Function. +

+

+ The term Mass Function is usually applied to discrete distributions, while + the term Probability Density + Function applies to continuous distributions. +

+
+ + Lower + Critical Value. +
+

+ The lower critical value calculates the value of the random variable given + the area under the left tail of the distribution. It is equivalent to calculating + the Quantile. +

+
+ + Upper + Critical Value. +
+

+ The upper critical value calculates the value of the random variable given + the area under the right tail of the distribution. It is equivalent to calculating + the quantile from the + complement of the probability. +

+
+ + Survival + Function +
+

+ Refer to the Complement of + the Cumulative Distribution Function. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3