1 [section:students_t_dist Students t Distribution]
3 ``#include <boost/math/distributions/students_t.hpp>``
5 namespace boost{ namespace math{
7 template <class RealType = double,
8 class ``__Policy`` = ``__policy_class`` >
9 class students_t_distribution;
11 typedef students_t_distribution<> students_t;
13 template <class RealType, class ``__Policy``>
14 class students_t_distribution
16 typedef RealType value_type;
17 typedef Policy policy_type;
20 students_t_distribution(const RealType& v);
23 RealType degrees_of_freedom()const;
25 // degrees of freedom estimation:
26 static RealType find_degrees_of_freedom(
27 RealType difference_from_mean,
36 A statistical distribution published by William Gosset in 1908.
37 His employer, Guinness Breweries, required him to publish under a
38 pseudonym (possibly to hide that they were using statistics),
39 so he chose "Student". Given N independent measurements, let
41 [equation students_t_dist]
43 where /M/ is the population mean,[' ''' μ '''] is the sample mean, and /s/ is the
46 Student's t-distribution is defined as the distribution of the random
47 variable t which is - very loosely - the "best" that we can do not
48 knowing the true standard deviation of the sample. It has the PDF:
50 [equation students_t_ref1]
52 The Student's t-distribution takes a single parameter: the number of
53 degrees of freedom of the sample. When the degrees of freedom is
54 /one/ then this distribution is the same as the Cauchy-distribution.
55 As the number of degrees of freedom tends towards infinity, then this
56 distribution approaches the normal-distribution. The following graph
57 illustrates how the PDF varies with the degrees of freedom [nu]:
59 [graph students_t_pdf]
63 students_t_distribution(const RealType& v);
65 Constructs a Student's t-distribution with /v/ degrees of freedom.
67 Requires /v/ > 0, otherwise calls __domain_error. Note that
68 non-integral degrees of freedom are supported,
69 and are meaningful under certain circumstances.
71 RealType degrees_of_freedom()const;
73 Returns the number of degrees of freedom of this distribution.
75 static RealType find_degrees_of_freedom(
76 RealType difference_from_mean,
82 Returns the number of degrees of freedom required to observe a significant
83 result in the Student's t test when the mean differs from the "true"
84 mean by /difference_from_mean/.
87 [[difference_from_mean][The difference between the true mean and the sample mean
88 that we wish to show is significant.]]
89 [[alpha][The maximum acceptable probability of rejecting the null hypothesis
90 when it is in fact true.]]
91 [[beta][The maximum acceptable probability of failing to reject the null hypothesis
92 when it is in fact false.]]
93 [[sd][The sample standard deviation.]]
94 [[hint][A hint for the location to start looking for the result, a good choice for this
95 would be the sample size of a previous borderline Student's t test.]]
99 Remember that for a two-sided test, you must divide alpha by two
100 before calling this function.]
102 For more information on this function see the
103 [@http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm
104 NIST Engineering Statistics Handbook].
106 [h4 Non-member Accessors]
108 All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
109 distributions are supported: __usual_accessors.
111 The domain of the random variable is \[-[infin], +[infin]\].
115 Various [link math_toolkit.stat_tut.weg.st_eg worked examples] are available illustrating the use of the Student's t
120 The normal distribution is implemented in terms of the
121 [link math_toolkit.sf_beta.ibeta_function incomplete beta function]
122 and [link math_toolkit.sf_beta.ibeta_inv_function its inverses],
123 refer to accuracy data on those functions for more information.
127 In the following table /v/ is the degrees of freedom of the distribution,
128 /t/ is the random variate, /p/ is the probability and /q = 1-p/.
131 [[Function][Implementation Notes]]
132 [[pdf][Using the relation: pdf = (v \/ (v + t[super 2]))[super (1+v)\/2 ] / (sqrt(v) * __beta(v\/2, 0.5)) ]]
133 [[cdf][Using the relations:
135 p = 1 - z /iff t > 0/
141 __ibeta(v \/ 2, 0.5, v \/ (v + t[super 2])) \/ 2 ['iff v < 2t[super 2]]
143 __ibetac(0.5, v \/ 2, t[super 2 ] / (v + t[super 2]) \/ 2 /otherwise/]]
144 [[cdf complement][Using the relation: q = cdf(-t) ]]
145 [[quantile][Using the relation: t = sign(p - 0.5) * sqrt(v * y \/ x)
149 x = __ibeta_inv(v \/ 2, 0.5, 2 * min(p, q))
153 The quantities /x/ and /y/ are both returned by __ibeta_inv
154 without the subtraction implied above.]]
155 [[quantile from the complement][Using the relation: t = -quantile(q)]]
158 [[variance][if (v > 2) v \/ (v - 2) else NaN]]
159 [[skewness][if (v > 3) 0 else NaN ]]
160 [[kurtosis][if (v > 4) 3 * (v - 2) \/ (v - 4) else NaN]]
161 [[kurtosis excess][if (v > 4) 6 \/ (df - 4) else NaN]]
164 If the moment index /k/ is less than /v/, then the moment is undefined.
165 Evaluating the moment will throw a __domain_error unless ignored by a policy,
166 when it will return `std::numeric_limits<>::quiet_NaN();`
168 (For simplicity, we have not implemented the return of infinity in some cases
169 as suggested by [@http://en.wikipedia.org/wiki/Student%27s_t-distribution Wikipedia Student's t].
170 See also [@https://svn.boost.org/trac/boost/ticket/7177].)
172 [endsect] [/section:students_t_dist Students t]
175 Copyright 2006, 2012 John Maddock and Paul A. Bristow.
176 Distributed under the Boost Software License, Version 1.0.
177 (See accompanying file LICENSE_1_0.txt or copy at
178 http://www.boost.org/LICENSE_1_0.txt).