Honeycomb  0.1
Component-Model Framework
Weibull.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
5 
6 namespace honey
7 {
8 
10 
26 template<class Real>
27 class Weibull_ : public RandomDist<Real>
28 {
29  typedef RandomDist<Real> Super;
30  RandomDist_imports();
31  typedef Gamma_<Double> Gamma;
33  typedef Poisson_<Double> Poisson;
34 
35 public:
36  Weibull_(RandomGen& gen, Real a, Real b) : Super(gen), a(a), b(b) { assert(a > 0 && b > 0); }
37 
38  virtual Real next() const;
39  virtual Real pdf(Real x) const;
40  virtual Real cdf(Real x) const;
41  virtual Real cdfComp(Real x) const;
42  virtual Real cdfInv(Real P) const;
43  virtual Real mean() const { return Double(a) * GammaFunc::gamma(1 + 1 / Double(b)); }
44  virtual Real variance() const { return Alge_d::sqr(Double(a)) * (GammaFunc::gamma(1 + 2 / Double(b)) - Alge_d::sqr(GammaFunc::gamma(1 + 1 / Double(b)))); }
45 
48 };
49 
53 
54 extern template class Weibull_<Float>;
55 extern template class Weibull_<Double>;
56 
57 }
virtual Real cdfInv(Real P) const
Inverse of the CDF.
Definition: Weibull.cpp:52
Random number generator interface.
Definition: Gen.h:11
virtual Real cdf(Real x) const
Cumulative Distribution Function.
Definition: Weibull.cpp:36
Generate a random integer variate from a poisson distribution.
Definition: Poisson.h:28
Weibull_< Real > Weibull
Definition: Weibull.h:50
Generate a random variate from a gamma distribution .
Definition: Gamma.h:29
virtual Real cdfComp(Real x) const
Complement of the CDF.
Definition: Weibull.cpp:44
Class to evaluate Gamma and related functions.
Definition: Gamma.h:9
Real a
Definition: Weibull.h:46
virtual Real variance() const
Calc variance.
Definition: Weibull.h:44
static Real gamma(Real z)
Gamma function.
Definition: Gamma.h:72
Weibull_(RandomGen &gen, Real a, Real b)
Definition: Weibull.h:36
Double_::Real Double
Definition: Dist.h:20
virtual Real next() const
Get next randomly distributed variate. Requires a random generator (see ctor or setGen()) ...
Definition: Weibull.cpp:11
#define assert(...)
Forwards to assert_#args. See assert_1(), assert_2().
Definition: Debug.h:24
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
virtual Real mean() const
Calc mean.
Definition: Weibull.h:43
Weibull_< Double > Weibull_d
Definition: Weibull.h:52
static Num sqr(Num x)
Square.
Definition: Alge.h:60
Weibull_< Float > Weibull_f
Definition: Weibull.h:51
Generate a random integer variate from a weibull distribution.
Definition: Weibull.h:27
virtual Real pdf(Real x) const
Probability Density Function.
Definition: Weibull.cpp:17
Real b
Definition: Weibull.h:47
Global Honeycomb namespace.
Base class for all random distributions.
Definition: Dist.h:15