Fleet  0.0.9
Inference in the LOT
Public Types | Public Member Functions | Public Attributes | List of all members
Bayesable< _datum_t, _data_t > Class Template Referenceabstract

#include <Bayesable.h>

Public Types

typedef _datum_t datum_t
 
typedef _data_t data_t
 

Public Member Functions

 Bayesable ()
 
virtual size_t hash () const =0
 
virtual std::string string (std::string prefix="") const =0
 
virtual double compute_prior ()=0
 Compute the prior – defaultly not defined. More...
 
virtual double compute_single_likelihood (const datum_t &datum)
 Compute the likelihood of a single data point. More...
 
virtual void clear_bayes ()
 
virtual double compute_likelihood (const data_t &data, const double breakout=-infinity)
 Compute the likelihood of a collection of data, by calling compute_single_likelihood on each. This stops if our likelihood falls below breakout. More...
 
virtual double compute_posterior (const data_t &data, const std::pair< double, double > breakoutpair=std::make_pair(-infinity, 1.0))
 Compute the posterior, by calling prior and likelihood. This includes only a little bit of fanciness, which is that if our prior is -inf, then we don't both computing the likelihood. More...
 
virtual double at_temperature (double t) const
 
virtual bool operator< (const Bayesable< datum_t, data_t > &l) const
 
virtual void print (std::string prefix="")
 

Public Attributes

double prior
 
double likelihood
 
double posterior
 
uintmax_t born
 
size_t born_chain_idx
 

Detailed Description

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
class Bayesable< _datum_t, _data_t >

Author
steven piantadosi
Date
29/01/20

Member Typedef Documentation

◆ data_t

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
typedef _data_t Bayesable< _datum_t, _data_t >::data_t

◆ datum_t

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
typedef _datum_t Bayesable< _datum_t, _data_t >::datum_t

Constructor & Destructor Documentation

◆ Bayesable()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
Bayesable< _datum_t, _data_t >::Bayesable ( )
inline

Member Function Documentation

◆ at_temperature()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual double Bayesable< _datum_t, _data_t >::at_temperature ( double  t) const
inlinevirtual

Return my posterior score at a given (likelihood) temperature

Parameters
t
Returns

◆ clear_bayes()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual void Bayesable< _datum_t, _data_t >::clear_bayes ( )
inlinevirtual

Zero by prior, likelihood, posterior

◆ compute_likelihood()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual double Bayesable< _datum_t, _data_t >::compute_likelihood ( const data_t data,
const double  breakout = -infinity 
)
inlinevirtual

Compute the likelihood of a collection of data, by calling compute_single_likelihood on each. This stops if our likelihood falls below breakout.

Parameters
data
breakout
Returns

Reimplemented in GrammarHypothesis< this_t, _HYP, datum_t, data_t >, MyHypothesis, MyHypothesis, VectorNormalHypothesis, VectorHalfNormalHypothesis, TNormalVariable<+[](float x) ->, and MyGrammarHypothesis.

◆ compute_posterior()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual double Bayesable< _datum_t, _data_t >::compute_posterior ( const data_t data,
const std::pair< double, double >  breakoutpair = std::make_pair(-infinity,1.0) 
)
inlinevirtual

Compute the posterior, by calling prior and likelihood. This includes only a little bit of fanciness, which is that if our prior is -inf, then we don't both computing the likelihood.

To understand breakout, look at MCMCChain.h and see how compute_posterior is called – the first term in breakout is (u + current.at_temperature(temperature) + fb), and the second is the temperature We have to pass in two pieces because the temperature only applies ot the likelihood. Note that when we use breakout in compute_likelihood, it is only for the likelihood temp.

NOTE: The order here is fixed to compute the prior first. This permits us to penalize the "prior" with something in the likelihood – for instance if we want to use a runtime prior that is computed as we run the likelihood

Parameters
data
breakout
Returns

◆ compute_prior()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual double Bayesable< _datum_t, _data_t >::compute_prior ( )
pure virtual

◆ compute_single_likelihood()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual double Bayesable< _datum_t, _data_t >::compute_single_likelihood ( const datum_t datum)
inlinevirtual

◆ hash()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual size_t Bayesable< _datum_t, _data_t >::hash ( ) const
pure virtual

◆ operator<()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual bool Bayesable< _datum_t, _data_t >::operator< ( const Bayesable< datum_t, data_t > &  l) const
inlinevirtual

Allow sorting of Bayesable hypotheses. We defaultly sort by posterior so that TopN works right. But we also need to be careful because std::set uses this to determine equality, so this also checks priors and then hashes.

Parameters
l
Returns

◆ print()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual void Bayesable< _datum_t, _data_t >::print ( std::string  prefix = "")
inlinevirtual

Default printing of a hypothesis includes its posterior, prior, likelihood, and quoted string version

Parameters
prefix

Reimplemented in GrammarHypothesis< this_t, _HYP, datum_t, data_t >, GrammarHypothesis< MyGrammarHypothesis, MyHypothesis, MyHumanDatum >, GrammarHypothesis< MyGrammarHypothesis, MyHypothesis >, MyHypothesis, MyHypothesis, MyHypothesis, and MyHypothesis.

◆ string()

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
virtual std::string Bayesable< _datum_t, _data_t >::string ( std::string  prefix = "") const
pure virtual

Member Data Documentation

◆ born

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
uintmax_t Bayesable< _datum_t, _data_t >::born

◆ born_chain_idx

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
size_t Bayesable< _datum_t, _data_t >::born_chain_idx

◆ likelihood

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
double Bayesable< _datum_t, _data_t >::likelihood

◆ posterior

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
double Bayesable< _datum_t, _data_t >::posterior

◆ prior

template<typename _datum_t, typename _data_t = std::vector<_datum_t>>
double Bayesable< _datum_t, _data_t >::prior

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