]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/doc/distributions/nc_beta.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / distributions / nc_beta.qbk
CommitLineData
7c673cae
FG
1[section:nc_beta_dist Noncentral Beta Distribution]
2
3``#include <boost/math/distributions/non_central_beta.hpp>``
4
5 namespace boost{ namespace math{
6
7 template <class RealType = double,
8 class ``__Policy`` = ``__policy_class`` >
9 class non_central_beta_distribution;
10
11 typedef non_central_beta_distribution<> non_central_beta;
12
13 template <class RealType, class ``__Policy``>
14 class non_central_beta_distribution
15 {
16 public:
17 typedef RealType value_type;
18 typedef Policy policy_type;
19
20 // Constructor:
21 non_central_beta_distribution(RealType alpha, RealType beta, RealType lambda);
22
23 // Accessor to shape parameters:
24 RealType alpha()const;
25 RealType beta()const;
26
27 // Accessor to non-centrality parameter lambda:
28 RealType non_centrality()const;
29 };
30
31 }} // namespaces
32
33The noncentral beta distribution is a generalization of the __beta_distrib.
34
35It is defined as the ratio
36X = [chi][sub m][super 2]([lambda]) \/ ([chi][sub m][super 2]([lambda])
37+ [chi][sub n][super 2])
38where [chi][sub m][super 2]([lambda]) is a noncentral [chi][super 2]
39random variable with /m/ degrees of freedom, and [chi][sub n][super 2]
40is a central [chi][super 2] random variable with /n/ degrees of freedom.
41
42This gives a PDF that can be expressed as a Poisson mixture
43of beta distribution PDFs:
44
45[equation nc_beta_ref1]
46
47where P(i;[lambda]\/2) is the discrete Poisson probablity at /i/, with mean
48[lambda]\/2, and I[sub x][super ']([alpha], [beta]) is the derivative of
49the incomplete beta function. This leads to the usual form of the CDF
50as:
51
52[equation nc_beta_ref2]
53
54The following graph illustrates how the distribution changes
55for different values of [lambda]:
56
57[graph nc_beta_pdf]
58
59[h4 Member Functions]
60
61 non_central_beta_distribution(RealType a, RealType b, RealType lambda);
62
63Constructs a noncentral beta distribution with shape parameters /a/ and /b/
64and non-centrality parameter /lambda/.
65
66Requires a > 0, b > 0 and lambda >= 0, otherwise calls __domain_error.
67
68 RealType alpha()const;
69
70Returns the parameter /a/ from which this object was constructed.
71
72 RealType beta()const;
73
74Returns the parameter /b/ from which this object was constructed.
75
76 RealType non_centrality()const;
77
78Returns the parameter /lambda/ from which this object was constructed.
79
80[h4 Non-member Accessors]
81
82Most of the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
83are supported: __cdf, __pdf, __quantile, __mean, __variance, __sd,
84__median, __mode, __hazard, __chf, __range and __support.
85
86Mean and variance are implemented using hypergeometric pfq functions and relations given in
87[@http://reference.wolfram.com/mathematica/ref/NoncentralBetaDistribution.html Wolfram Noncentral Beta Distribution].
88
89However, the following are not currently implemented:
90 __skewness, __kurtosis and __kurtosis_excess.
91
92The domain of the random variable is \[0, 1\].
93
94[h4 Accuracy]
95
96The following table shows the peak errors
97(in units of [@http://en.wikipedia.org/wiki/Machine_epsilon epsilon])
98found on various platforms with various floating point types.
99The failures in the comparison to the [@http://www.r-project.org/ R Math library],
100seem to be mostly in the corner cases when the probablity would be very small.
101Unless otherwise specified any floating-point type that is narrower
102than the one shown will have __zero_error.
103
104[table_non_central_beta_CDF]
105
106[table_non_central_beta_CDF_complement]
107
108Error rates for the PDF, the complement of the CDF and for the quantile
109functions are broadly similar.
110
111[h4 Tests]
112
113There are two sets of test data used to verify this implementation:
114firstly we can compare with a few sample values generated by the
115[@http://www.r-project.org/ R library].
116Secondly, we have tables of test data, computed with this
117implementation and using interval arithmetic - this data should
118be accurate to at least 50 decimal digits - and is the used for
119our accuracy tests.
120
121[h4 Implementation]
122
123The CDF and its complement are evaluated as follows:
124
125First we determine which of the two values (the CDF or its
126complement) is likely to be the smaller, the crossover point
127is taken to be the mean of the distribution: for this we use the
128approximation due to: R. Chattamvelli and R. Shanmugam,
129"Algorithm AS 310: Computing the Non-Central Beta Distribution Function",
130Applied Statistics, Vol. 46, No. 1. (1997), pp. 146-156.
131
132[equation nc_beta_ref3]
133
134Then either the CDF or its complement is computed using the
135relations:
136
137[equation nc_beta_ref4]
138
139The summation is performed by starting at i = [lambda]/2, and then recursing
140in both directions, using the usual recurrence relations for the Poisson
141PDF and incomplete beta functions. This is the "Method 2" described
142by:
143
144Denise Benton and K. Krishnamoorthy,
145"Computing discrete mixtures of continuous
146distributions: noncentral chisquare, noncentral t
147and the distribution of the square of the sample
148multiple correlation coefficient",
149Computational Statistics & Data Analysis 43 (2003) 249-267.
150
151Specific applications of the above formulae to the noncentral
152beta distribution can be found in:
153
154Russell V. Lenth,
155"Algorithm AS 226: Computing Noncentral Beta Probabilities",
156Applied Statistics, Vol. 36, No. 2. (1987), pp. 241-244.
157
158H. Frick,
159"Algorithm AS R84: A Remark on Algorithm AS 226: Computing Non-Central Beta
160Probabilities", Applied Statistics, Vol. 39, No. 2. (1990), pp. 311-312.
161
162Ming Long Lam,
163"Remark AS R95: A Remark on Algorithm AS 226: Computing Non-Central Beta
164Probabilities", Applied Statistics, Vol. 44, No. 4. (1995), pp. 551-552.
165
166Harry O. Posten,
167"An Effective Algorithm for the Noncentral Beta Distribution Function",
168The American Statistician, Vol. 47, No. 2. (May, 1993), pp. 129-131.
169
170R. Chattamvelli,
171"A Note on the Noncentral Beta Distribution Function",
172The American Statistician, Vol. 49, No. 2. (May, 1995), pp. 231-234.
173
174Of these, the Posten reference provides the most complete overview,
175and includes the modification starting iteration at [lambda]/2.
176
177The main difference between this implementation and the above
178references is the direct computation of the complement when most
179efficient to do so, and the accumulation of the sum to -1 rather
180than subtracting the result from 1 at the end: this can substantially
181reduce the number of iterations required when the result is near 1.
182
183The PDF is computed using the methodology of Benton and Krishnamoorthy
184and the relation:
185
186[equation nc_beta_ref1]
187
188Quantiles are computed using a specially modified version of
189__bracket_solve,
190starting the search for the root at the mean of the distribution.
191(A Cornish-Fisher type expansion was also tried, but while this gets
192quite close to the root in many cases, when it is wrong it tends to
193introduce quite pathological behaviour: more investigation in this
194area is probably warranted).
195
196[endsect] [/section:nc_beta_dist]
197
198[/ nc_beta.qbk
199 Copyright 2008 John Maddock and Paul A. Bristow.
200 Distributed under the Boost Software License, Version 1.0.
201 (See accompanying file LICENSE_1_0.txt or copy at
202 http://www.boost.org/LICENSE_1_0.txt).
203]
204