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