Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / distributions / uniform.qbk
1 [section:uniform_dist Uniform Distribution]
2
3
4 ``#include <boost/math/distributions/uniform.hpp>``
5
6    namespace boost{ namespace math{
7     template <class RealType = double, 
8               class ``__Policy``   = ``__policy_class`` >
9     class uniform_distribution;
10       
11     typedef uniform_distribution<> uniform;
12
13     template <class RealType, class ``__Policy``>
14     class uniform_distribution
15     {
16     public:
17        typedef RealType value_type;
18
19        uniform_distribution(RealType lower = 0, RealType upper = 1); // Constructor.
20           : m_lower(lower), m_upper(upper) // Default is standard uniform distribution.
21        // Accessor functions.
22        RealType lower()const;
23        RealType upper()const;
24     }; // class uniform_distribution
25    
26    }} // namespaces
27    
28 The uniform distribution, also known as a rectangular distribution,
29 is a probability distribution that has constant probability.
30
31 The [@http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29 continuous uniform distribution]
32 is a distribution with the 
33 [@http://en.wikipedia.org/wiki/Probability_density_function probability density function]:
34
35 [expression f(x) =1 / (upper - lower) [sixemspace] for lower < x < upper]
36 [expression f(x) =zero [sixemspace] for x < lower or x > upper]
37         
38 and in this implementation:
39         
40 [expression 1 / (upper - lower) [sixemspace] for x = lower or x = upper]
41
42 The choice of /x = lower/ or /x = upper/ is made because statistical use of this distribution judged is most likely:
43 the method of maximum likelihood uses this definition.
44
45 There is also a [@http://en.wikipedia.org/wiki/Discrete_uniform_distribution *discrete* uniform distribution].
46
47 Parameters lower and upper can be any finite value.
48
49 The [@http://en.wikipedia.org/wiki/Random_variate random variate]
50 /x/ must also be finite, and is supported /lower <= x <= upper/.
51
52 The lower parameter is also called the
53 [@http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm location parameter],
54 [@http://en.wikipedia.org/wiki/Location_parameter that is where the origin of a plot will lie],
55 and (upper - lower) is also called the [@http://en.wikipedia.org/wiki/Scale_parameter scale parameter].
56
57 The following graph illustrates how the
58 [@http://en.wikipedia.org/wiki/Probability_density_function probability density function PDF]
59 varies with the shape parameter:
60
61 [graph uniform_pdf]
62
63 Likewise for the CDF:
64
65 [graph uniform_cdf]
66
67 [h4 Member Functions]
68
69    uniform_distribution(RealType lower = 0, RealType upper = 1);
70    
71 Constructs a [@http://en.wikipedia.org/wiki/uniform_distribution 
72 uniform distribution] with lower  /lower/ (a) and upper /upper/ (b).
73
74 Requires that the /lower/ and /upper/ parameters are both finite;
75 otherwise if infinity or NaN then calls __domain_error.
76
77    RealType lower()const;
78    
79 Returns the /lower/ parameter of this distribution.
80    
81    RealType upper()const;
82       
83 Returns the /upper/ parameter of this distribution.
84
85 [h4 Non-member Accessors]
86
87 All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
88 that are generic to all distributions are supported: __usual_accessors.
89
90 The domain of the random variable is any finite value,
91 but the supported range is only /lower/ <= x <= /upper/.
92
93 [h4 Accuracy]
94
95 The uniform distribution is implemented with simple arithmetic operators and so should have errors within an epsilon or two.
96
97 [h4 Implementation]
98
99 In the following table a is the /lower/ parameter of the distribution, 
100 b is the /upper/ parameter,
101 /x/ is the random variate, /p/ is the probability and /q = 1-p/.
102
103 [table
104 [[Function][Implementation Notes]]
105 [[pdf][Using the relation: pdf = 0 for x < a, 1 / (b - a) for a <= x <= b, 0 for x > b ]]
106 [[cdf][Using the relation: cdf = 0 for x < a, (x - a) / (b - a) for a <= x <= b, 1 for x > b]]
107 [[cdf complement][Using the relation: q = 1 - p, (b - x) / (b - a) ]]
108 [[quantile][Using the relation: x = p * (b - a) + a; ]]
109 [[quantile from the complement][x = -q * (b - a) + b ]]
110 [[mean][(a + b) / 2 ]]
111 [[variance][(b - a) [super 2] / 12 ]]
112 [[mode][any value in \[a, b\] but a is chosen.  (Would NaN be better?) ]]
113 [[skewness][0]]
114 [[kurtosis excess][-6/5 = -1.2 exactly. (kurtosis - 3)]]
115 [[kurtosis][9/5]]
116 ]
117
118 [h4 References]
119 * [@http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29 Wikpedia continuous uniform distribution]
120 * [@http://mathworld.wolfram.com/UniformDistribution.html Weisstein, Weisstein, Eric W. "Uniform Distribution." From MathWorld--A Wolfram Web Resource.]
121 * [@http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm]
122
123 [endsect] [/section:uniform_dist Uniform]
124
125 [/ 
126   Copyright 2006 John Maddock and Paul A. Bristow.
127   Distributed under the Boost Software License, Version 1.0.
128   (See accompanying file LICENSE_1_0.txt or copy at
129   http://www.boost.org/LICENSE_1_0.txt).
130 ]
131