weibull.qbk 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [section:weibull_dist Weibull Distribution]
  2. ``#include <boost/math/distributions/weibull.hpp>``
  3. namespace boost{ namespace math{
  4. template <class RealType = double,
  5. class ``__Policy`` = ``__policy_class`` >
  6. class weibull_distribution;
  7. typedef weibull_distribution<> weibull;
  8. template <class RealType, class ``__Policy``>
  9. class weibull_distribution
  10. {
  11. public:
  12. typedef RealType value_type;
  13. typedef Policy policy_type;
  14. // Construct:
  15. weibull_distribution(RealType shape, RealType scale = 1)
  16. // Accessors:
  17. RealType shape()const;
  18. RealType scale()const;
  19. };
  20. }} // namespaces
  21. The [@http://en.wikipedia.org/wiki/Weibull_distribution Weibull distribution]
  22. is a continuous distribution
  23. with the
  24. [@http://en.wikipedia.org/wiki/Probability_density_function probability density function]:
  25. [expression f(x; [alpha], [beta]) = ([alpha]\/[beta]) * (x \/ [beta])[super [alpha] - 1] * e[super -(x\/[beta])[super [alpha]]]]
  26. For shape parameter ['[alpha]] > 0, and scale parameter ['[beta]] > 0, and /x/ > 0.
  27. The Weibull distribution is often used in the field of failure analysis;
  28. in particular it can mimic distributions where the failure rate varies over time.
  29. If the failure rate is:
  30. * constant over time, then ['[alpha]] = 1, suggests that items are failing from random events.
  31. * decreases over time, then ['[alpha]] < 1, suggesting "infant mortality".
  32. * increases over time, then ['[alpha]] > 1, suggesting "wear out" - more likely to fail as time goes by.
  33. The following graph illustrates how the PDF varies with the shape parameter ['[alpha]]:
  34. [graph weibull_pdf1]
  35. While this graph illustrates how the PDF varies with the scale parameter ['[beta]]:
  36. [graph weibull_pdf2]
  37. [h4 Related distributions]
  38. When ['[alpha]] = 3, the
  39. [@http://en.wikipedia.org/wiki/Weibull_distribution Weibull distribution] appears similar to the
  40. [@http://en.wikipedia.org/wiki/Normal_distribution normal distribution].
  41. When ['[alpha]] = 1, the Weibull distribution reduces to the
  42. [@http://en.wikipedia.org/wiki/Exponential_distribution exponential distribution].
  43. The relationship of the types of extreme value distributions, of which the Weibull is but one, is
  44. discussed by
  45. [@http://www.worldscibooks.com/mathematics/p191.html Extreme Value Distributions, Theory and Applications
  46. Samuel Kotz & Saralees Nadarajah].
  47. [h4 Member Functions]
  48. weibull_distribution(RealType shape, RealType scale = 1);
  49. Constructs a [@http://en.wikipedia.org/wiki/Weibull_distribution
  50. Weibull distribution] with shape /shape/ and scale /scale/.
  51. Requires that the /shape/ and /scale/ parameters are both greater than zero,
  52. otherwise calls __domain_error.
  53. RealType shape()const;
  54. Returns the /shape/ parameter of this distribution.
  55. RealType scale()const;
  56. Returns the /scale/ parameter of this distribution.
  57. [h4 Non-member Accessors]
  58. All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
  59. distributions are supported: __usual_accessors.
  60. The domain of the random variable is \[0, [infin]\].
  61. [h4 Accuracy]
  62. The Weibull distribution is implemented in terms of the
  63. standard library `log` and `exp` functions plus __expm1 and __log1p
  64. and as such should have very low error rates.
  65. [h4 Implementation]
  66. In the following table ['[alpha]] is the shape parameter of the distribution,
  67. ['[beta]] is its scale parameter, /x/ is the random variate, /p/ is the probability
  68. and /q = 1-p/.
  69. [table
  70. [[Function][Implementation Notes]]
  71. [[pdf][Using the relation: pdf = [alpha][beta][super -[alpha] ]x[super [alpha] - 1] e[super -(x/beta)[super alpha]] ]]
  72. [[cdf][Using the relation: p = -__expm1(-(x\/[beta])[super [alpha]]) ]]
  73. [[cdf complement][Using the relation: q = e[super -(x\/[beta])[super [alpha]]] ]]
  74. [[quantile][Using the relation: x = [beta] * (-__log1p(-p))[super 1\/[alpha]] ]]
  75. [[quantile from the complement][Using the relation: x = [beta] * (-log(q))[super 1\/[alpha]] ]]
  76. [[mean][[beta] * [Gamma](1 + 1\/[alpha]) ]]
  77. [[variance][[beta][super 2]([Gamma](1 + 2\/[alpha]) - [Gamma][super 2](1 + 1\/[alpha])) ]]
  78. [[mode][[beta](([alpha] - 1) \/ [alpha])[super 1\/[alpha]] ]]
  79. [[skewness][Refer to [@http://mathworld.wolfram.com/WeibullDistribution.html Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.] ]]
  80. [[kurtosis][Refer to [@http://mathworld.wolfram.com/WeibullDistribution.html Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.] ]]
  81. [[kurtosis excess][Refer to [@http://mathworld.wolfram.com/WeibullDistribution.html Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.] ]]
  82. ]
  83. [h4 References]
  84. * [@http://en.wikipedia.org/wiki/Weibull_distribution ]
  85. * [@http://mathworld.wolfram.com/WeibullDistribution.html Weisstein, Eric W. "Weibull Distribution." From MathWorld--A Wolfram Web Resource.]
  86. * [@http://www.itl.nist.gov/div898/handbook/eda/section3/eda3668.htm Weibull in NIST Exploratory Data Analysis]
  87. [endsect] [/section:weibull Weibull]
  88. [/
  89. Copyright 2006 John Maddock and Paul A. Bristow.
  90. Distributed under the Boost Software License, Version 1.0.
  91. (See accompanying file LICENSE_1_0.txt or copy at
  92. http://www.boost.org/LICENSE_1_0.txt).
  93. ]