non_members.qbk 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. [section:nmp Non-Member Properties]
  2. Properties that are common to all distributions are accessed via non-member
  3. getter functions: non-membership allows more of these functions to be added over time,
  4. as the need arises. Unfortunately the literature uses many different and
  5. confusing names to refer to a rather small number of actual concepts; refer
  6. to the [link math_toolkit.dist_ref.nmp.concept_index concept index] to find the property you
  7. want by the name you are most familiar with.
  8. Or use the [link math_toolkit.dist_ref.nmp.function_index function index]
  9. to go straight to the function you want if you already know its name.
  10. [h4:function_index Function Index]
  11. * __cdf.
  12. * __ccdf.
  13. * __chf.
  14. * __hazard.
  15. * __kurtosis.
  16. * __kurtosis_excess
  17. * __mean.
  18. * __median.
  19. * __mode.
  20. * __pdf.
  21. * __range.
  22. * __quantile.
  23. * __quantile_c.
  24. * __skewness.
  25. * __sd.
  26. * __support.
  27. * __variance.
  28. [h4:concept_index Conceptual Index]
  29. * __ccdf.
  30. * __cdf.
  31. * __chf.
  32. * [link math_toolkit.dist_ref.nmp.cdf_inv Inverse Cumulative Distribution Function].
  33. * [link math_toolkit.dist_ref.nmp.survival_inv Inverse Survival Function].
  34. * __hazard
  35. * [link math_toolkit.dist_ref.nmp.lower_critical Lower Critical Value].
  36. * __kurtosis.
  37. * __kurtosis_excess
  38. * __mean.
  39. * __median.
  40. * __mode.
  41. * [link math_toolkit.dist_ref.nmp.cdfPQ P].
  42. * [link math_toolkit.dist_ref.nmp.percent Percent Point Function].
  43. * __pdf.
  44. * [link math_toolkit.dist_ref.nmp.pmf Probability Mass Function].
  45. * __range.
  46. * [link math_toolkit.dist_ref.nmp.cdfPQ Q].
  47. * __quantile.
  48. * [link math_toolkit.dist_ref.nmp.quantile_c Quantile from the complement of the probability].
  49. * __skewness.
  50. * __sd
  51. * [link math_toolkit.dist_ref.nmp.survival Survival Function].
  52. * [link math_toolkit.dist_ref.nmp.support support].
  53. * [link math_toolkit.dist_ref.nmp.upper_critical Upper Critical Value].
  54. * __variance.
  55. [h4:cdf Cumulative Distribution Function]
  56. template <class RealType, class ``__Policy``>
  57. RealType cdf(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist, const RealType& x);
  58. The __cdf is the probability that
  59. the variable takes a value less than or equal to x. It is equivalent
  60. to the integral from -infinity to x of the __pdf.
  61. This function may return a __domain_error if the random variable is outside
  62. the defined range for the distribution.
  63. For example, the following graph shows the cdf for the
  64. normal distribution:
  65. [$../graphs/cdf.png]
  66. [h4:ccdf Complement of the Cumulative Distribution Function]
  67. template <class Distribution, class RealType>
  68. RealType cdf(const ``['Unspecified-Complement-Type]``<Distribution, RealType>& comp);
  69. The complement of the __cdf
  70. is the probability that
  71. the variable takes a value greater than x. It is equivalent
  72. to the integral from x to infinity of the __pdf, or 1 minus the __cdf of x.
  73. This is also known as the survival function.
  74. This function may return a __domain_error if the random variable is outside
  75. the defined range for the distribution.
  76. In this library, it is obtained by wrapping the arguments to the `cdf`
  77. function in a call to `complement`, for example:
  78. // standard normal distribution object:
  79. boost::math::normal norm;
  80. // print survival function for x=2.0:
  81. std::cout << cdf(complement(norm, 2.0)) << std::endl;
  82. For example, the following graph shows the __complement of the cdf for the
  83. normal distribution:
  84. [$../graphs/survival.png]
  85. See __why_complements for why the complement is useful and when it should be used.
  86. [h4:hazard Hazard Function]
  87. template <class RealType, class ``__Policy``>
  88. RealType hazard(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist, const RealType& x);
  89. Returns the __hazard of /x/ and distibution /dist/.
  90. This function may return a __domain_error if the random variable is outside
  91. the defined range for the distribution.
  92. [equation hazard]
  93. [caution
  94. Some authors refer to this as the conditional failure
  95. density function rather than the hazard function.]
  96. [h4:chf Cumulative Hazard Function]
  97. template <class RealType, class ``__Policy``>
  98. RealType chf(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist, const RealType& x);
  99. Returns the __chf of /x/ and distibution /dist/.
  100. This function may return a __domain_error if the random variable is outside
  101. the defined range for the distribution.
  102. [equation chf]
  103. [caution
  104. Some authors refer to this as simply the "Hazard Function".]
  105. [h4:mean mean]
  106. template<class RealType, class ``__Policy``>
  107. RealType mean(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  108. Returns the mean of the distribution /dist/.
  109. This function may return a __domain_error if the distribution does not have
  110. a defined mean (for example the Cauchy distribution).
  111. [h4:median median]
  112. template<class RealType, class ``__Policy``>
  113. RealType median(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  114. Returns the median of the distribution /dist/.
  115. [h4:mode mode]
  116. template<class RealType, ``__Policy``>
  117. RealType mode(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  118. Returns the mode of the distribution /dist/.
  119. This function may return a __domain_error if the distribution does not have
  120. a defined mode.
  121. [h4:pdf Probability Density Function]
  122. template <class RealType, class ``__Policy``>
  123. RealType pdf(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist, const RealType& x);
  124. For a continuous function, the probability density function (pdf) returns
  125. the probability that the variate has the value x.
  126. Since for continuous distributions the probability at a single point is actually zero,
  127. the probability is better expressed as the integral of the pdf between two points:
  128. see the __cdf.
  129. For a discrete distribution, the pdf is the probability that the
  130. variate takes the value x.
  131. This function may return a __domain_error if the random variable is outside
  132. the defined range for the distribution.
  133. For example, for a standard normal distribution the pdf looks like this:
  134. [$../graphs/pdf.png]
  135. [h4:range Range]
  136. template<class RealType, class ``__Policy``>
  137. std::pair<RealType, RealType> range(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  138. Returns the valid range of the random variable over distribution /dist/.
  139. [h4:quantile Quantile]
  140. template <class RealType, class ``__Policy``>
  141. RealType quantile(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist, const RealType& p);
  142. The quantile is best viewed as the inverse of the __cdf, it returns
  143. a value /x/ such that `cdf(dist, x) == p`.
  144. This is also known as the /percent point function/, or /percentile/, or /fractile/,
  145. it is also the same as calculating the ['lower critical value] of a distribution.
  146. This function returns a __domain_error if the probability lies outside [0,1].
  147. The function may return an __overflow_error if there is no finite value
  148. that has the specified probability.
  149. The following graph shows the quantile function for a standard normal
  150. distribution:
  151. [$../graphs/quantile.png]
  152. [h4:quantile_c Quantile from the complement of the probability.]
  153. See also [link math_toolkit.stat_tut.overview.complements complements].
  154. template <class Distribution, class RealType>
  155. RealType quantile(const ``['Unspecified-Complement-Type]``<Distribution, RealType>& comp);
  156. This is the inverse of the __ccdf. It is calculated by wrapping
  157. the arguments in a call to the quantile function in a call to
  158. /complement/. For example:
  159. // define a standard normal distribution:
  160. boost::math::normal norm;
  161. // print the value of x for which the complement
  162. // of the probability is 0.05:
  163. std::cout << quantile(complement(norm, 0.05)) << std::endl;
  164. The function computes a value /x/ such that
  165. `cdf(complement(dist, x)) == q` where /q/ is complement of the
  166. probability.
  167. [link why_complements Why complements?]
  168. This function is also called the inverse survival function, and is the
  169. same as calculating the ['upper critical value] of a distribution.
  170. This function returns a __domain_error if the probablity lies outside [0,1].
  171. The function may return an __overflow_error if there is no finite value
  172. that has the specified probability.
  173. The following graph show the inverse survival function for the normal
  174. distribution:
  175. [$../graphs/survival_inv.png]
  176. [h4:sd Standard Deviation]
  177. template <class RealType, class ``__Policy``>
  178. RealType standard_deviation(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  179. Returns the standard deviation of distribution /dist/.
  180. This function may return a __domain_error if the distribution does not have
  181. a defined standard deviation.
  182. [h4:support support]
  183. template<class RealType, class ``__Policy``>
  184. std::pair<RealType, RealType> support(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  185. Returns the supported range of random variable over the distribution /dist/.
  186. The distribution is said to be 'supported' over a range that is
  187. [@http://en.wikipedia.org/wiki/Probability_distribution
  188. "the smallest closed set whose complement has probability zero"].
  189. Non-mathematicians might say it means the 'interesting' smallest range
  190. of random variate x that has the cdf going from zero to unity.
  191. Outside are uninteresting zones where the pdf is zero, and the cdf zero or unity.
  192. [h4:variance Variance]
  193. template <class RealType, class ``__Policy``>
  194. RealType variance(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  195. Returns the variance of the distribution /dist/.
  196. This function may return a __domain_error if the distribution does not have
  197. a defined variance.
  198. [h4:skewness Skewness]
  199. template <class RealType, class ``__Policy``>
  200. RealType skewness(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  201. Returns the skewness of the distribution /dist/.
  202. This function may return a __domain_error if the distribution does not have
  203. a defined skewness.
  204. [h4:kurtosis Kurtosis]
  205. template <class RealType, class ``__Policy``>
  206. RealType kurtosis(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  207. Returns the 'proper' kurtosis (normalized fourth moment) of the distribution /dist/.
  208. kertosis = [beta][sub 2]= [mu][sub 4] / [mu][sub 2][super 2]
  209. Where [mu][sub i] is the i'th central moment of the distribution, and
  210. in particular [mu][sub 2] is the variance of the distribution.
  211. The kurtosis is a measure of the "peakedness" of a distribution.
  212. Note that the literature definition of kurtosis is confusing.
  213. The definition used here is that used by for example
  214. [@http://mathworld.wolfram.com/Kurtosis.html Wolfram MathWorld]
  215. (that includes a table of formulae for kurtosis excess for various distributions)
  216. but NOT the definition of
  217. [@http://en.wikipedia.org/wiki/Kurtosis kurtosis used by Wikipedia]
  218. which treats "kurtosis" and "kurtosis excess" as the same quantity.
  219. kurtosis_excess = 'proper' kurtosis - 3
  220. This subtraction of 3 is convenient so that the ['kurtosis excess]
  221. of a normal distribution is zero.
  222. This function may return a __domain_error if the distribution does not have
  223. a defined kurtosis.
  224. 'Proper' kurtosis can have a value from zero to + infinity.
  225. [h4:kurtosis_excess Kurtosis excess]
  226. template <class RealType, ``__Policy``>
  227. RealType kurtosis_excess(const ``['Distribution-Type]``<RealType, ``__Policy``>& dist);
  228. Returns the kurtosis excess of the distribution /dist/.
  229. kurtosis excess = [gamma][sub 2]= [mu][sub 4] / [mu][sub 2][super 2]- 3 = kurtosis - 3
  230. Where [mu][sub i] is the i'th central moment of the distribution, and
  231. in particular [mu][sub 2] is the variance of the distribution.
  232. The kurtosis excess is a measure of the "peakedness" of a distribution, and
  233. is more widely used than the "kurtosis proper". It is defined so that
  234. the kurtosis excess of a normal distribution is zero.
  235. This function may return a __domain_error if the distribution does not have
  236. a defined kurtosis excess.
  237. Kurtosis excess can have a value from -2 to + infinity.
  238. kurtosis = kurtosis_excess +3;
  239. The kurtosis excess of a normal distribution is zero.
  240. [h4:cdfPQ P and Q]
  241. The terms P and Q are sometimes used to refer to the __cdf
  242. and its [link math_toolkit.dist_ref.nmp.ccdf complement] respectively.
  243. Lowercase p and q are sometimes used to refer to the values returned
  244. by these functions.
  245. [h4:percent Percent Point Function or Percentile]
  246. The percent point function, also known as the percentile, is the same as
  247. the __quantile.
  248. [h4:cdf_inv Inverse CDF Function.]
  249. The inverse of the cumulative distribution function, is the same as the
  250. __quantile.
  251. [h4:survival_inv Inverse Survival Function.]
  252. The inverse of the survival function, is the same as computing the
  253. [link math_toolkit.dist_ref.nmp.quantile_c quantile
  254. from the complement of the probability].
  255. [h4:pmf Probability Mass Function]
  256. The Probability Mass Function is the same as the __pdf.
  257. The term Mass Function is usually applied to discrete distributions,
  258. while the term __pdf applies to continuous distributions.
  259. [h4:lower_critical Lower Critical Value.]
  260. The lower critical value calculates the value of the random variable
  261. given the area under the left tail of the distribution.
  262. It is equivalent to calculating the __quantile.
  263. [h4:upper_critical Upper Critical Value.]
  264. The upper critical value calculates the value of the random variable
  265. given the area under the right tail of the distribution. It is equivalent to
  266. calculating the [link math_toolkit.dist_ref.nmp.quantile_c quantile from the complement of the
  267. probability].
  268. [h4:survival Survival Function]
  269. Refer to the __ccdf.
  270. [endsect] [/section:nmp Non-Member Properties]
  271. [/ non_members.qbk
  272. Copyright 2006 John Maddock and Paul A. Bristow.
  273. Distributed under the Boost Software License, Version 1.0.
  274. (See accompanying file LICENSE_1_0.txt or copy at
  275. http://www.boost.org/LICENSE_1_0.txt).
  276. ]