shark::AbstractDistribution Class Referenceabstract

Abstract class for distributions. More...

#include <shark/Rng/AbstractDistribution.h>

+ Inheritance diagram for shark::AbstractDistribution:

Public Member Functions

virtual ~AbstractDistribution ()
 Dtor. More...
 
virtual double p (double x) const =0
 
virtual double logP (double x) const
 

Detailed Description

Abstract class for distributions.

Definition at line 44 of file AbstractDistribution.h.

Constructor & Destructor Documentation

◆ ~AbstractDistribution()

virtual shark::AbstractDistribution::~AbstractDistribution ( )
inlinevirtual

Dtor.

Definition at line 48 of file AbstractDistribution.h.

References p().

Member Function Documentation

◆ logP()

virtual double shark::AbstractDistribution::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 in shark::Normal< RngType >, and shark::Normal< Rng::rng_type >.

Definition at line 64 of file AbstractDistribution.h.

References p(), and shark::safeLog().

◆ p()

virtual double shark::AbstractDistribution::p ( double  x) const
pure virtual

Calculate probability for a given input

Parameters
xthe input for calculating probability
Returns
probability of input

Implemented in shark::Uniform< RngType >, shark::Normal< RngType >, and shark::Normal< Rng::rng_type >.

Referenced by logP(), and ~AbstractDistribution().


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