GClasses
GClasses::GBNVariable Class Referenceabstract

Detailed Description

The base class of nodes in a belief network that represent variable values.

#include <GBayesianNetwork.h>

Inheritance diagram for GClasses::GBNVariable:
GClasses::GBNNode GClasses::GBNCategorical GClasses::GBNMetropolisNode GClasses::GBNBeta GClasses::GBNExponential GClasses::GBNGamma GClasses::GBNInverseGamma GClasses::GBNLogNormal GClasses::GBNNormal GClasses::GBNPareto GClasses::GBNPoisson GClasses::GBNUniformContinuous GClasses::GBNUniformDiscrete

Public Member Functions

 GBNVariable ()
 
virtual ~GBNVariable ()
 
virtual void addCatParent (GBNCategorical *pNode, GBNNode *pDefaultVal)=0
 Adds a categorical node as a parent of this node. Calling this method will cause This node to resize its table of distribution parameters, so a default value is required to fill in new elements. Typically, you will set these new elements to something more meaningful after you call this method. More...
 
size_t catCount ()
 Returns the total number of combinations of categorical values supported by the categorical parents of this node. This node is expected to specify a distribution for each of these categorical combinations. More...
 
const std::vector< GBNVariable * > & children ()
 Returns all nodes that are known to depend on this one. More...
 
size_t currentCatIndex ()
 Queries the categorical parent nodes to determine their current values, and combines them to produce a single index value that is unique for this combination of categorical values. The value this returns will be from 0 to catCount()-1. The values are organized in little-endian manner. That is, it cycles through all values supported by the first categorical parent before moving on to the next value of the next parent. More...
 
virtual double currentValue ()=0
 Return the most recent value sampled from this node. More...
 
virtual double likelihood (double x)=0
 Compute the likelihood of drawing the value "x" from the distribution represented in this node given the current values in all of the parent nodes. If "x" is not a supported value, then this should return 0.0;. More...
 
virtual void onNewChild (GBNVariable *pChild)
 This method links back to the child node that just added this node as a parent. More...
 
virtual void sample (GRand *pRand)=0
 Draw a new Gibbs sample for this node given the current values of all other nodes it its Markov blanket. More...
 
void setObserved (double value)
 Set this node to an observed value. After calling this, subsequent calls to sample will not change its value. More...
 
void setUnobserved ()
 Set this node to an unobserved value. After calling this, subsequent calls to sample will draw new values for this node. More...
 
- Public Member Functions inherited from GClasses::GBNNode
 GBNNode ()
 
virtual ~GBNNode ()
 

Protected Attributes

std::vector< GBNCategorical * > m_catParents
 
std::vector< GBNVariable * > m_children
 
- Protected Attributes inherited from GClasses::GBNNode
bool m_observed
 
double m_observedValue
 

Constructor & Destructor Documentation

GClasses::GBNVariable::GBNVariable ( )
virtual GClasses::GBNVariable::~GBNVariable ( )
virtual

Member Function Documentation

virtual void GClasses::GBNVariable::addCatParent ( GBNCategorical pNode,
GBNNode pDefaultVal 
)
pure virtual

Adds a categorical node as a parent of this node. Calling this method will cause This node to resize its table of distribution parameters, so a default value is required to fill in new elements. Typically, you will set these new elements to something more meaningful after you call this method.

Implemented in GClasses::GBNInverseGamma, GClasses::GBNGamma, GClasses::GBNBeta, GClasses::GBNExponential, GClasses::GBNPoisson, GClasses::GBNUniformContinuous, GClasses::GBNUniformDiscrete, GClasses::GBNPareto, GClasses::GBNLogNormal, GClasses::GBNNormal, and GClasses::GBNCategorical.

size_t GClasses::GBNVariable::catCount ( )

Returns the total number of combinations of categorical values supported by the categorical parents of this node. This node is expected to specify a distribution for each of these categorical combinations.

const std::vector<GBNVariable*>& GClasses::GBNVariable::children ( )
inline

Returns all nodes that are known to depend on this one.

size_t GClasses::GBNVariable::currentCatIndex ( )

Queries the categorical parent nodes to determine their current values, and combines them to produce a single index value that is unique for this combination of categorical values. The value this returns will be from 0 to catCount()-1. The values are organized in little-endian manner. That is, it cycles through all values supported by the first categorical parent before moving on to the next value of the next parent.

virtual double GClasses::GBNVariable::currentValue ( )
pure virtual

Return the most recent value sampled from this node.

Implements GClasses::GBNNode.

Implemented in GClasses::GBNMetropolisNode, and GClasses::GBNCategorical.

virtual double GClasses::GBNVariable::likelihood ( double  x)
pure virtual

Compute the likelihood of drawing the value "x" from the distribution represented in this node given the current values in all of the parent nodes. If "x" is not a supported value, then this should return 0.0;.

Implemented in GClasses::GBNInverseGamma, GClasses::GBNGamma, GClasses::GBNBeta, GClasses::GBNExponential, GClasses::GBNPoisson, GClasses::GBNUniformContinuous, GClasses::GBNUniformDiscrete, GClasses::GBNPareto, GClasses::GBNLogNormal, GClasses::GBNNormal, and GClasses::GBNCategorical.

virtual void GClasses::GBNVariable::onNewChild ( GBNVariable pChild)
virtual

This method links back to the child node that just added this node as a parent.

Implements GClasses::GBNNode.

virtual void GClasses::GBNVariable::sample ( GRand pRand)
pure virtual

Draw a new Gibbs sample for this node given the current values of all other nodes it its Markov blanket.

Implemented in GClasses::GBNMetropolisNode, and GClasses::GBNCategorical.

void GClasses::GBNVariable::setObserved ( double  value)
inline

Set this node to an observed value. After calling this, subsequent calls to sample will not change its value.

void GClasses::GBNVariable::setUnobserved ( )
inline

Set this node to an unobserved value. After calling this, subsequent calls to sample will draw new values for this node.

Member Data Documentation

std::vector<GBNCategorical*> GClasses::GBNVariable::m_catParents
protected
std::vector<GBNVariable*> GClasses::GBNVariable::m_children
protected