20template <
typename RealType>
29 GumbelRand(
double location = 0,
double scale = 1);
31 [[nodiscard]] std::string
Name()
const override;
33 [[nodiscard]] RealType
MinValue()
const override {
return -INFINITY; }
34 [[nodiscard]] RealType
MaxValue()
const override {
return INFINITY; }
38 [[nodiscard]]
inline double GetLocation() const noexcept {
return mu; }
39 [[nodiscard]]
inline double GetScale() const noexcept {
return beta; }
41 [[nodiscard]]
double f(
const RealType &x)
const override;
42 [[nodiscard]]
double logf(
const RealType &x)
const override;
43 [[nodiscard]]
double F(
const RealType &x)
const override;
44 [[nodiscard]]
double S(
const RealType &x)
const override;
45 template <std::uniform_random_bit_generator G>
48 template <std::uniform_random_bit_generator G>
51 [[nodiscard]]
long double Mean()
const override;
52 [[nodiscard]]
long double Variance()
const override;
53 [[nodiscard]] RealType
Median()
const override;
54 [[nodiscard]] RealType
Mode()
const override;
55 [[nodiscard]]
long double Skewness()
const override;
59 RealType quantileImpl(
double p)
const override;
60 RealType quantileImpl1m(
double p)
const override;
63 [[nodiscard]]
long double Entropy()
const;
73template <
typename RealType>
76 SetLocation(location);
80template <
typename RealType>
83 return "Gumbel(" + this->toStringWithPrecision(GetLocation()) +
", " + this->toStringWithPrecision(GetScale()) +
87template <
typename RealType>
90 if (!std::isfinite(location))
91 throw std::invalid_argument(
"Gumbel distribution: location should be finite");
95template <
typename RealType>
99 throw std::invalid_argument(
"Gumbel distribution: scale should be positive");
101 logBeta = std::log(beta);
104template <
typename RealType>
107 return std::exp(logf(x));
110template <
typename RealType>
113 double z = (mu - x) / beta;
114 double y = std::exp(z);
115 return z - y - logBeta;
118template <
typename RealType>
121 double y = (mu - x) / beta;
126template <
typename RealType>
129 double y = (mu - x) / beta;
131 return -std::expm1l(-y);
134template <
typename RealType>
135template <std::uniform_random_bit_generator G>
141template <
typename RealType>
142template <std::uniform_random_bit_generator G>
149template <
typename RealType>
155template <
typename RealType>
162template <
typename RealType>
165 return mu - beta * std::log(-std::log(p));
168template <
typename RealType>
169RealType GumbelRand<RealType>::quantileImpl1m(
double p)
const
171 return mu - beta * std::log(-std::log1pl(-p));
174template <
typename RealType>
178 return mu - beta * M_LN_LN2;
181template <
typename RealType>
187template <
typename RealType>
195template <
typename RealType>
201template <
typename RealType>
The ContinuousDistribution class Abstract class for all continuous distributions.
Definition continuous.hpp:22
The GumbelRand class Gumbel distribution.
Definition gumbel.hpp:22
static RealType StandardVariate(G &g)
Definition gumbel.hpp:143
double GetScale() const noexcept
Definition gumbel.hpp:39
RealType Median() const override
Definition gumbel.hpp:175
std::string Name() const override
Definition gumbel.hpp:81
double f(const RealType &x) const override
Definition gumbel.hpp:105
long double ExcessKurtosis() const override
Definition gumbel.hpp:196
long double Mean() const override
Definition gumbel.hpp:150
double S(const RealType &x) const override
Definition gumbel.hpp:127
GumbelRand(double location=0, double scale=1)
Definition gumbel.hpp:74
void SetScale(double scale)
Definition gumbel.hpp:96
double GetLocation() const noexcept
Definition gumbel.hpp:38
Support SupportType() const override
Definition gumbel.hpp:32
RealType MaxValue() const override
Definition gumbel.hpp:34
void SetLocation(double location)
Definition gumbel.hpp:88
long double Variance() const override
Definition gumbel.hpp:156
RealType MinValue() const override
Definition gumbel.hpp:33
double logf(const RealType &x) const override
Definition gumbel.hpp:111
double F(const RealType &x) const override
Definition gumbel.hpp:119
long double Skewness() const override
Definition gumbel.hpp:188
long double Entropy() const
Definition gumbel.hpp:202
RealType operator()(G &g) const
Definition gumbel.hpp:136
RealType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition gumbel.hpp:182
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
constexpr long double ln2
Definition constants.hpp:18
constexpr long double egamma
Definition constants.hpp:36
constexpr long double apery
Definition constants.hpp:37
constexpr long double pi
Definition constants.hpp:22
constexpr long double pi_sq
Definition constants.hpp:39
constexpr long double sqrt2
Definition constants.hpp:27
constexpr long double sqrt3
Definition constants.hpp:29
Real standardNormal(G &g)
Ziggurat algorithm of Marsaglia and Tsang with 256 layers and an explicit sign bit.
Definition variates.hpp:45
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15