shark::Normal< RngType > Class Template Reference

Implements a univariate normal (Gaussian) distribution. More...

#include <shark/Rng/Normal.h>

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

Public Member Functions

 Normal (RngType &rng, double mean=0., double variance=1.)
 
double operator() (double mean, double variance)
 
double mean () const
 
double variance () const
 
void mean (double newMean)
 
void variance (double newVariance)
 
double p (double x) const
 
double logP (double x) const
 
- Public Member Functions inherited from shark::AbstractDistribution
virtual ~AbstractDistribution ()
 Dtor. More...
 

Detailed Description

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

Implements a univariate normal (Gaussian) distribution.

For backwards compatibility with older shark versions instead of the standard deviation sigma the variance=sigma^2 is used as argument.

Definition at line 52 of file Normal.h.

Constructor & Destructor Documentation

◆ Normal()

template<typename RngType = DefaultRngType>
shark::Normal< RngType >::Normal ( RngType &  rng,
double  mean = 0.,
double  variance = 1. 
)
inline

constructor

Parameters
rngrandom number generator
meanmean of distribution
variancevariance of distribution

Definition at line 65 of file Normal.h.

Member Function Documentation

◆ logP()

template<typename RngType = DefaultRngType>
double shark::Normal< RngType >::logP ( double  x) const
inlinevirtual

Calculate log(p(x))

std::log can get -inf before it returns NaN. shark::safeLog tries to save the day, however is not perfect. The only real solution is to implement a function logP inside the distributions which returns the energy of the state

Note
subclasses should implement their own version of this function instead of replying on the default implementation unless you are pretty sure what you are doing.
Parameters
xthe input for calculating log of probability
Returns
log of probability of input

Reimplemented from shark::AbstractDistribution.

Definition at line 103 of file Normal.h.

References shark::Normal< RngType >::mean(), shark::safeLog(), shark::sqr(), and shark::SQRT_2_PI.

◆ mean() [1/2]

template<typename RngType = DefaultRngType>
double shark::Normal< RngType >::mean ( ) const
inline

◆ mean() [2/2]

template<typename RngType = DefaultRngType>
void shark::Normal< RngType >::mean ( double  newMean)
inline

Definition at line 87 of file Normal.h.

◆ operator()()

template<typename RngType = DefaultRngType>
double shark::Normal< RngType >::operator() ( double  mean,
double  variance 
)
inline

Definition at line 71 of file Normal.h.

◆ p()

template<typename RngType = DefaultRngType>
double shark::Normal< RngType >::p ( double  x) const
inlinevirtual

Calculate probability for a given input

Parameters
xthe input for calculating probability
Returns
probability of input

Implements shark::AbstractDistribution.

Definition at line 97 of file Normal.h.

References shark::Normal< RngType >::mean(), shark::sqr(), and shark::SQRT_2_PI.

◆ variance() [1/2]

template<typename RngType = DefaultRngType>
double shark::Normal< RngType >::variance ( ) const
inline

Definition at line 82 of file Normal.h.

◆ variance() [2/2]

template<typename RngType = DefaultRngType>
void shark::Normal< RngType >::variance ( double  newVariance)
inline

Definition at line 92 of file Normal.h.

References shark::Normal< RngType >::mean().


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