RandLib 2.0.0
Probability distributions, fitting, and heavy-tail tools for C++20
Loading...
Searching...
No Matches
geometric_stable.hpp
Go to the documentation of this file.
1#pragma once
2
8
9namespace randlib
10{
11
17template <typename RealType>
19{
20 RealType variate(detail::EngineRef g) const override { return (*this)(g); }
21 void sample(detail::EngineRef g, std::span<RealType> outputData) const override;
22
24
25protected:
26 double alpha = 2;
27 double alphaInv = 0.5;
28 double beta = 0;
29 double mu = 0;
30 double m = 0;
33
35 double kappa = 1;
36 double kappaInv = 1;
37 double kappaSq = 1;
39 double logKappa = 0;
40
41 GeneralGeometricStableDistribution(double exponent, double skewness, double scale = 1.0, double location = 0.0,
42 double shift = 0.0);
43
44public:
46
47protected:
48 void SetParameters(double exponent, double skewness, double scale = 1.0, double location = 0.0, double shift = 0.);
49 void SetLocation(double location);
50 void SetShift(double shift);
51 void SetScale(double scale);
52 void SetAsymmetry(double asymmetry);
53
64
66
67public:
68 [[nodiscard]] inline double GetExponent() const noexcept { return alpha; }
69 [[nodiscard]] inline double GetSkewness() const noexcept { return beta; }
70 [[nodiscard]] inline double GetScale() const noexcept { return gamma; }
71 [[nodiscard]] inline double GetLogScale() const noexcept { return logGamma; }
72
73 [[nodiscard]] Support SupportType() const override;
74 [[nodiscard]] RealType MinValue() const override;
75 [[nodiscard]] RealType MaxValue() const override;
76
77protected:
78 double pdfLaplace(double x) const;
79 double logpdfLaplace(double x) const;
80 double cdfLaplace(double x) const;
81 double cdfLaplaceCompl(double x) const;
82
83private:
84 double pdfByLevy(double x) const;
85 double pdfByCauchy(double x) const;
86
91 double conditionalShift(double w) const;
97 double lowerLogMixingVariable(double x0) const;
103 template <typename Function>
104 double mixtureIntegral(const Function &g, double logWMin) const;
105
106public:
107 [[nodiscard]] double f(const RealType &x) const override;
108 [[nodiscard]] double logf(const RealType &x) const override;
109 [[nodiscard]] double F(const RealType &x) const override;
110
111private:
112 template <std::uniform_random_bit_generator G>
113 double variateForUnityExponent(double z, G &g) const;
114 template <std::uniform_random_bit_generator G>
115 double variateForGeneralExponent(double z, G &g) const;
116 template <std::uniform_random_bit_generator G>
117 double variateForOneHalfExponent(double z, G &g) const;
118 template <std::uniform_random_bit_generator G>
119 double variateByCauchy(double z, G &g) const;
120
121public:
122 template <std::uniform_random_bit_generator G>
123 [[nodiscard]] RealType operator()(G &g) const;
124
125 [[nodiscard]] long double Mean() const override;
126 [[nodiscard]] long double Variance() const override;
127 [[nodiscard]] RealType Median() const override;
128 [[nodiscard]] RealType Mode() const override;
129 [[nodiscard]] long double Skewness() const override;
130 [[nodiscard]] long double ExcessKurtosis() const override;
131
132protected:
137 RealType quantileLaplace(double p) const;
142 RealType quantileLaplace1m(double p) const;
143
147 RealType searchTailQuantile(double p, bool upperTail) const;
148 RealType quantileImpl(double p) const override;
149 RealType quantileImpl1m(double p) const override;
150
151 std::complex<double> CFImpl(double t) const override;
152};
153
162template <typename RealType>
164{
165public:
166 GeometricStableRand(double exponent = 2, double skewness = 0, double scale = randlib::consts::sqrt2,
167 double location = 0);
169
170 [[nodiscard]] std::string Name() const override;
171
172private:
173 void ChangeAsymmetry();
174
175public:
176 void SetParameters(double exponent, double skewness);
177 void SetLocation(double location);
178 void SetScale(double scale);
179 [[nodiscard]] inline double GetLocation() const noexcept { return this->mu; }
180};
181
182} // namespace randlib
183
188
189namespace randlib
190{
191
192template <typename RealType>
194 double scale, double location,
195 double shift)
196{
197 SetParameters(exponent, skewness, scale, location, shift);
198}
199
200template <typename RealType>
201void GeneralGeometricStableDistribution<RealType>::SetParameters(double exponent, double skewness, double scale,
202 double location, double shift)
203{
204 if (!(exponent >= 0.1 && exponent <= 2.0))
205 throw std::invalid_argument(
206 "Geometric-Stable distribution: exponent should be inside the interval [0.1, 2], but it's equal to " +
207 std::to_string(exponent));
208 if (!(std::fabs(skewness) <= 1.0))
209 throw std::invalid_argument(
210 "Geometric-Stable distribution: skewness should be inside the interval [-1, 1], but it's equal to " +
211 std::to_string(skewness));
212
213 alpha = exponent;
214 alphaInv = 1.0 / alpha;
215 beta = skewness;
216 Z.SetExponent(alpha);
217 Z.SetSkewness(beta);
218
219 SetScale(scale);
220 SetLocation(location);
221 SetShift(shift);
222
223 if (alpha == 2.0)
224 distributionType = (mu == 0.0) ? LAPLACE : ASYMMETRIC_LAPLACE;
225 else if (alpha == 0.5)
226 distributionType = (std::fabs(beta) == 1.0) ? LEVY : ONEHALF_EXPONENT;
227 else if (alpha == 1.0)
228 distributionType = (beta == 0.0) ? CAUCHY : UNITY_EXPONENT;
229 else
230 distributionType = GENERAL;
231}
232
233template <typename RealType>
235{
236 if (!std::isfinite(location))
237 throw std::invalid_argument("Geometric-Stable distribution: location should be finite");
238 mu = location;
239}
240
241template <typename RealType>
243{
244 if (!std::isfinite(shift))
245 throw std::invalid_argument("Geometric-Stable distribution: shift should be finite");
246 m = shift;
247}
248
249template <typename RealType>
251{
252 if (!(scale > 0.0))
253 throw std::invalid_argument("Asymmetric-Laplace distribution: scale should be positive, but it's equal to " +
254 std::to_string(scale));
255 gamma = scale;
256 logGamma = std::log(gamma);
257}
258
259template <typename RealType>
261{
262 if (!(asymmetry > 0.0))
263 throw std::invalid_argument(
264 "Asymmetric-Laplace distribution: asymmetry parameter should be positive, but it's equal to " +
265 std::to_string(asymmetry));
266 kappa = asymmetry;
267 kappaInv = 1.0 / kappa;
268 kappaSq = kappa * kappa;
269 log1pKappaSq = std::log1pl(kappaSq);
270 logKappa = std::log(kappa);
271}
272
273template <typename RealType>
275{
276 if (alpha < 1) {
277 if (beta == 1 && mu >= 0)
279 if (beta == -1 && mu <= 0)
281 }
282 return Support::Infinite;
283}
284
285template <typename RealType>
287{
288 if (alpha < 1 && beta == 1 && mu >= 0)
289 return m;
290 return -INFINITY;
291}
292
293template <typename RealType>
295{
296 if (alpha < 1 && beta == -1 && mu <= 0)
297 return m;
298 return INFINITY;
299}
300
301template <typename RealType>
303{
304 return std::exp(logpdfLaplace(x));
305}
306
307template <typename RealType>
309{
310 double y = x / gamma;
311 y *= (x < 0) ? kappaInv : -kappa;
312 return y - logGamma - log1pKappaSq + logKappa;
313}
314
315template <typename RealType>
317{
318 double y = x / gamma;
319 if (x < 0) {
320 y *= kappaInv;
321 y += 2 * logKappa - log1pKappaSq;
322 return std::exp(y);
323 }
324 return -std::expm1l(-log1pKappaSq - kappa * y);
325}
326
327template <typename RealType>
329{
330 double y = x / gamma;
331 if (x < 0) {
332 y *= kappaInv;
333 y += 2 * logKappa - log1pKappaSq;
334 return -std::expm1l(y);
335 }
336 return std::exp(-log1pKappaSq - kappa * y);
337}
338
339template <typename RealType>
341{
342 if (mu == 0) {
344 x *= beta;
345 if (x < 0)
346 return 0.0;
347 if (x == 0)
348 return INFINITY;
349 double halfSigmaInv = 0.5 / gamma;
350 double z = std::sqrt(halfSigmaInv * x);
352 return 0.5 * y / (gamma * z);
353 }
354
355 if (x == 0) {
356 return std::fabs(1.0 / mu);
357 }
358
359 double a = x / gamma, c = mu / gamma;
360 if (beta < 0) {
361 a = -a;
362 c = -c;
363 }
364
365 if (a < 0) {
366 if (c >= 0.0)
367 return 0.0;
368 double h = std::sqrt(1 - 2 * c); // can be hashed
369 double hm1 = h - 1;
370 double y = 2 * a / (hm1 * hm1);
371 y -= std::log(gamma * hm1 * h);
373 return std::exp(y);
374 }
375
376 double sqrt2a = std::sqrt(2 * a);
377
378 if (c < 0.5) {
379 double h = std::sqrt(1 - 2 * c); // can be hashed
380 double term1 = math::sign(c) * sqrt2a / (1 - h);
381 double term2 = sqrt2a / (1 + h);
382 double y = math::xexpxsqerfc(term1);
383 y -= math::xexpxsqerfc(term2);
384 y /= h * gamma * sqrt2a;
385 return y;
386 }
387
388 if (c == 0.5) {
389 double y = math::xexpxsqerfc(sqrt2a);
390 y *= (8.0 * a + 2.0) / sqrt2a;
391 y -= 4 * sqrt2a / randlib::consts::sqrtpi;
392 return y / gamma;
393 }
394
396 // (as I wasn't able to handle complex integrals)
397 double adivc = x / mu;
398 double y = math::integrate(
399 [a, c, adivc](double t) {
400 if (t <= 0 || t >= adivc)
401 return 0.0;
402 double amct = a - c * t;
403 double integrand = 0.5 * t / amct;
404 ++integrand;
405 integrand *= t;
406 integrand = std::exp(-integrand);
407 integrand *= t;
408 integrand /= amct * std::sqrt(amct);
409 return integrand;
410 },
411 0, adivc);
412 return y / (gamma * randlib::consts::sqrt2pi);
413}
414
415template <typename RealType>
416double GeneralGeometricStableDistribution<RealType>::pdfByCauchy(double x) const
417{
418 // TODO: find analytical solution, maybe using residue technique
419 // otherwise, use peak, which is t = exp(x / sqrt(mu^2 + sigma^2))
420 // to split the integral on two
421 if (x == 0)
422 return INFINITY;
423 return -gamma * randlib::consts::inv_pi *
425 [this, x](double t) {
426 if (t <= 0.0 || t >= 1.0)
427 return 0.0;
428 double logt = std::log(t);
429 double a = gamma * logt;
430 a *= a;
431 double b = x + mu * logt;
432 b *= b;
433 return logt / (a + b);
434 },
435 0, 1);
436}
437
438template <typename RealType>
439double GeneralGeometricStableDistribution<RealType>::conditionalShift(double w) const
440{
443 double shift = mu * w;
444 if (distributionType == UNITY_EXPONENT)
445 shift += randlib::consts::two_inv_pi * beta * gamma * w * std::log(gamma * w);
446 return shift;
447}
448
449template <typename RealType>
450double GeneralGeometricStableDistribution<RealType>::lowerLogMixingVariable(double x0) const
451{
454 if (x0 == 0)
455 return -40.0;
456 return std::min(-20.0, alpha * std::log(std::fabs(x0) / gamma) - 20.0);
457}
458
459template <typename RealType>
460template <typename Function>
461double GeneralGeometricStableDistribution<RealType>::mixtureIntegral(const Function &g, double logWMin) const
462{
466 static constexpr double LOG_W_MAX = 7.0;
467 double wMin = std::exp(logWMin);
468 double head = -std::expm1(-wMin) * g(wMin);
469 return head + math::integrate(
470 [&g](double u) {
471 double w = std::exp(u);
472 return w * std::exp(-w) * g(w);
473 },
474 logWMin, LOG_W_MAX, 1e-13);
475}
476
477template <typename RealType>
479{
480 double x0 = x - m;
482 if (alpha < 1 && std::fabs(beta) == 1) {
483 if (x0 < 0 && mu >= 0 && beta > 0)
484 return 0.0;
485 if (x0 > 0 && mu <= 0 && beta < 0)
486 return 0.0;
487 }
488
490 if (distributionType == LAPLACE || distributionType == ASYMMETRIC_LAPLACE)
491 return pdfLaplace(x0);
492 if (distributionType == CAUCHY)
493 return pdfByCauchy(x0);
494 if (distributionType == LEVY)
495 return pdfByLevy(x0);
496
497 if (x0 == 0) {
498 if (alpha == 1)
499 return INFINITY;
500 if (mu == 0) {
501 double coef = std::tgammal(1.0 - alphaInv);
502 if (!std::isfinite(coef))
503 return INFINITY;
504 return Z.f(0) * coef / gamma;
505 }
506 }
507
508 if (distributionType != UNITY_EXPONENT) {
509 return mixtureIntegral(
510 [this, x0](double w) {
511 double tau = 1.0 / (gamma * std::pow(w, alphaInv));
512 return tau * Z.f(tau * x0 - tau * conditionalShift(w));
513 },
514 lowerLogMixingVariable(x0));
515 }
516
519 return math::integrate(
520 [this, x0](double z) {
521 if (z <= 0 || z >= 1)
522 return 0.0;
523 double logz = std::log(z);
524 double tau = 1.0 / (gamma * std::pow(-logz, alphaInv));
525 double par = tau * (x0 - conditionalShift(-logz));
526 return tau * Z.f(par);
527 },
528 0, 1, 1e-13);
529}
530
531template <typename RealType>
533{
534 return (distributionType == LAPLACE || distributionType == ASYMMETRIC_LAPLACE) ? logpdfLaplace(x - m)
535 : std::log(f(x));
536}
537
538template <typename RealType>
540{
541 double x0 = x - m;
542 if (distributionType == LAPLACE || distributionType == ASYMMETRIC_LAPLACE)
543 return cdfLaplace(x0);
544 if (distributionType != UNITY_EXPONENT) {
545 return mixtureIntegral(
546 [this, x0](double w) { return Z.F((x0 - conditionalShift(w)) / (gamma * std::pow(w, alphaInv))); },
547 lowerLogMixingVariable(x0));
548 }
549
551 return math::integrate(
552 [this, x0](double z) {
553 if (z <= 0)
554 return (x0 == 0.0) ? Z.F(-mu / gamma) : ((x0 < 0.0) ? 0.0 : 1.0);
555 if (z >= 1)
556 return Z.F(-mu / gamma);
557 double denominator = 1.0 - z;
558 double t = z / denominator;
559 double par = x0 - conditionalShift(t);
560 par /= std::pow(t, alphaInv) * gamma;
561 double y = std::exp(-t) * Z.F(par);
562 return y / (denominator * denominator);
563 },
564 0, 1, 1e-13);
565}
566
567template <typename RealType>
568template <std::uniform_random_bit_generator G>
570{
572 double X = z + 2 * beta * std::log(gamma * W) / randlib::consts::pi;
573 X *= gamma;
574 X += mu;
575 return X * W;
576}
577
578template <typename RealType>
579template <std::uniform_random_bit_generator G>
580double GeneralGeometricStableDistribution<RealType>::variateForGeneralExponent(double z, G &g) const
581{
583 double X = std::pow(W, alphaInv) * gamma * z;
584 return mu * W + X;
585}
586
587template <typename RealType>
588template <std::uniform_random_bit_generator G>
589double GeneralGeometricStableDistribution<RealType>::variateForOneHalfExponent(double z, G &g) const
590{
592 double X = mu + gamma * W * z;
593 return X * W;
594}
595
596template <typename RealType>
597template <std::uniform_random_bit_generator G>
598double GeneralGeometricStableDistribution<RealType>::variateByCauchy(double z, G &g) const
599{
601 double X = mu + gamma * z;
602 return X * W;
603}
604
605template <typename RealType>
606template <std::uniform_random_bit_generator G>
608{
609 switch (distributionType) {
610 case LAPLACE:
612 case ASYMMETRIC_LAPLACE:
614 case ONEHALF_EXPONENT:
615 case LEVY:
616 return variateForOneHalfExponent(Z(g), g);
617 case CAUCHY:
618 return variateByCauchy(Z(g), g);
619 case UNITY_EXPONENT:
620 return variateForUnityExponent(Z(g), g);
621 case GENERAL:
622 return variateForGeneralExponent(Z(g), g);
623 default:
624 throw std::runtime_error("Shifted Geometric Stable distribution: invalid distribution type");
625 }
626}
627
628template <typename RealType>
629void GeneralGeometricStableDistribution<RealType>::sample(detail::EngineRef g, std::span<RealType> outputData) const
630{
631 switch (distributionType) {
632 case LAPLACE: {
633 for (RealType &var : outputData)
634 var = gamma * LaplaceRand<RealType>::StandardVariate(g);
635 } break;
636 case ASYMMETRIC_LAPLACE: {
637 for (RealType &var : outputData)
638 var = gamma * AsymmetricLaplaceRand<RealType>::StandardVariate(kappa, g);
639 } break;
640 case ONEHALF_EXPONENT:
641 case LEVY: {
642 Z.Sample(g, outputData);
643 for (RealType &var : outputData)
644 var = variateForOneHalfExponent(var, g);
645 } break;
646 case CAUCHY: {
647 Z.Sample(g, outputData);
648 for (RealType &var : outputData)
649 var = variateByCauchy(var, g);
650 } break;
651 case UNITY_EXPONENT: {
652 Z.Sample(g, outputData);
653 for (RealType &var : outputData)
654 var = variateForUnityExponent(var, g);
655 } break;
656 case GENERAL: {
657 Z.Sample(g, outputData);
658 for (RealType &var : outputData)
659 var = variateForGeneralExponent(var, g);
660 } break;
661 default:
662 throw std::runtime_error("Shifted Geometric Stable distribution: invalid distribution type");
663 }
664}
665
666template <typename RealType>
668{
669 if (alpha > 1)
670 return m + mu;
671 if (beta == 1)
672 return INFINITY;
673 return (beta == -1) ? -INFINITY : NAN;
674}
675
676template <typename RealType>
678{
679 if (distributionType == LAPLACE || distributionType == ASYMMETRIC_LAPLACE)
680 return mu * mu + 2 * gamma * gamma;
681 return INFINITY;
682}
683
684template <typename RealType>
686{
687 double x = 0;
688 if (alpha != 2 && beta != 0) {
689 x = (alpha == 1) ? randlib::consts::two_inv_pi * std::log(t) : -std::tan(randlib::consts::half_pi * alpha);
690 x *= beta;
691 }
692 double re = std::pow(gamma * t, alpha);
693 std::complex<double> psi = std::complex<double>(re, re * x - mu * t);
694 return 1.0 / (1.0 + psi);
695}
696
697template <typename RealType>
699{
700 if (distributionType == LAPLACE || distributionType == ASYMMETRIC_LAPLACE)
701 return quantileLaplace(0.5);
703}
704
705template <typename RealType>
707{
708 // TODO: calculate mode for more cases
709 if (alpha == 1 || alpha == 2)
710 return m;
712}
713
714template <typename RealType>
716{
717 if (distributionType != LAPLACE && distributionType != ASYMMETRIC_LAPLACE)
718 return NAN;
719 long double k4 = kappaSq * kappaSq;
720 long double k6 = k4 * kappaSq;
721 long double z = (k4 + 1);
722 z *= std::sqrt(z);
723 long double y = 2 * (1 - k6);
724 return y / z;
725}
726
727template <typename RealType>
729{
730 if (distributionType != LAPLACE && distributionType != ASYMMETRIC_LAPLACE)
731 return NAN;
732 long double denominator = kappaSq + kappaInv * kappaInv;
733 denominator *= denominator;
734 return 6.0 - 12.0 / denominator;
735}
736
737template <typename RealType>
739{
740 double tail = std::min(p, 1.0 - p);
741 double guess = (tail < 0.05) ? stableTailQuantile(tail, upperTail != (p > 0.5), alpha, beta, gamma, mu) : NAN;
742 return this->searchQuantile(p, upperTail, guess, 0.05);
743}
744
745template <typename RealType>
747{
748 return searchTailQuantile(p, false);
749}
750
751template <typename RealType>
753{
754 return searchTailQuantile(p, true);
755}
756
757template <typename RealType>
759{
760 if (p < kappaSq / (1 + kappaSq)) {
761 RealType q = p / kappaSq + p;
762 q = std::log(q);
763 q *= kappa * gamma;
764 return m + q;
765 } else {
766 RealType q = (kappaSq + 1) * (1 - p);
767 q = std::log(q);
768 q *= gamma / kappa;
769 return m - q;
770 }
771}
772
773template <typename RealType>
775{
776 if (p > 1.0 / (1 + kappaSq)) {
777 RealType pm1 = p - 1.0;
778 RealType q = -pm1 / kappaSq - pm1;
779 q = std::log(q);
780 q *= kappa * gamma;
781 return m + q;
782 } else {
783 RealType q = (kappaSq + 1) * p;
784 q = std::log(q);
785 q *= gamma / kappa;
786 return m - q;
787 }
788}
789template <typename RealType>
790GeometricStableRand<RealType>::GeometricStableRand(double exponent, double skewness, double scale, double location)
791 : GeneralGeometricStableDistribution<RealType>(exponent, skewness, scale, location)
792{
793 ChangeAsymmetry();
794}
795
796template <typename RealType>
798{
799 return "Geometric Stable(" + this->toStringWithPrecision(this->GetExponent()) + ", " +
800 this->toStringWithPrecision(this->GetSkewness()) + ", " + this->toStringWithPrecision(this->GetScale()) +
801 ", " + this->toStringWithPrecision(this->GetLocation()) + ")";
802}
803
804template <typename RealType>
806{
807 if (this->distributionType != this->LAPLACE && this->distributionType != this->ASYMMETRIC_LAPLACE)
808 return;
809 double gamma2 = 2 * this->gamma;
810 double asymmetry = this->mu * this->mu + gamma2 * gamma2;
811 asymmetry = std::sqrt(asymmetry) - this->mu;
812 asymmetry /= gamma2;
813 this->SetAsymmetry(asymmetry);
814}
815
816template <typename RealType>
817void GeometricStableRand<RealType>::SetParameters(double exponent, double skewness)
818{
820 ChangeAsymmetry();
821}
822
823template <typename RealType>
825{
827 ChangeAsymmetry();
828}
829
830template <typename RealType>
832{
834 ChangeAsymmetry();
835}
836
837} // namespace randlib
static RealType StandardVariate(double asymmetry, G &g)
Definition laplace.hpp:376
The ContinuousDistribution class Abstract class for all continuous distributions.
Definition continuous.hpp:22
RealType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition continuous.hpp:285
The GeneralGeometricStableDistribution class Abstract class for general interface of Asymmetric Lapla...
Definition geometric_stable.hpp:19
double gamma
scale γ
Definition geometric_stable.hpp:31
RealType searchTailQuantile(double p, bool upperTail) const
Quantile search that starts far tails from their power-law asymptote.
Definition geometric_stable.hpp:738
double logf(const RealType &x) const override
Definition geometric_stable.hpp:532
double GetLogScale() const noexcept
Definition geometric_stable.hpp:71
long double Mean() const override
Definition geometric_stable.hpp:667
RealType quantileLaplace(double p) const
Definition geometric_stable.hpp:758
RealType quantileImpl(double p) const override
Definition geometric_stable.hpp:746
double kappaInv
1 / κ
Definition geometric_stable.hpp:36
virtual ~GeneralGeometricStableDistribution()
Definition geometric_stable.hpp:45
DISTRIBUTION_TYPE distributionType
type of distribution (Laplace by default)
Definition geometric_stable.hpp:65
RealType MinValue() const override
Definition geometric_stable.hpp:286
double log1pKappaSq
log(1 + κ^2)
Definition geometric_stable.hpp:38
void SetAsymmetry(double asymmetry)
Definition geometric_stable.hpp:260
long double ExcessKurtosis() const override
Definition geometric_stable.hpp:728
double alphaInv
Definition geometric_stable.hpp:27
double cdfLaplace(double x) const
Definition geometric_stable.hpp:316
long double Variance() const override
Definition geometric_stable.hpp:677
void SetLocation(double location)
Definition geometric_stable.hpp:234
double mu
location μ
Definition geometric_stable.hpp:29
DISTRIBUTION_TYPE
Definition geometric_stable.hpp:55
@ LAPLACE
α = 2, μ = 0
Definition geometric_stable.hpp:56
@ LEVY
α = 0.5, |β| = 1
Definition geometric_stable.hpp:59
@ ONEHALF_EXPONENT
α = 0.5, |β| ≠ 1
Definition geometric_stable.hpp:61
@ CAUCHY
α = 1, β = 0
Definition geometric_stable.hpp:58
@ ASYMMETRIC_LAPLACE
α = 2, μ ≠ 0
Definition geometric_stable.hpp:57
@ UNITY_EXPONENT
α = 1, β ≠ 0
Definition geometric_stable.hpp:60
@ GENERAL
the rest
Definition geometric_stable.hpp:62
double logGamma
log(γ)
Definition geometric_stable.hpp:32
double GetExponent() const noexcept
Definition geometric_stable.hpp:68
double F(const RealType &x) const override
Definition geometric_stable.hpp:539
double m
shift m
Definition geometric_stable.hpp:30
void SetShift(double shift)
Definition geometric_stable.hpp:242
double logpdfLaplace(double x) const
Definition geometric_stable.hpp:308
RealType MaxValue() const override
Definition geometric_stable.hpp:294
double kappa
parameters for α = 2
Definition geometric_stable.hpp:35
RealType quantileImpl1m(double p) const override
Definition geometric_stable.hpp:752
void SetParameters(double exponent, double skewness, double scale=1.0, double location=0.0, double shift=0.)
Definition geometric_stable.hpp:201
long double Skewness() const override
Definition geometric_stable.hpp:715
double alpha
characteristic exponent α
Definition geometric_stable.hpp:26
double f(const RealType &x) const override
Definition geometric_stable.hpp:478
double kappaSq
κ^2
Definition geometric_stable.hpp:37
double cdfLaplaceCompl(double x) const
Definition geometric_stable.hpp:328
RealType Median() const override
Definition geometric_stable.hpp:698
RealType quantileLaplace1m(double p) const
Definition geometric_stable.hpp:774
Support SupportType() const override
Definition geometric_stable.hpp:274
std::complex< double > CFImpl(double t) const override
Definition geometric_stable.hpp:685
double pdfLaplace(double x) const
Definition geometric_stable.hpp:302
RealType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition geometric_stable.hpp:706
void SetScale(double scale)
Definition geometric_stable.hpp:250
GeneralGeometricStableDistribution(double exponent, double skewness, double scale=1.0, double location=0.0, double shift=0.0)
log(κ)
Definition geometric_stable.hpp:193
RealType operator()(G &g) const
Definition geometric_stable.hpp:607
double beta
1/α
Definition geometric_stable.hpp:28
double GetScale() const noexcept
Definition geometric_stable.hpp:70
double GetSkewness() const noexcept
Definition geometric_stable.hpp:69
double logKappa
Definition geometric_stable.hpp:39
The GeometricStableRand class Geometric-Stable distribution.
Definition geometric_stable.hpp:164
GeometricStableRand(double exponent=2, double skewness=0, double scale=randlib::consts::sqrt2, double location=0)
Definition geometric_stable.hpp:790
std::string Name() const override
Definition geometric_stable.hpp:797
void SetScale(double scale)
Definition geometric_stable.hpp:831
void SetParameters(double exponent, double skewness)
Definition geometric_stable.hpp:817
void SetLocation(double location)
Definition geometric_stable.hpp:824
double GetLocation() const noexcept
Definition geometric_stable.hpp:179
virtual ~GeometricStableRand()
Definition geometric_stable.hpp:168
The LaplaceRand class Laplace distribution.
Definition laplace.hpp:150
static RealType StandardVariate(G &g)
Definition laplace.hpp:442
void Sample(std::span< T > outputData) const
Fills the output with variates drawn with the engine of this object.
Definition distribution.hpp:139
The StableRand class Stable distribution.
Definition stable.hpp:521
virtual RealType Median() const
Definition univariate.hpp:396
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 ln2
Definition constants.hpp:18
constexpr long double half_pi
Definition constants.hpp:23
constexpr long double sqrtpi
Definition constants.hpp:31
constexpr long double pi
Definition constants.hpp:22
constexpr long double two_inv_pi
Definition constants.hpp:25
constexpr long double inv_sqrtpi
Definition constants.hpp:33
constexpr long double sqrt2
Definition constants.hpp:27
constexpr long double e
Definition constants.hpp:15
constexpr long double sqrt2pi
Definition constants.hpp:32
Real standardNormal(G &g)
Ziggurat algorithm of Marsaglia and Tsang with 256 layers and an explicit sign bit.
Definition variates.hpp:45
int sign(Real x)
Definition functions.hpp:232
Real xexpxsqerfc(Real x)
xexpxsqerfc
Definition functions.hpp:504
Real integrate(const F &f, std::type_identity_t< Real > a, std::type_identity_t< Real > b, std::type_identity_t< Real > tolerance=1e-11, int maxSubdivisions=512)
Global adaptive Gauss-Kronrod quadrature (QUADPACK QAG).
Definition quadrature.hpp:226
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15
@ LeftSemiFinite
(-∞, b]
@ RightSemiFinite
[a, ∞)
@ Infinite
(-∞, ∞)
double stableTailQuantile(double p, bool upperTail, double alpha, double beta, double gamma, double mu)
Quantile of the power-law tails of a stable law with α < 2: P(X > x) ~ C (1 + β) γ^α x^(-α) and P(X <...
Definition stable.hpp:49