17template <
typename RealType>
29 [[nodiscard]] std::string
Name()
const override;
31 [[nodiscard]] RealType
MinValue()
const override {
return 0; }
32 [[nodiscard]] RealType
MaxValue()
const override {
return INFINITY; }
35 [[nodiscard]]
inline double GetMean() const noexcept {
return mu; }
36 [[nodiscard]]
inline double GetShape() const noexcept {
return lambda; }
38 [[nodiscard]]
double f(
const RealType &x)
const override;
39 [[nodiscard]]
double logf(
const RealType &x)
const override;
40 [[nodiscard]]
double F(
const RealType &x)
const override;
41 [[nodiscard]]
double S(
const RealType &x)
const override;
42 template <std::uniform_random_bit_generator G>
45 [[nodiscard]]
long double Mean()
const override;
46 [[nodiscard]]
long double Variance()
const override;
47 [[nodiscard]] RealType
Mode()
const override;
48 [[nodiscard]]
long double Skewness()
const override;
52 std::complex<double> CFImpl(
double t)
const override;
63template <
typename RealType>
66 SetParameters(mean, shape);
69template <
typename RealType>
72 return "Inverse-Gaussian(" + this->toStringWithPrecision(GetMean()) +
", " +
73 this->toStringWithPrecision(GetShape()) +
")";
76template <
typename RealType>
80 throw std::invalid_argument(
"Inverse-Gaussian distribution: mean should be positive");
82 throw std::invalid_argument(
"Inverse-Gaussian distribution: shape should be positive");
87 cdfCoef = std::exp(2 * lambda / mu);
90template <
typename RealType>
93 return (x > 0.0) ? std::exp(logf(x)) : 0.0;
96template <
typename RealType>
101 double y = -1.5 * std::log(x);
104 z *= -0.5 * lambda / (x * mu * mu);
109template <
typename RealType>
114 double b = std::sqrt(0.5 * lambda / x);
115 double a = b * x / mu;
126template <
typename RealType>
131 double b = std::sqrt(0.5 * lambda / x);
132 double a = b * x / mu;
141template <
typename RealType>
142template <std::uniform_random_bit_generator G>
148 RealType mupX = mu * X;
149 RealType y = 4 * lambda + mupX;
150 y = std::sqrt(y * mupX);
154 if (U * (1 + y) > 1.0)
159template <
typename RealType>
165template <
typename RealType>
168 return mu * mu * mu / lambda;
171template <
typename RealType>
176 std::complex<double> y(1, -im - im);
177 y = 1.0 - std::sqrt(y);
182template <
typename RealType>
185 RealType aux = 1.5 * mu / lambda;
186 RealType mode = 1 + aux * aux;
187 mode = std::sqrt(mode);
192template <
typename RealType>
195 return 3 * std::sqrt(mu / lambda);
198template <
typename RealType>
201 return 15 * mu / lambda;
The ContinuousDistribution class Abstract class for all continuous distributions.
Definition continuous.hpp:22
The InverseGaussianRand class Inverse Gaussian (Wald) distribution.
Definition inverse_gaussian.hpp:19
double GetMean() const noexcept
Definition inverse_gaussian.hpp:35
RealType MaxValue() const override
Definition inverse_gaussian.hpp:32
double f(const RealType &x) const override
Definition inverse_gaussian.hpp:91
double F(const RealType &x) const override
Definition inverse_gaussian.hpp:110
double logf(const RealType &x) const override
Definition inverse_gaussian.hpp:97
RealType MinValue() const override
Definition inverse_gaussian.hpp:31
RealType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition inverse_gaussian.hpp:183
RealType operator()(G &g) const
Definition inverse_gaussian.hpp:143
double GetShape() const noexcept
Definition inverse_gaussian.hpp:36
void SetParameters(double mean, double shape)
Definition inverse_gaussian.hpp:77
double S(const RealType &x) const override
Definition inverse_gaussian.hpp:127
std::string Name() const override
Definition inverse_gaussian.hpp:70
long double Variance() const override
Definition inverse_gaussian.hpp:166
long double Skewness() const override
Definition inverse_gaussian.hpp:193
long double ExcessKurtosis() const override
Definition inverse_gaussian.hpp:199
long double Mean() const override
Definition inverse_gaussian.hpp:160
InverseGaussianRand(double mean=1, double shape=1)
Definition inverse_gaussian.hpp:64
Support SupportType() const override
Definition inverse_gaussian.hpp:30
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
constexpr long double inv_pi
Definition constants.hpp:24
constexpr long double sqrtpi
Definition constants.hpp:31
constexpr long double inv_sqrt2
Definition constants.hpp:28
constexpr long double e
Definition constants.hpp:15
Real standardNormal(G &g)
Ziggurat algorithm of Marsaglia and Tsang with 256 layers and an explicit sign bit.
Definition variates.hpp:45
Real erfcx(Real x)
Definition functions.hpp:525
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15