queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::MarkovChainPositionData< V > Class Template Reference

A templated class that represents a Markov Chain. More...

#include <MarkovChainPositionData.h>

Public Member Functions

Constructor/Destructor methods
 MarkovChainPositionData (const BaseEnvironment &env)
 Constructor 1. More...
 
 MarkovChainPositionData (const BaseEnvironment &env, const V &vecValues, bool outOfTargetSupport, double logLikelihood, double logTarget)
 Constructor 2. More...
 
 MarkovChainPositionData (const MarkovChainPositionData< V > &rhs)
 Constructor 3: copy. More...
 
 ~MarkovChainPositionData ()
 Destructor. More...
 
Set methods
MarkovChainPositionData< V > & operator= (const MarkovChainPositionData< V > &rhs)
 Assignment operator. More...
 
Statistical/Mathematical methods
const V & vecValues () const
 Values of the chain (vector); access to private attribute m_vecValues. More...
 
bool outOfTargetSupport () const
 Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport. More...
 
double logLikelihood () const
 Logarithm of the value of the likelihood; access to private attribute m_logLikelihood. More...
 
double logTarget () const
 Logarithm of the value of the target; access to private attribute m_logTarget. More...
 
void set (const V &vecValues, bool outOfTargetSupport, double logLikelihood, double logTarget)
 Sets the values of the chain. More...
 

Private Attributes

const BaseEnvironmentm_env
 
V * m_vecValues
 
bool m_outOfTargetSupport
 
double m_logLikelihood
 
double m_logTarget
 

I/O methods

void print (std::ostream &os) const
 TODO: Prints the Markov chain. More...
 
std::ostream & operator<< (std::ostream &os, const MarkovChainPositionData< V > &obj)
 

Detailed Description

template<class V = GslVector>
class QUESO::MarkovChainPositionData< V >

A templated class that represents a Markov Chain.

This class implements a Markov Chain. It contains important information about a position such as whether or not it is out of the target support and its logarithmic values of the likelihood and of the target, besides the position location. A Markov chain is collection of random variables {X_t}, where the index t runs through 0, 1, ..., having the property that, given the present, the future is conditionally independent of the past. For instance, a Markov chain is passed to the Metropolis-Hastings algorithm and on it is calculated the acceptance ration MetropolisHastingsSG::alpha().

Definition at line 49 of file MarkovChainPositionData.h.

Constructor & Destructor Documentation

template<class V >
QUESO::MarkovChainPositionData< V >::MarkovChainPositionData ( const BaseEnvironment env)

Constructor 1.

It allocates a new Markov chain, given the environment. All the other private attributes are either NULL, false or zero.

Definition at line 32 of file MarkovChainPositionData.C.

template<class V >
QUESO::MarkovChainPositionData< V >::MarkovChainPositionData ( const BaseEnvironment env,
const V &  vecValues,
bool  outOfTargetSupport,
double  logLikelihood,
double  logTarget 
)

Constructor 2.

It allocates a new Markov chain, and the vector vecValues, given the environment, the likelihood and target values and sets whether or not it is out of target support.

Definition at line 43 of file MarkovChainPositionData.C.

49  :
50  m_env (env),
51  m_vecValues (new V(vecValues)),
55 {
56 }
const V & vecValues() const
Values of the chain (vector); access to private attribute m_vecValues.
double logTarget() const
Logarithm of the value of the target; access to private attribute m_logTarget.
bool outOfTargetSupport() const
Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport...
double logLikelihood() const
Logarithm of the value of the likelihood; access to private attribute m_logLikelihood.
template<class V >
QUESO::MarkovChainPositionData< V >::MarkovChainPositionData ( const MarkovChainPositionData< V > &  rhs)

Constructor 3: copy.

The new Markov chain is a copy of rhs.

Definition at line 59 of file MarkovChainPositionData.C.

60  :
61  m_env (rhs.m_env ),
62  m_vecValues (new V(*rhs.m_vecValues )),
63  m_outOfTargetSupport(rhs.m_outOfTargetSupport),
64  m_logLikelihood (rhs.m_logLikelihood ),
65  m_logTarget (rhs.m_logTarget )
66 {
67 }

Destructor.

Definition at line 70 of file MarkovChainPositionData.C.

Member Function Documentation

template<class V >
double QUESO::MarkovChainPositionData< V >::logLikelihood ( ) const

Logarithm of the value of the likelihood; access to private attribute m_logLikelihood.

Definition at line 108 of file MarkovChainPositionData.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::generateFullChain().

109 {
110  return m_logLikelihood;
111 }
template<class V >
double QUESO::MarkovChainPositionData< V >::logTarget ( ) const

Logarithm of the value of the target; access to private attribute m_logTarget.

Definition at line 116 of file MarkovChainPositionData.C.

Referenced by QUESO::Algorithm< V, M >::acceptance_ratio(), and QUESO::MetropolisHastingsSG< P_V, P_M >::generateFullChain().

117 {
118  return m_logTarget;
119 }
template<class V >
MarkovChainPositionData< V > & QUESO::MarkovChainPositionData< V >::operator= ( const MarkovChainPositionData< V > &  rhs)

Assignment operator.

Definition at line 77 of file MarkovChainPositionData.C.

References QUESO::MarkovChainPositionData< V >::m_logLikelihood, QUESO::MarkovChainPositionData< V >::m_logTarget, QUESO::MarkovChainPositionData< V >::m_outOfTargetSupport, and QUESO::MarkovChainPositionData< V >::m_vecValues.

78 {
79  if (m_vecValues == NULL) m_vecValues = new V(*rhs.m_vecValues);
80  else *m_vecValues = *rhs.m_vecValues;
81  m_outOfTargetSupport = rhs.m_outOfTargetSupport;
82  m_logLikelihood = rhs.m_logLikelihood;
83  m_logTarget = rhs.m_logTarget;
84 
85  return *this;
86 }
template<class V >
bool QUESO::MarkovChainPositionData< V >::outOfTargetSupport ( ) const

Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport.

Definition at line 100 of file MarkovChainPositionData.C.

Referenced by QUESO::Algorithm< V, M >::acceptance_ratio().

101 {
102  return m_outOfTargetSupport;
103 }
template<class V = GslVector>
void QUESO::MarkovChainPositionData< V >::print ( std::ostream &  os) const

TODO: Prints the Markov chain.

Todo:
: implement me!
template<class V >
void QUESO::MarkovChainPositionData< V >::set ( const V &  vecValues,
bool  outOfTargetSupport,
double  logLikelihood,
double  logTarget 
)

Sets the values of the chain.

Definition at line 123 of file MarkovChainPositionData.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::delayedRejection().

128 {
129  if (m_vecValues == NULL) m_vecValues = new V(vecValues);
130  else *m_vecValues = vecValues;
134 
135  return;
136 }
const V & vecValues() const
Values of the chain (vector); access to private attribute m_vecValues.
double logTarget() const
Logarithm of the value of the target; access to private attribute m_logTarget.
bool outOfTargetSupport() const
Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport...
double logLikelihood() const
Logarithm of the value of the likelihood; access to private attribute m_logLikelihood.
template<class V >
const V & QUESO::MarkovChainPositionData< V >::vecValues ( ) const

Values of the chain (vector); access to private attribute m_vecValues.

Definition at line 91 of file MarkovChainPositionData.C.

Referenced by QUESO::Algorithm< V, M >::acceptance_ratio(), QUESO::MetropolisHastingsSG< P_V, P_M >::delayedRejection(), and QUESO::MetropolisHastingsSG< P_V, P_M >::generateFullChain().

92 {
93  queso_require_msg(m_vecValues, "m_vecValues is NULL");
94  return *m_vecValues;
95 }

Friends And Related Function Documentation

template<class V = GslVector>
std::ostream& operator<< ( std::ostream &  os,
const MarkovChainPositionData< V > &  obj 
)
friend

Definition at line 106 of file MarkovChainPositionData.h.

108  {
109  obj.print(os);
110 
111  return os;
112  }

Member Data Documentation

template<class V = GslVector>
const BaseEnvironment& QUESO::MarkovChainPositionData< V >::m_env
private

Definition at line 116 of file MarkovChainPositionData.h.

template<class V = GslVector>
double QUESO::MarkovChainPositionData< V >::m_logLikelihood
private
template<class V = GslVector>
double QUESO::MarkovChainPositionData< V >::m_logTarget
private
template<class V = GslVector>
bool QUESO::MarkovChainPositionData< V >::m_outOfTargetSupport
private
template<class V = GslVector>
V* QUESO::MarkovChainPositionData< V >::m_vecValues
private

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

Generated on Tue Jun 5 2018 19:49:33 for queso-0.57.1 by  doxygen 1.8.5