logistic.qbk 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. [section:logistic_dist Logistic Distribution]
  2. ``#include <boost/math/distributions/logistic.hpp>``
  3. namespace boost{ namespace math{
  4. template <class RealType = double,
  5. class ``__Policy`` = ``__policy_class`` >
  6. class logistic_distribution;
  7. template <class RealType, class Policy>
  8. class logistic_distribution
  9. {
  10. public:
  11. typedef RealType value_type;
  12. typedef Policy policy_type;
  13. // Construct:
  14. logistic_distribution(RealType location = 0, RealType scale = 1);
  15. // Accessors:
  16. RealType location()const; // location.
  17. RealType scale()const; // scale.
  18. };
  19. typedef logistic_distribution<> logistic;
  20. }} // namespaces
  21. The logistic distribution is a continous probability distribution.
  22. It has two parameters - location and scale. The cumulative distribution
  23. function of the logistic distribution appears in logistic regression
  24. and feedforward neural networks. Among other applications,
  25. United State Chess Federation and FIDE use it to calculate chess ratings.
  26. The following graph shows how the distribution changes as the
  27. parameters change:
  28. [graph logistic_pdf]
  29. [h4 Member Functions]
  30. logistic_distribution(RealType u = 0, RealType s = 1);
  31. Constructs a logistic distribution with location /u/ and scale /s/.
  32. Requires `scale > 0`, otherwise a __domain_error is raised.
  33. RealType location()const;
  34. Returns the location of this distribution.
  35. RealType scale()const;
  36. Returns the scale of this distribution.
  37. [h4 Non-member Accessors]
  38. All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
  39. that are generic to all distributions are supported: __usual_accessors.
  40. The domain of the random variable is \[-\[max_value\], +\[min_value\]\].
  41. However, the pdf and cdf support inputs of +[infin] and -[infin]
  42. as special cases if RealType permits.
  43. At `p=1` and `p=0`, the quantile function returns the result of
  44. +__overflow_error and -__overflow_error, while the complement
  45. quantile function returns the result of -__overflow_error and
  46. +__overflow_error respectively.
  47. [h4 Accuracy]
  48. The logistic distribution is implemented in terms of the `std::exp`
  49. and the `std::log` functions, so its accuracy is related to the
  50. accurate implementations of those functions on a given platform.
  51. When calculating the quantile with a non-zero /position/ parameter
  52. catastrophic cancellation errors can occur:
  53. in such cases, only a low /absolute error/ can be guaranteed.
  54. [h4 Implementation]
  55. [table
  56. [[Function][Implementation Notes]]
  57. [[pdf][Using the relation: pdf = e[super -(x-u)/s] / (s*(1+e[super -(x-u)/s])[super 2])]]
  58. [[cdf][Using the relation: p = 1/(1+e[super -(x-u)/s])]]
  59. [[cdf complement][Using the relation: q = 1/(1+e[super (x-u)/s])]]
  60. [[quantile][Using the relation: x = u - s*log(1/p-1)]]
  61. [[quantile from the complement][Using the relation: x = u + s*log(p/1-p)]]
  62. [[mean][u]]
  63. [[mode][The same as the mean.]]
  64. [[skewness][0]]
  65. [[kurtosis excess][6/5]]
  66. [[variance][ ([pi]*s)[super 2] / 3]]
  67. ]
  68. [endsect] [/section:logistic_dist Logistic Distribution]
  69. [/ logistic.qbk
  70. Copyright 2006, 2007 John Maddock and Paul A. Bristow.
  71. Distributed under the Boost Software License, Version 1.0.
  72. (See accompanying file LICENSE_1_0.txt or copy at
  73. http://www.boost.org/LICENSE_1_0.txt).
  74. ]