Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / dist_ref / dists / logistic_dist.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Logistic Distribution</title>
5 <link rel="stylesheet" href="../../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../dists.html" title="Distributions">
9 <link rel="prev" href="laplace_dist.html" title="Laplace Distribution">
10 <link rel="next" href="lognormal_dist.html" title="Log Normal Distribution">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="laplace_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lognormal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="math_toolkit.dist_ref.dists.logistic_dist"></a><a class="link" href="logistic_dist.html" title="Logistic Distribution">Logistic
28         Distribution</a>
29 </h4></div></div></div>
30 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">logistic</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></pre>
31 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
32
33 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
34           <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>   <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
35 <span class="keyword">class</span> <span class="identifier">logistic_distribution</span><span class="special">;</span>
36
37 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
38 <span class="keyword">class</span> <span class="identifier">logistic_distribution</span>
39 <span class="special">{</span>
40 <span class="keyword">public</span><span class="special">:</span>
41    <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
42    <span class="keyword">typedef</span> <span class="identifier">Policy</span>   <span class="identifier">policy_type</span><span class="special">;</span>
43    <span class="comment">// Construct:</span>
44    <span class="identifier">logistic_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
45    <span class="comment">// Accessors:</span>
46    <span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// location.</span>
47    <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// scale.</span>
48
49 <span class="special">};</span>
50
51 <span class="keyword">typedef</span> <span class="identifier">logistic_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">logistic</span><span class="special">;</span>
52
53 <span class="special">}}</span> <span class="comment">// namespaces</span>
54 </pre>
55 <p>
56           The logistic distribution is a continous probability distribution. It has
57           two parameters - location and scale. The cumulative distribution function
58           of the logistic distribution appears in logistic regression and feedforward
59           neural networks. Among other applications, United State Chess Federation
60           and FIDE use it to calculate chess ratings.
61         </p>
62 <p>
63           The following graph shows how the distribution changes as the parameters
64           change:
65         </p>
66 <div class="blockquote"><blockquote class="blockquote"><p>
67             <span class="inlinemediaobject"><img src="../../../../graphs/logistic_pdf.svg" align="middle"></span>
68
69           </p></blockquote></div>
70 <h5>
71 <a name="math_toolkit.dist_ref.dists.logistic_dist.h0"></a>
72           <span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.member_functions"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.member_functions">Member
73           Functions</a>
74         </h5>
75 <pre class="programlisting"><span class="identifier">logistic_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">u</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">s</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
76 </pre>
77 <p>
78           Constructs a logistic distribution with location <span class="emphasis"><em>u</em></span>
79           and scale <span class="emphasis"><em>s</em></span>.
80         </p>
81 <p>
82           Requires <code class="computeroutput"><span class="identifier">scale</span> <span class="special">&gt;</span>
83           <span class="number">0</span></code>, otherwise a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
84           is raised.
85         </p>
86 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
87 </pre>
88 <p>
89           Returns the location of this distribution.
90         </p>
91 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
92 </pre>
93 <p>
94           Returns the scale of this distribution.
95         </p>
96 <h5>
97 <a name="math_toolkit.dist_ref.dists.logistic_dist.h1"></a>
98           <span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.non_member_accessors"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.non_member_accessors">Non-member
99           Accessors</a>
100         </h5>
101 <p>
102           All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
103           functions</a> that are generic to all distributions are supported:
104           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
105           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
106           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
107           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
108           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
109           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
110           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
111           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
112         </p>
113 <p>
114           The domain of the random variable is [-[max_value], +[min_value]]. However,
115           the pdf and cdf support inputs of +&#8734; and -&#8734;
116 as special cases if RealType permits.
117         </p>
118 <p>
119           At <code class="computeroutput"><span class="identifier">p</span><span class="special">=</span><span class="number">1</span></code> and <code class="computeroutput"><span class="identifier">p</span><span class="special">=</span><span class="number">0</span></code>, the quantile
120           function returns the result of +<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
121           and -<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>,
122           while the complement quantile function returns the result of -<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
123           and +<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
124           respectively.
125         </p>
126 <h5>
127 <a name="math_toolkit.dist_ref.dists.logistic_dist.h2"></a>
128           <span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.accuracy"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.accuracy">Accuracy</a>
129         </h5>
130 <p>
131           The logistic distribution is implemented in terms of the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span></code> and the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">log</span></code>
132           functions, so its accuracy is related to the accurate implementations of
133           those functions on a given platform. When calculating the quantile with
134           a non-zero <span class="emphasis"><em>position</em></span> parameter catastrophic cancellation
135           errors can occur: in such cases, only a low <span class="emphasis"><em>absolute error</em></span>
136           can be guaranteed.
137         </p>
138 <h5>
139 <a name="math_toolkit.dist_ref.dists.logistic_dist.h3"></a>
140           <span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.implementation"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.implementation">Implementation</a>
141         </h5>
142 <div class="informaltable"><table class="table">
143 <colgroup>
144 <col>
145 <col>
146 </colgroup>
147 <thead><tr>
148 <th>
149                   <p>
150                     Function
151                   </p>
152                 </th>
153 <th>
154                   <p>
155                     Implementation Notes
156                   </p>
157                 </th>
158 </tr></thead>
159 <tbody>
160 <tr>
161 <td>
162                   <p>
163                     pdf
164                   </p>
165                 </td>
166 <td>
167                   <p>
168                     Using the relation: pdf = e<sup>-(x-u)/s</sup> / (s*(1+e<sup>-(x-u)/s</sup>)<sup>2</sup>)
169                   </p>
170                 </td>
171 </tr>
172 <tr>
173 <td>
174                   <p>
175                     cdf
176                   </p>
177                 </td>
178 <td>
179                   <p>
180                     Using the relation: p = 1/(1+e<sup>-(x-u)/s</sup>)
181                   </p>
182                 </td>
183 </tr>
184 <tr>
185 <td>
186                   <p>
187                     cdf complement
188                   </p>
189                 </td>
190 <td>
191                   <p>
192                     Using the relation: q = 1/(1+e<sup>(x-u)/s</sup>)
193                   </p>
194                 </td>
195 </tr>
196 <tr>
197 <td>
198                   <p>
199                     quantile
200                   </p>
201                 </td>
202 <td>
203                   <p>
204                     Using the relation: x = u - s*log(1/p-1)
205                   </p>
206                 </td>
207 </tr>
208 <tr>
209 <td>
210                   <p>
211                     quantile from the complement
212                   </p>
213                 </td>
214 <td>
215                   <p>
216                     Using the relation: x = u + s*log(p/1-p)
217                   </p>
218                 </td>
219 </tr>
220 <tr>
221 <td>
222                   <p>
223                     mean
224                   </p>
225                 </td>
226 <td>
227                   <p>
228                     u
229                   </p>
230                 </td>
231 </tr>
232 <tr>
233 <td>
234                   <p>
235                     mode
236                   </p>
237                 </td>
238 <td>
239                   <p>
240                     The same as the mean.
241                   </p>
242                 </td>
243 </tr>
244 <tr>
245 <td>
246                   <p>
247                     skewness
248                   </p>
249                 </td>
250 <td>
251                   <p>
252                     0
253                   </p>
254                 </td>
255 </tr>
256 <tr>
257 <td>
258                   <p>
259                     kurtosis excess
260                   </p>
261                 </td>
262 <td>
263                   <p>
264                     6/5
265                   </p>
266                 </td>
267 </tr>
268 <tr>
269 <td>
270                   <p>
271                     variance
272                   </p>
273                 </td>
274 <td>
275                   <p>
276                     (&#960;*s)<sup>2</sup> / 3
277                   </p>
278                 </td>
279 </tr>
280 </tbody>
281 </table></div>
282 </div>
283 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
284 <td align="left"></td>
285 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
286       Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
287       Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
288       R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
289       Daryle Walker and Xiaogang Zhang<p>
290         Distributed under the Boost Software License, Version 1.0. (See accompanying
291         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
292       </p>
293 </div></td>
294 </tr></table>
295 <hr>
296 <div class="spirit-nav">
297 <a accesskey="p" href="laplace_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lognormal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
298 </div>
299 </body>
300 </html>