1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Weibull 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.12.0"> 8<link rel="up" href="../dists.html" title="Distributions"> 9<link rel="prev" href="uniform_dist.html" title="Uniform Distribution"> 10<link rel="next" href="../dist_algorithms.html" title="Distribution Algorithms"> 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="uniform_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="../dist_algorithms.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.weibull_dist"></a><a class="link" href="weibull_dist.html" title="Weibull Distribution">Weibull Distribution</a> 28</h4></div></div></div> 29<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">weibull</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre> 30<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> 31 32<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span> 33 <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 21. 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<></a> <span class="special">></span> 34<span class="keyword">class</span> <span class="identifier">weibull_distribution</span><span class="special">;</span> 35 36<span class="keyword">typedef</span> <span class="identifier">weibull_distribution</span><span class="special"><></span> <span class="identifier">weibull</span><span class="special">;</span> 37 38<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 39<span class="keyword">class</span> <span class="identifier">weibull_distribution</span> 40<span class="special">{</span> 41<span class="keyword">public</span><span class="special">:</span> 42 <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span> 43 <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span> 44 <span class="comment">// Construct:</span> 45 <span class="identifier">weibull_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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> 46 <span class="comment">// Accessors:</span> 47 <span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 48 <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 49<span class="special">};</span> 50 51<span class="special">}}</span> <span class="comment">// namespaces</span> 52</pre> 53<p> 54 The <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull 55 distribution</a> is a continuous distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability 56 density function</a>: 57 </p> 58<div class="blockquote"><blockquote class="blockquote"><p> 59 <span class="serif_italic">f(x; α, β) = (α/β) * (x / β)<sup>α - 1</sup> * e<sup>-(x/β)<sup>α</sup></sup></span> 60 </p></blockquote></div> 61<p> 62 For shape parameter <span class="emphasis"><em>α</em></span> > 0, and scale parameter 63 <span class="emphasis"><em>β</em></span> > 0, and <span class="emphasis"><em>x</em></span> > 0. 64 </p> 65<p> 66 The Weibull distribution is often used in the field of failure analysis; 67 in particular it can mimic distributions where the failure rate varies 68 over time. If the failure rate is: 69 </p> 70<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 71<li class="listitem"> 72 constant over time, then <span class="emphasis"><em>α</em></span> = 1, suggests that items 73 are failing from random events. 74 </li> 75<li class="listitem"> 76 decreases over time, then <span class="emphasis"><em>α</em></span> < 1, suggesting 77 "infant mortality". 78 </li> 79<li class="listitem"> 80 increases over time, then <span class="emphasis"><em>α</em></span> > 1, suggesting 81 "wear out" - more likely to fail as time goes by. 82 </li> 83</ul></div> 84<p> 85 The following graph illustrates how the PDF varies with the shape parameter 86 <span class="emphasis"><em>α</em></span>: 87 </p> 88<div class="blockquote"><blockquote class="blockquote"><p> 89 <span class="inlinemediaobject"><img src="../../../../graphs/weibull_pdf1.svg" align="middle"></span> 90 91 </p></blockquote></div> 92<p> 93 While this graph illustrates how the PDF varies with the scale parameter 94 <span class="emphasis"><em>β</em></span>: 95 </p> 96<div class="blockquote"><blockquote class="blockquote"><p> 97 <span class="inlinemediaobject"><img src="../../../../graphs/weibull_pdf2.svg" align="middle"></span> 98 99 </p></blockquote></div> 100<h5> 101<a name="math_toolkit.dist_ref.dists.weibull_dist.h0"></a> 102 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.related_distributions"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.related_distributions">Related 103 distributions</a> 104 </h5> 105<p> 106 When <span class="emphasis"><em>α</em></span> = 3, the <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull 107 distribution</a> appears similar to the <a href="http://en.wikipedia.org/wiki/Normal_distribution" target="_top">normal 108 distribution</a>. When <span class="emphasis"><em>α</em></span> = 1, the Weibull distribution 109 reduces to the <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">exponential 110 distribution</a>. The relationship of the types of extreme value distributions, 111 of which the Weibull is but one, is discussed by <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme 112 Value Distributions, Theory and Applications Samuel Kotz & Saralees 113 Nadarajah</a>. 114 </p> 115<h5> 116<a name="math_toolkit.dist_ref.dists.weibull_dist.h1"></a> 117 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.member_functions"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.member_functions">Member 118 Functions</a> 119 </h5> 120<pre class="programlisting"><span class="identifier">weibull_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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> 121</pre> 122<p> 123 Constructs a <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull 124 distribution</a> with shape <span class="emphasis"><em>shape</em></span> and scale <span class="emphasis"><em>scale</em></span>. 125 </p> 126<p> 127 Requires that the <span class="emphasis"><em>shape</em></span> and <span class="emphasis"><em>scale</em></span> 128 parameters are both greater than zero, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. 129 </p> 130<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 131</pre> 132<p> 133 Returns the <span class="emphasis"><em>shape</em></span> parameter of this distribution. 134 </p> 135<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> 136</pre> 137<p> 138 Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution. 139 </p> 140<h5> 141<a name="math_toolkit.dist_ref.dists.weibull_dist.h2"></a> 142 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.non_member_accessors"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.non_member_accessors">Non-member 143 Accessors</a> 144 </h5> 145<p> 146 All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor 147 functions</a> that are generic to all distributions are supported: 148 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>, 149 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>, 150 <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>, 151 <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>, 152 <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>, 153 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>, 154 <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>, 155 <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>. 156 </p> 157<p> 158 The domain of the random variable is [0, ∞]. 159 </p> 160<h5> 161<a name="math_toolkit.dist_ref.dists.weibull_dist.h3"></a> 162 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.accuracy"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.accuracy">Accuracy</a> 163 </h5> 164<p> 165 The Weibull distribution is implemented in terms of the standard library 166 <code class="computeroutput"><span class="identifier">log</span></code> and <code class="computeroutput"><span class="identifier">exp</span></code> 167 functions plus <a class="link" href="../../powers/expm1.html" title="expm1">expm1</a> and 168 <a class="link" href="../../powers/log1p.html" title="log1p">log1p</a> and as such should 169 have very low error rates. 170 </p> 171<h5> 172<a name="math_toolkit.dist_ref.dists.weibull_dist.h4"></a> 173 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.implementation"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.implementation">Implementation</a> 174 </h5> 175<p> 176 In the following table <span class="emphasis"><em>α</em></span> is the shape parameter of 177 the distribution, <span class="emphasis"><em>β</em></span> is its scale parameter, <span class="emphasis"><em>x</em></span> 178 is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q 179 = 1-p</em></span>. 180 </p> 181<div class="informaltable"><table class="table"> 182<colgroup> 183<col> 184<col> 185</colgroup> 186<thead><tr> 187<th> 188 <p> 189 Function 190 </p> 191 </th> 192<th> 193 <p> 194 Implementation Notes 195 </p> 196 </th> 197</tr></thead> 198<tbody> 199<tr> 200<td> 201 <p> 202 pdf 203 </p> 204 </td> 205<td> 206 <p> 207 Using the relation: pdf = αβ<sup>-α </sup>x<sup>α - 1</sup> e<sup>-(x/beta)<sup>alpha</sup></sup> 208 </p> 209 </td> 210</tr> 211<tr> 212<td> 213 <p> 214 cdf 215 </p> 216 </td> 217<td> 218 <p> 219 Using the relation: p = -<a class="link" href="../../powers/expm1.html" title="expm1">expm1</a>(-(x/β)<sup>α</sup>) 220 </p> 221 </td> 222</tr> 223<tr> 224<td> 225 <p> 226 cdf complement 227 </p> 228 </td> 229<td> 230 <p> 231 Using the relation: q = e<sup>-(x/β)<sup>α</sup></sup> 232 </p> 233 </td> 234</tr> 235<tr> 236<td> 237 <p> 238 quantile 239 </p> 240 </td> 241<td> 242 <p> 243 Using the relation: x = β * (-<a class="link" href="../../powers/log1p.html" title="log1p">log1p</a>(-p))<sup>1/α</sup> 244 </p> 245 </td> 246</tr> 247<tr> 248<td> 249 <p> 250 quantile from the complement 251 </p> 252 </td> 253<td> 254 <p> 255 Using the relation: x = β * (-log(q))<sup>1/α</sup> 256 </p> 257 </td> 258</tr> 259<tr> 260<td> 261 <p> 262 mean 263 </p> 264 </td> 265<td> 266 <p> 267 β * Γ(1 + 1/α) 268 </p> 269 </td> 270</tr> 271<tr> 272<td> 273 <p> 274 variance 275 </p> 276 </td> 277<td> 278 <p> 279 β<sup>2</sup>(Γ(1 + 2/α) - Γ<sup>2</sup>(1 + 1/α)) 280 </p> 281 </td> 282</tr> 283<tr> 284<td> 285 <p> 286 mode 287 </p> 288 </td> 289<td> 290 <p> 291 β((α - 1) / α)<sup>1/α</sup> 292 </p> 293 </td> 294</tr> 295<tr> 296<td> 297 <p> 298 skewness 299 </p> 300 </td> 301<td> 302 <p> 303 Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein, 304 Eric W. "Weibull Distribution." From MathWorld--A Wolfram 305 Web Resource.</a> 306 </p> 307 </td> 308</tr> 309<tr> 310<td> 311 <p> 312 kurtosis 313 </p> 314 </td> 315<td> 316 <p> 317 Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein, 318 Eric W. "Weibull Distribution." From MathWorld--A Wolfram 319 Web Resource.</a> 320 </p> 321 </td> 322</tr> 323<tr> 324<td> 325 <p> 326 kurtosis excess 327 </p> 328 </td> 329<td> 330 <p> 331 Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein, 332 Eric W. "Weibull Distribution." From MathWorld--A Wolfram 333 Web Resource.</a> 334 </p> 335 </td> 336</tr> 337</tbody> 338</table></div> 339<h5> 340<a name="math_toolkit.dist_ref.dists.weibull_dist.h5"></a> 341 <span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.references"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.references">References</a> 342 </h5> 343<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 344<li class="listitem"> 345 <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">http://en.wikipedia.org/wiki/Weibull_distribution</a> 346 </li> 347<li class="listitem"> 348 <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein, 349 Eric W. "Weibull Distribution." From MathWorld--A Wolfram 350 Web Resource.</a> 351 </li> 352<li class="listitem"> 353 <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3668.htm" target="_top">Weibull 354 in NIST Exploratory Data Analysis</a> 355 </li> 356</ul></div> 357</div> 358<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 359<td align="left"></td> 360<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 361 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 362 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 363 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 364 Daryle Walker and Xiaogang Zhang<p> 365 Distributed under the Boost Software License, Version 1.0. (See accompanying 366 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>) 367 </p> 368</div></td> 369</tr></table> 370<hr> 371<div class="spirit-nav"> 372<a accesskey="p" href="uniform_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="../dist_algorithms.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 373</div> 374</body> 375</html> 376