RandLib 2.0.0
Probability distributions, fitting, and heavy-tail tools for C++20
Loading...
Searching...
No Matches
randlib::GeneralGeometricStableDistribution< RealType > Class Template Reference

The GeneralGeometricStableDistribution class Abstract class for general interface of Asymmetric Laplace and Geometric-Stable distributions. More...

#include <geometric_stable.hpp>

Inheritance diagram for randlib::GeneralGeometricStableDistribution< RealType >:
Collaboration diagram for randlib::GeneralGeometricStableDistribution< RealType >:

Public Member Functions

virtual ~GeneralGeometricStableDistribution ()
 
double GetExponent () const noexcept
 
double GetSkewness () const noexcept
 
double GetScale () const noexcept
 
double GetLogScale () const noexcept
 
Support SupportType () const override
 
RealType MinValue () const override
 
RealType MaxValue () const override
 
double f (const RealType &x) const override
 
double logf (const RealType &x) const override
 
double F (const RealType &x) const override
 
template<std::uniform_random_bit_generator G>
RealType operator() (G &g) const
 
long double Mean () const override
 
long double Variance () const override
 
RealType Median () const override
 
RealType Mode () const override
 Mode is the value, which has the largest probability to happen, or, in the case of continuous distribution, has the largest value of density function.
 
long double Skewness () const override
 
long double ExcessKurtosis () const override
 
- Public Member Functions inherited from randlib::ContinuousDistribution< RealType >
virtual ~ContinuousDistribution ()
 
void ProbabilityDensityFunction (std::span< const RealType > x, std::span< double > y) const
 fill vector y with f(x)
 
void LogProbabilityDensityFunction (std::span< const RealType > x, std::span< double > y) const
 fill vector y with logf(x)
 
double Hazard (const RealType &x) const override
 
double LikelihoodFunction (std::span< const RealType > sample) const override
 
double LogLikelihoodFunction (std::span< const RealType > sample) const override
 
bool KolmogorovSmirnovTest (std::span< const RealType > orderStatistic, double alpha) const
 
- Public Member Functions inherited from randlib::UnivariateDistribution< RealType >
virtual ~UnivariateDistribution ()
 
bool isLeftBounded () const
 
bool isRightBounded () const
 
RealType Quantile (double p) const
 
RealType Quantile1m (double p) const
 
void QuantileFunction (std::span< const double > p, std::span< RealType > y) const
 
void QuantileFunction1m (std::span< const double > p, std::span< RealType > y) const
 
std::complex< double > CF (double t) const
 
void CharacteristicFunction (std::span< const double > t, std::span< std::complex< double > > y) const
 
void HazardFunction (std::span< const RealType > x, std::span< double > y) const
 
virtual long double Kurtosis () const
 
virtual long double SecondMoment () const
 
virtual long double ThirdMoment () const
 
virtual long double FourthMoment () const
 
- Public Member Functions inherited from randlib::ProbabilityDistribution< T >
virtual ~ProbabilityDistribution ()=default
 
virtual std::string Name () const =0
 
virtual double F (const T &x) const =0
 
void CumulativeDistributionFunction (std::span< const T > x, std::span< double > y) const
 
virtual double S (const T &x) const
 
void SurvivalFunction (std::span< const T > x, std::span< double > y) const
 
template<std::uniform_random_bit_generator G>
T operator() (G &g) const
 Draws a variate with the given engine through the virtual interface.
 
T Variate () const
 Uses the engine of this object, so it is not thread-safe for one object; use operator() with one engine per thread instead.
 
void Sample (std::span< T > outputData) const
 Fills the output with variates drawn with the engine of this object.
 
template<std::uniform_random_bit_generator G>
void Sample (G &g, std::span< T > outputData) const
 Fills the output with variates drawn with the given engine.
 
void Reseed (std::uint64_t seed)
 

Protected Types

enum  DISTRIBUTION_TYPE {
  LAPLACE , ASYMMETRIC_LAPLACE , CAUCHY , LEVY ,
  UNITY_EXPONENT , ONEHALF_EXPONENT , GENERAL
}
 

Protected Member Functions

 GeneralGeometricStableDistribution (double exponent, double skewness, double scale=1.0, double location=0.0, double shift=0.0)
 log(κ)
 
void SetParameters (double exponent, double skewness, double scale=1.0, double location=0.0, double shift=0.)
 
void SetLocation (double location)
 
void SetShift (double shift)
 
void SetScale (double scale)
 
void SetAsymmetry (double asymmetry)
 
double pdfLaplace (double x) const
 
double logpdfLaplace (double x) const
 
double cdfLaplace (double x) const
 
double cdfLaplaceCompl (double x) const
 
RealType quantileLaplace (double p) const
 
RealType quantileLaplace1m (double p) const
 
RealType searchTailQuantile (double p, bool upperTail) const
 Quantile search that starts far tails from their power-law asymptote.
 
RealType quantileImpl (double p) const override
 
RealType quantileImpl1m (double p) const override
 
std::complex< double > CFImpl (double t) const override
 
- Protected Member Functions inherited from randlib::ContinuousDistribution< RealType >
 ContinuousDistribution ()
 
std::complex< double > integrateCharacteristicFunction (double t) const
 
RealType quantileImpl (double p, RealType initValue) const override
 
RealType quantileImpl1m (double p, RealType initValue) const override
 
long double ExpectedValue (const std::function< double(RealType)> &funPtr, RealType minPoint, RealType maxPoint) const override
 
RealType searchQuantile (double p, bool upperTail, RealType guess, double relativeStep=1e-3) const
 Deterministic root search for the quantile: brackets the root, starting from the guess when it is finite, then refines it with the Illinois variant of regula falsi (on a logarithmic scale for small p), falling back to bisection whenever the bracket does not halve.
 
- Protected Member Functions inherited from randlib::UnivariateDistribution< RealType >
 UnivariateDistribution ()
 
- Protected Member Functions inherited from randlib::ProbabilityDistribution< T >
std::string toStringWithPrecision (const double a_value, const int n=6) const
 
 ProbabilityDistribution ()=default
 
DefaultEngine & engine () const
 
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.
 
fit_error fitError (FitErrorCode code, const std::string &explanation) const
 

Protected Attributes

double alpha = 2
 characteristic exponent α
 
double alphaInv = 0.5
 
double beta = 0
 1/α
 
double mu = 0
 location μ
 
double m = 0
 shift m
 
double gamma = randlib::consts::sqrt2
 scale γ
 
double logGamma = 0.5 * randlib::consts::ln2
 log(γ)
 
double kappa = 1
 parameters for α = 2
 
double kappaInv = 1
 1 / κ
 
double kappaSq = 1
 κ^2
 
double log1pKappaSq = randlib::consts::ln2
 log(1 + κ^2)
 
double logKappa = 0
 
DISTRIBUTION_TYPE distributionType = LAPLACE
 type of distribution (Laplace by default)
 

Additional Inherited Members

- Public Types inherited from randlib::ProbabilityDistribution< T >
using value_type = T
 
- Static Public Member Functions inherited from randlib::UnivariateDistribution< RealType >
static long double GetSampleSum (std::span< const RealType > sample)
 
static long double GetSampleMean (std::span< const RealType > sample)
 
static long double GetSampleLogMean (std::span< const RealType > sample)
 
static long double GetSampleVariance (std::span< const RealType > sample, double mean)
 
static long double GetSampleLogVariance (std::span< const RealType > sample, double logMean)
 
static LongDoublePair GetSampleMeanAndVariance (std::span< const RealType > sample)
 
static LongDoublePair GetSampleLogMeanAndVariance (std::span< const RealType > sample)
 
static std::tuple< long double, long double, long double, long double > GetSampleStatistics (std::span< const RealType > sample)
 
- Static Protected Member Functions inherited from randlib::UnivariateDistribution< RealType >
static bool allElementsAreNotGreaterThan (RealType value, std::span< const RealType > sample)
 
static bool allElementsAreNotSmallerThan (RealType value, std::span< const RealType > sample)
 
static bool allElementsAreNonNegative (std::span< const RealType > sample)
 
static bool allElementsArePositive (std::span< const RealType > sample)
 
- Static Protected Attributes inherited from randlib::ProbabilityDistribution< T >
static constexpr size_t MAX_ITER_REJECTION = detail::MAX_ITER_REJECTION
 MAX_ITER_REJECTION upper boundary for maximum amount of iterations in rejection methods one thousand should be enough to be sure there is a bug (or rejection method is too slow to be used)
 
static constexpr char POSITIVITY_VIOLATION [] = "All elements should be positive"
 
static constexpr char NON_NEGATIVITY_VIOLATION [] = "All elements should be non-negative"
 
static constexpr char UPPER_LIMIT_VIOLATION [] = "No element should be greater than "
 
static constexpr char LOWER_LIMIT_VIOLATION [] = "No element should be smaller than "
 

Detailed Description

template<typename RealType>
class randlib::GeneralGeometricStableDistribution< RealType >

The GeneralGeometricStableDistribution class Abstract class for general interface of Asymmetric Laplace and Geometric-Stable distributions.

Member Enumeration Documentation

◆ DISTRIBUTION_TYPE

template<typename RealType >
enum randlib::GeneralGeometricStableDistribution::DISTRIBUTION_TYPE
protected
Enumerator
LAPLACE 

α = 2, μ = 0

ASYMMETRIC_LAPLACE 

α = 2, μ ≠ 0

CAUCHY 

α = 1, β = 0

LEVY 

α = 0.5, |β| = 1

UNITY_EXPONENT 

α = 1, β ≠ 0

ONEHALF_EXPONENT 

α = 0.5, |β| ≠ 1

GENERAL 

the rest

Constructor & Destructor Documentation

◆ GeneralGeometricStableDistribution()

template<typename RealType >
randlib::GeneralGeometricStableDistribution< RealType >::GeneralGeometricStableDistribution ( double  exponent,
double  skewness,
double  scale = 1.0,
double  location = 0.0,
double  shift = 0.0 
)
protected

log(κ)

◆ ~GeneralGeometricStableDistribution()

template<typename RealType >
virtual randlib::GeneralGeometricStableDistribution< RealType >::~GeneralGeometricStableDistribution ( )
inlinevirtual

Member Function Documentation

◆ cdfLaplace()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::cdfLaplace ( double  x) const
protected

◆ cdfLaplaceCompl()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::cdfLaplaceCompl ( double  x) const
protected

◆ CFImpl()

template<typename RealType >
std::complex< double > randlib::GeneralGeometricStableDistribution< RealType >::CFImpl ( double  t) const
overrideprotectedvirtual
Parameters
t
Returns
characteristic function implementation (inverse Fourier transform of pdf)

Reimplemented from randlib::UnivariateDistribution< RealType >.

◆ ExcessKurtosis()

template<typename RealType >
long double randlib::GeneralGeometricStableDistribution< RealType >::ExcessKurtosis ( ) const
overridevirtual
Returns
E[((X - μ) / σ) ^ 4] - 3 (fourth moment around the mean divided by the square of the variance of the probability distribution minus 3)

var is finite, so is mu

Reimplemented from randlib::UnivariateDistribution< RealType >.

◆ f()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::f ( const RealType &  x) const
overridevirtual
Parameters
x
Returns
probability density function

Cut zeros for semi-infinite distribution

Verify if any of analytical expressions is applicable

For α = 1, small w would need the stable law far in its tails, where it is slow (#1); integrate in z = exp(-w) instead

Reimplemented from randlib::ContinuousDistribution< RealType >.

◆ F()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::F ( const RealType &  x) const
override

For α = 1, integrate in t = z / (1 - z) instead (see f)

◆ GetExponent()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::GetExponent ( ) const
inlinenoexcept

◆ GetLogScale()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::GetLogScale ( ) const
inlinenoexcept

◆ GetScale()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::GetScale ( ) const
inlinenoexcept

◆ GetSkewness()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::GetSkewness ( ) const
inlinenoexcept

◆ logf()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::logf ( const RealType &  x) const
overridevirtual
Parameters
x
Returns
logarithm of probability density function

Implements randlib::ContinuousDistribution< RealType >.

◆ logpdfLaplace()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::logpdfLaplace ( double  x) const
protected

◆ MaxValue()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::MaxValue ( ) const
overridevirtual
Returns
maximum possible value that can be achieved by random variable

Implements randlib::ProbabilityDistribution< T >.

◆ Mean()

template<typename RealType >
long double randlib::GeneralGeometricStableDistribution< RealType >::Mean ( ) const
overridevirtual
Returns
Mathematical expectation

Implements randlib::UnivariateDistribution< RealType >.

◆ Median()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::Median ( ) const
overridevirtual
Returns
such x that F(x) = 0.5

Reimplemented from randlib::UnivariateDistribution< RealType >.

◆ MinValue()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::MinValue ( ) const
overridevirtual
Returns
minimum possible value that can be achieved by random variable

Implements randlib::ProbabilityDistribution< T >.

◆ Mode()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::Mode ( ) const
overridevirtual

Mode is the value, which has the largest probability to happen, or, in the case of continuous distribution, has the largest value of density function.

Returns
mode. In case, when it's not unique, return any of them.

Reimplemented from randlib::ContinuousDistribution< RealType >.

◆ operator()()

template<typename RealType >
template<std::uniform_random_bit_generator G>
RealType randlib::GeneralGeometricStableDistribution< RealType >::operator() ( G &  g) const

◆ pdfLaplace()

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::pdfLaplace ( double  x) const
protected

◆ quantileImpl()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::quantileImpl ( double  p) const
overrideprotectedvirtual

◆ quantileImpl1m()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::quantileImpl1m ( double  p) const
overrideprotectedvirtual

◆ quantileLaplace()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::quantileLaplace ( double  p) const
protected
Parameters
pinput parameter in the interval (0, 1)
Returns
quantile for (Asymmetric) Laplace distribution

◆ quantileLaplace1m()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::quantileLaplace1m ( double  p) const
protected
Parameters
pinput parameter in the interval (0, 1)
Returns
quantile of 1-p for (Asymmetric) Laplace distribution

◆ searchTailQuantile()

template<typename RealType >
RealType randlib::GeneralGeometricStableDistribution< RealType >::searchTailQuantile ( double  p,
bool  upperTail 
) const
protected

Quantile search that starts far tails from their power-law asymptote.

◆ SetAsymmetry()

template<typename RealType >
void randlib::GeneralGeometricStableDistribution< RealType >::SetAsymmetry ( double  asymmetry)
protected

◆ SetLocation()

template<typename RealType >
void randlib::GeneralGeometricStableDistribution< RealType >::SetLocation ( double  location)
protected

◆ SetParameters()

template<typename RealType >
void randlib::GeneralGeometricStableDistribution< RealType >::SetParameters ( double  exponent,
double  skewness,
double  scale = 1.0,
double  location = 0.0,
double  shift = 0. 
)
protected

◆ SetScale()

template<typename RealType >
void randlib::GeneralGeometricStableDistribution< RealType >::SetScale ( double  scale)
protected

◆ SetShift()

template<typename RealType >
void randlib::GeneralGeometricStableDistribution< RealType >::SetShift ( double  shift)
protected

◆ Skewness()

template<typename RealType >
long double randlib::GeneralGeometricStableDistribution< RealType >::Skewness ( ) const
overridevirtual
Returns
E[((X - μ) / σ) ^ 3] where μ is central moment and σ is standard deviation

var is finite, so is mu

Reimplemented from randlib::UnivariateDistribution< RealType >.

◆ SupportType()

template<typename RealType >
Support randlib::GeneralGeometricStableDistribution< RealType >::SupportType ( ) const
overridevirtual
Returns
type of support

Implements randlib::UnivariateDistribution< RealType >.

◆ Variance()

template<typename RealType >
long double randlib::GeneralGeometricStableDistribution< RealType >::Variance ( ) const
overridevirtual
Returns
Variance of random variable

Implements randlib::UnivariateDistribution< RealType >.

Member Data Documentation

◆ alpha

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::alpha = 2
protected

characteristic exponent α

◆ alphaInv

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::alphaInv = 0.5
protected

◆ beta

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::beta = 0
protected

1/α

skewness β

◆ distributionType

template<typename RealType >
DISTRIBUTION_TYPE randlib::GeneralGeometricStableDistribution< RealType >::distributionType = LAPLACE
protected

type of distribution (Laplace by default)

◆ gamma

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::gamma = randlib::consts::sqrt2
protected

scale γ

◆ kappa

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::kappa = 1
protected

parameters for α = 2

asymmetry coefficient κ

◆ kappaInv

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::kappaInv = 1
protected

1 / κ

◆ kappaSq

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::kappaSq = 1
protected

κ^2

◆ log1pKappaSq

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::log1pKappaSq = randlib::consts::ln2
protected

log(1 + κ^2)

◆ logGamma

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::logGamma = 0.5 * randlib::consts::ln2
protected

log(γ)

◆ logKappa

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::logKappa = 0
protected

◆ m

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::m = 0
protected

shift m

◆ mu

template<typename RealType >
double randlib::GeneralGeometricStableDistribution< RealType >::mu = 0
protected

location μ


The documentation for this class was generated from the following file: