File: logistic.qbk

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (110 lines) | stat: -rw-r--r-- 3,736 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
[section:logistic_dist Logistic Distribution]

``#include <boost/math/distributions/logistic.hpp>``

   namespace boost{ namespace math{ 
      
   template <class RealType = double, 
             class ``__Policy``   = ``__policy_class`` >
   class logistic_distribution;

   template <class RealType, class Policy>
   class logistic_distribution
   {
   public:
      typedef RealType value_type;
      typedef Policy   policy_type;
      // Construct:
      BOOST_MATH_GPU_ENABLED logistic_distribution(RealType location = 0, RealType scale = 1);
      // Accessors:
      BOOST_MATH_GPU_ENABLED RealType location()const; // location.
      BOOST_MATH_GPU_ENABLED RealType scale()const; // scale.
      
   };

   typedef logistic_distribution<> logistic;

   }} // namespaces
   
The logistic distribution is a continuous probability distribution. 
It has two parameters - location and scale.  The cumulative distribution 
function of the logistic distribution appears in logistic regression 
and feedforward neural networks. Among other applications, 
United State Chess Federation and FIDE use it to calculate chess ratings.

The following graph shows how the distribution changes as the
parameters change:

[graph logistic_pdf]

[h4 Member Functions]

   BOOST_MATH_GPU_ENABLED logistic_distribution(RealType u = 0, RealType s = 1);

Constructs a logistic distribution with location /u/ and scale /s/.

Requires `scale > 0`, otherwise a __domain_error is raised.

   BOOST_MATH_GPU_ENABLED RealType location()const;   

Returns the location of this distribution.

   BOOST_MATH_GPU_ENABLED RealType scale()const;

Returns the scale of this distribution. 

[h4 Non-member Accessors]

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variable is \[-\[max_value\], +\[min_value\]\]. 
However, the pdf and cdf support inputs of +[infin] and -[infin]
as special cases if RealType permits.

At `p=1` and `p=0`, the quantile function returns the result of 
+__overflow_error and -__overflow_error, while the complement 
quantile function returns the result of -__overflow_error and 
+__overflow_error respectively. 

In this distribution the implementation of `logcdf` is specialized
to improve numerical accuracy.

[h4 Accuracy]

The logistic distribution is implemented in terms of the `std::exp` 
and the `std::log` functions, so its accuracy is related to the 
accurate implementations of those functions on a given platform. 
When calculating the quantile with a non-zero /position/ parameter 
catastrophic cancellation errors can occur: 
in such cases, only a low /absolute error/ can be guaranteed.

[h4 Implementation]

[table
[[Function][Implementation Notes]]
[[pdf][Using the relation: pdf = e[super -(x-u)/s] / (s*(1+e[super -(x-u)/s])[super 2])]]
[[cdf][Using the relation: p = 1/(1+e[super -(x-u)/s])]]
[[logcdf][log(cdf) = -log1p(exp((u-x)/s)) ]]
[[cdf complement][Using the relation: q = 1/(1+e[super (x-u)/s])]]
[[quantile][Using the relation: x = u - s*log(1/p-1)]]
[[quantile from the complement][Using the relation: x = u + s*log(p/1-p)]]
[[mean][u]]
[[mode][The same as the mean.]]
[[skewness][0]]
[[kurtosis excess][6/5]]
[[variance][ ([pi]*s)[super 2] / 3]]
]

[endsect] [/section:logistic_dist Logistic Distribution]


[/ logistic.qbk
  Copyright 2006, 2007 John Maddock and Paul A. Bristow.
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
]