21template <
typename IntType>
27 double lgamma1pRo = 0;
33 [[nodiscard]] std::string
Name()
const override;
35 [[nodiscard]] IntType
MinValue()
const override {
return 1; }
36 [[nodiscard]] IntType
MaxValue()
const override {
return std::numeric_limits<IntType>::max(); }
39 [[nodiscard]]
inline double GetShape() const noexcept {
return rho; }
41 [[nodiscard]]
double logP(
const IntType &k)
const override;
42 [[nodiscard]]
double F(
const IntType &k)
const override;
43 [[nodiscard]]
double S(
const IntType &k)
const override;
44 template <std::uniform_random_bit_generator G>
47 template <std::uniform_random_bit_generator G>
48 [[nodiscard]]
static IntType
Variate(
double shape, G &g);
50 [[nodiscard]]
long double Mean()
const override;
51 [[nodiscard]]
long double Variance()
const override;
52 [[nodiscard]] IntType
Mode()
const override;
53 [[nodiscard]]
long double Skewness()
const override;
65template <
typename IntType>
71template <
typename IntType>
74 return "Yule(" + this->toStringWithPrecision(GetShape()) +
")";
77template <
typename IntType>
81 throw std::invalid_argument(
"Yule distribution: shape should be positive");
83 lgamma1pRo = std::lgammal(rho + 1);
87template <
typename IntType>
92 double y = lgamma1pRo;
94 y -= std::lgammal(k + rho + 1);
99template <
typename IntType>
104 double y = lgamma1pRo;
106 y -= std::lgammal(k + rho + 1);
107 double logk = std::log(k);
108 return -std::expm1(y + logk);
111template <
typename IntType>
116 double y = lgamma1pRo;
118 y -= std::lgammal(k + rho + 1);
123template <
typename IntType>
124template <std::uniform_random_bit_generator G>
127 double prob = 1.0 / X(g);
131template <
typename IntType>
132template <std::uniform_random_bit_generator G>
136 throw std::invalid_argument(
"Yule distribution: shape should be positive");
141template <
typename IntType>
144 return (rho <= 1) ? INFINITY : rho / (rho - 1);
147template <
typename IntType>
152 double aux = rho / (rho - 1);
153 return aux * aux / (rho - 2);
156template <
typename IntType>
162template <
typename IntType>
167 long double skewness = rho + 1;
168 skewness *= skewness;
169 skewness *= std::sqrt(rho - 2);
170 return skewness / (rho * (rho - 3));
173template <
typename IntType>
178 long double numerator = 11 * rho * rho - 49;
181 long double denominator = rho * (rho - 4) * (rho - 3);
182 return rho + 3 + numerator / denominator;
The DiscreteDistribution class Abstract class for all discrete distributions.
Definition discrete.hpp:21
The ParetoRand class Pareto distribution.
Definition pareto.hpp:24
static RealType StandardVariate(double shape, G &g)
Definition pareto.hpp:219
T Variate() const
Uses the engine of this object, so it is not thread-safe for one object; use operator() with one engi...
Definition distribution.hpp:133
The YuleRand class Yule distribution.
Definition yule.hpp:23
long double Variance() const override
Definition yule.hpp:148
double GetShape() const noexcept
Definition yule.hpp:39
double F(const IntType &k) const override
Definition yule.hpp:100
IntType operator()(G &g) const
Definition yule.hpp:125
IntType MinValue() const override
Definition yule.hpp:35
double S(const IntType &k) const override
Definition yule.hpp:112
IntType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition yule.hpp:157
long double Skewness() const override
Definition yule.hpp:163
IntType MaxValue() const override
Definition yule.hpp:36
Support SupportType() const override
Definition yule.hpp:34
std::string Name() const override
Definition yule.hpp:72
long double ExcessKurtosis() const override
Definition yule.hpp:174
void SetShape(double shape)
Definition yule.hpp:78
double logP(const IntType &k) const override
Definition yule.hpp:88
long double Mean() const override
Definition yule.hpp:142
YuleRand(double shape)
Definition yule.hpp:66
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
Real lfact(size_t n)
Calculate log(n!) using table values for small n <= 255 and built-in lgamma function for large n > 25...
Definition math/gamma.hpp:591
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15