27template <
typename RealType>
33 LevyRand(
double location = 0,
double scale = 1);
34 [[nodiscard]] std::string
Name()
const override;
36 [[nodiscard]]
double f(
const RealType &x)
const override;
37 [[nodiscard]]
double logf(
const RealType &x)
const override;
38 [[nodiscard]]
double F(
const RealType &x)
const override;
39 [[nodiscard]]
double S(
const RealType &x)
const override;
40 template <std::uniform_random_bit_generator G>
43 template <std::uniform_random_bit_generator G>
47 RealType quantileImpl(
double p)
const override;
48 RealType quantileImpl1m(
double p)
const override;
50 std::complex<double> CFImpl(
double t)
const override;
67template <
typename RealType>
72template <
typename RealType>
75 return "Levy(" + this->toStringWithPrecision(this->GetLocation()) +
", " +
76 this->toStringWithPrecision(this->GetScale()) +
")";
79template <
typename RealType>
82 return this->pdfLevy(x);
85template <
typename RealType>
88 return this->logpdfLevy(x);
91template <
typename RealType>
94 return this->cdfLevy(x);
97template <
typename RealType>
100 return this->cdfLevyCompl(x);
103template <
typename RealType>
104template <std::uniform_random_bit_generator G>
109 rv = this->gamma / rv;
110 return this->mu + rv;
113template <
typename RealType>
114template <std::uniform_random_bit_generator G>
118 return 1.0 / (rv * rv);
121template <
typename RealType>
124 return this->quantileLevy(p);
127template <
typename RealType>
128RealType LevyRand<RealType>::quantileImpl1m(
double p)
const
130 return this->quantileLevy1m(p);
133template <
typename RealType>
134std::complex<double> LevyRand<RealType>::CFImpl(
double t)
const
136 return this->cfLevy(t);
139template <
typename RealType>
143 if (!this->allElementsAreNotSmallerThan(this->mu, sample))
145 this->LOWER_LIMIT_VIOLATION + this->toStringWithPrecision(this->mu));
146 long double invSum = 0.0;
147 for (RealType var : sample)
148 invSum += 1.0 / (var - this->mu);
149 invSum = 1.0 / invSum;
150 this->SetScale(sample.size() * invSum);
The LevyRand class Levy distribution.
Definition levy.hpp:29
void FitScale(std::span< const RealType > sample)
Fit scale using maximum-likelihoood estimator.
Definition levy.hpp:140
LevyRand(double location=0, double scale=1)
Definition levy.hpp:68
static RealType StandardVariate(G &g)
Definition levy.hpp:115
double S(const RealType &x) const override
Definition levy.hpp:98
RealType operator()(G &g) const
Definition levy.hpp:105
double F(const RealType &x) const override
Definition levy.hpp:92
double logf(const RealType &x) const override
Definition levy.hpp:86
double f(const RealType &x) const override
Definition levy.hpp:80
std::string Name() const override
Definition levy.hpp:73
virtual void sample(detail::EngineRef g, std::span< T > outputData) const
Fills the output with variate(g); distributions with a faster bulk algorithm override it.
Definition distribution.hpp:66
The StableDistribution class Abstract class for Stable distribution.
Definition stable.hpp:74
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
#define RANDLIB_DEPRECATED_FIT_MEMBER
Definition fwd.hpp:9
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
@ WrongSample
the sample could not have been drawn from this distribution