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

The BivariateNormalRand class
Bivariate Gaussian (normal) distribution. More...

#include <bivariate_normal.hpp>

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

Public Member Functions

 BivariateNormalRand (double location1, double location2, double scale1, double scale2, double correlation)
 
std::string Name () const override
 
void SetLocations (double location1, double location2)
 
void SetCovariance (double scale1, double scale2, double correlation)
 
DoublePair GetLocation ()
 
double GetFirstLocation () const noexcept
 
double GetSecondLocation () const noexcept
 
double GetFirstScale () const noexcept
 
double GetSecondScale () const noexcept
 
double GetCorrelation () const noexcept
 
double f (const Pair< RealType > &point) const override
 
double logf (const Pair< RealType > &point) const override
 
double F (const Pair< RealType > &point) const override
 
template<std::uniform_random_bit_generator G>
Pair< RealType > operator() (G &g) const
 
long double Correlation () const override
 
Pair< RealType > Mode () const override
 
- Public Member Functions inherited from randlib::ContinuousBivariateDistribution< NormalRand< RealType >, NormalRand< RealType >, RealType >
virtual ~ContinuousBivariateDistribution ()
 
- Public Member Functions inherited from randlib::BivariateDistribution< T1, T2, T >
virtual ~BivariateDistribution ()
 
Pair< T > MinValue () const override
 
Pair< T > MaxValue () const override
 
virtual LongDoublePair Mean () const final
 
virtual LongDoubleTriplet Covariance () const final
 
virtual std::pair< T1, T2 > GetMarginalDistributions () const final
 
- Public Member Functions inherited from randlib::ProbabilityDistribution< Pair< T > >
virtual ~ProbabilityDistribution ()=default
 
virtual double F (const Pair< T > &x) const=0
 
void CumulativeDistributionFunction (std::span< const Pair< T > > x, std::span< double > y) const
 
virtual double S (const Pair< T > &x) const
 
void SurvivalFunction (std::span< const Pair< T > > x, std::span< double > y) const
 
Pair< T > operator() (G &g) const
 Draws a variate with the given engine through the virtual interface.
 
Pair< 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< Pair< T > > outputData) const
 Fills the output with variates drawn with the engine of this object.
 
void Sample (G &g, std::span< Pair< T > > outputData) const
 Fills the output with variates drawn with the given engine.
 
void Reseed (std::uint64_t seed)
 

Additional Inherited Members

- Public Types inherited from randlib::ProbabilityDistribution< Pair< T > >
using value_type = Pair< T >
 
- Protected Member Functions inherited from randlib::ContinuousBivariateDistribution< NormalRand< RealType >, NormalRand< RealType >, RealType >
 ContinuousBivariateDistribution ()
 
- Protected Member Functions inherited from randlib::BivariateDistribution< T1, T2, T >
 BivariateDistribution ()
 
- Protected Member Functions inherited from randlib::ProbabilityDistribution< Pair< 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< Pair< 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 inherited from randlib::BivariateDistribution< T1, T2, T >
T1 X {}
 1st marginal distributions
 
T2 Y {}
 2nd marginal distributions
 
- Static Protected Attributes inherited from randlib::ProbabilityDistribution< Pair< T > >
static constexpr size_t 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 []
 
static constexpr char NON_NEGATIVITY_VIOLATION []
 
static constexpr char UPPER_LIMIT_VIOLATION []
 
static constexpr char LOWER_LIMIT_VIOLATION []
 

Detailed Description

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

The BivariateNormalRand class
Bivariate Gaussian (normal) distribution.

Notation: X ~ N(μ1, μ2, σ1, ρ, σ2)

Constructor & Destructor Documentation

◆ BivariateNormalRand()

template<typename RealType >
randlib::BivariateNormalRand< RealType >::BivariateNormalRand ( double  location1,
double  location2,
double  scale1,
double  scale2,
double  correlation 
)

Member Function Documentation

◆ Correlation()

template<typename RealType >
long double randlib::BivariateNormalRand< RealType >::Correlation ( ) const
overridevirtual

◆ f()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::f ( const Pair< RealType > &  point) const
overridevirtual

◆ F()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::F ( const Pair< RealType > &  point) const
override

F(x, y) = F(x)F(y)

Unnumbered equation between (3) and (4) in Section 2.2 of Genz (2004), integrating in terms of theta between asin(ρ) and +/- π/2

Integrand is exp(-(x^2 + y^2 - 2xysin(θ)) / (2cos(θ)^2))

◆ GetCorrelation()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::GetCorrelation ( ) const
inlinenoexcept

◆ GetFirstLocation()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::GetFirstLocation ( ) const
inlinenoexcept

◆ GetFirstScale()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::GetFirstScale ( ) const
inlinenoexcept

◆ GetLocation()

template<typename RealType >
DoublePair randlib::BivariateNormalRand< RealType >::GetLocation ( )
inline

◆ GetSecondLocation()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::GetSecondLocation ( ) const
inlinenoexcept

◆ GetSecondScale()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::GetSecondScale ( ) const
inlinenoexcept

◆ logf()

template<typename RealType >
double randlib::BivariateNormalRand< RealType >::logf ( const Pair< RealType > &  point) const
overridevirtual

log(f(x, y)) = log(f(x)) + log(f(y))

log(f(x, y)) = log(δ(xAdj - yAdj))

log(f(x, y)) = log(δ(xAdj + yAdj))

Implements randlib::ContinuousBivariateDistribution< NormalRand< RealType >, NormalRand< RealType >, RealType >.

◆ Mode()

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

◆ Name()

template<typename RealType >
std::string randlib::BivariateNormalRand< RealType >::Name ( ) const
overridevirtual
Returns
title of distribution, for instance "Normal(0, 1)"

Implements randlib::ProbabilityDistribution< Pair< T > >.

◆ operator()()

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

◆ SetCovariance()

template<typename RealType >
void randlib::BivariateNormalRand< RealType >::SetCovariance ( double  scale1,
double  scale2,
double  correlation 
)

◆ SetLocations()

template<typename RealType >
void randlib::BivariateNormalRand< RealType >::SetLocations ( double  location1,
double  location2 
)

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