shark::Cauchy< RngType > Class Template Reference

Cauchy distribution. More...

#include <shark/Rng/Cauchy.h>

+ Inheritance diagram for shark::Cauchy< RngType >:

Public Member Functions

 Cauchy (RngType &rng, double median=0, double sigma=1)
 Creates a new Cauchy random generator instance. More...
 
double operator() (double median, double sigma)
 creates a cauchy distributed number from parameters More...
 
double median () const
 returns the current median of the distribution More...
 
double sigma () const
 returns the width of the distribution More...
 
void median (double newMedian)
 
void sigma (double newSigma)
 
double p (double x) const
 

Detailed Description

template<typename RngType = shark::DefaultRngType>
class shark::Cauchy< RngType >

Cauchy distribution.

This class is a thin wrapper for the boost::cauchy_distribution class. The Cauchy distribution (aka "Lorentzian") is defined by:

\( f(x) = \frac{1}{\pi \sigma (1 + \left[\frac {(x-x_0)} \sigma\right]^2 )} \)


The Cauchy distribution is important as an example of a pathological case. The Cauchy distribution looks similar to a Normal distribution, but has much heavier tails. When studying hypothesis tests that assume normality, seeing how the tests perform on data from a Cauchy distribution is a good indicator of how sensitive the tests are to heavy-tail departures from normality. Likewise, it is a good check for robust techniques that are designed to work well under a wide variety of distributional assumptions.

Definition at line 65 of file Cauchy.h.

Constructor & Destructor Documentation

◆ Cauchy()

template<typename RngType = shark::DefaultRngType>
shark::Cauchy< RngType >::Cauchy ( RngType &  rng,
double  median = 0,
double  sigma = 1 
)
inline

Creates a new Cauchy random generator instance.

Parameters
medianthe median of the distribution
sigmathe width of the distribution
rngthe used random number generator

Definition at line 78 of file Cauchy.h.

Member Function Documentation

◆ median() [1/2]

template<typename RngType = shark::DefaultRngType>
double shark::Cauchy< RngType >::median ( ) const
inline

returns the current median of the distribution

Definition at line 98 of file Cauchy.h.

Referenced by shark::Cauchy< RngType >::p(), and shark::Cauchy< RngType >::sigma().

◆ median() [2/2]

template<typename RngType = shark::DefaultRngType>
void shark::Cauchy< RngType >::median ( double  newMedian)
inline

sets the median of the distribution

Parameters
newMedianthe new value for the Median

Definition at line 110 of file Cauchy.h.

References shark::Cauchy< RngType >::sigma().

◆ operator()()

template<typename RngType = shark::DefaultRngType>
double shark::Cauchy< RngType >::operator() ( double  median,
double  sigma 
)
inline

creates a cauchy distributed number from parameters

Parameters
medianthe median of the distribution
sigmathe width of the distribution

Definition at line 91 of file Cauchy.h.

◆ p()

template<typename RngType = shark::DefaultRngType>
double shark::Cauchy< RngType >::p ( double  x) const
inline

Returns the probability for the occurrence of random number "x".

Parameters
xthe point for which to calculate the propability

Definition at line 122 of file Cauchy.h.

References shark::entropy(), shark::Cauchy< RngType >::median(), shark::Cauchy< RngType >::sigma(), and shark::sqr().

◆ sigma() [1/2]

template<typename RngType = shark::DefaultRngType>
double shark::Cauchy< RngType >::sigma ( ) const
inline

returns the width of the distribution

Definition at line 104 of file Cauchy.h.

Referenced by shark::Cauchy< RngType >::median(), and shark::Cauchy< RngType >::p().

◆ sigma() [2/2]

template<typename RngType = shark::DefaultRngType>
void shark::Cauchy< RngType >::sigma ( double  newSigma)
inline

sets the width of the distribution

Parameters
newSigmathe new value for sigma

Definition at line 116 of file Cauchy.h.

References shark::Cauchy< RngType >::median().


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