GClasses
GClasses::GBayesNet Class Reference

Detailed Description

This class provides a platform for Bayesian belief networks. It allocates nodes in its own heap using placement new, so you don't have to worry about deleting the nodes. You can allocate your nodes manually and use them separately from this class if you want, but it is a lot easier if you use this class to manage it all.

#include <GBayesianNetwork.h>

Public Member Functions

 GBayesNet (size_t seed=0)
 General-purpose constructor. More...
 
 ~GBayesNet ()
 
GBNConstantdef ()
 Return a constant value that can be used as a default parameter for various nodes. More...
 
GBNBetanewBeta ()
 Return a pointer to a node that represents a Beta distribution. More...
 
GBNCategoricalnewCat (size_t categories)
 Return a pointer to a node that represents a categorical distribution. More...
 
GBNConstantnewConst (double val)
 Return a pointer to a node that represents a constant value. More...
 
GBNExponentialnewExponential ()
 Return a pointer to a node that represents an Exponential distribution. More...
 
GBNGammanewGamma ()
 Return a pointer to a node that represents a Gamma distribution. More...
 
GBNInverseGammanewInverseGamma ()
 Return a pointer to a node that represents an Inverse-Gamma distribution. More...
 
GBNLogNormalnewLogNormal ()
 Return a pointer to a node that represents a lognormal distribution. More...
 
GBNMathnewMath (GBNNode *pParent, GBNMath::math_op operation)
 Return a pointer to a node that sums all of its parent values. More...
 
GBNNormalnewNormal ()
 Return a pointer to a node that represents a normal distribution. More...
 
GBNParetonewPareto ()
 Return a pointer to a node that represents a Pareto distribution. More...
 
GBNPoissonnewPoisson ()
 Return a pointer to a node that represents a Poisson distribution. More...
 
GBNProductnewProduct ()
 Return a pointer to a node that sums all of its parent values. More...
 
GBNSumnewSum ()
 Return a pointer to a node that sums all of its parent values. More...
 
GBNUniformContinuousnewUniformContinuous ()
 Return a pointer to a node that represents a uniform continuous distribution. More...
 
GBNUniformDiscretenewUniformDiscrete ()
 Return a pointer to a node that represents a uniform discrete distribution. More...
 
GRandrand ()
 Returns a reference to the pseudo-random number generator used by this network. You might use this, for example, to change the random seed. More...
 
void sample ()
 Draw a Gibbs sample for each node in the graph in random order. More...
 

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if any tests fail. More...
 

Protected Attributes

GHeap m_heap
 
std::vector< GBNNode * > m_nodes
 
GBNConstantm_pConstOne
 
GRand m_rand
 
std::vector< GBNVariable * > m_sampleNodes
 

Constructor & Destructor Documentation

GClasses::GBayesNet::GBayesNet ( size_t  seed = 0)

General-purpose constructor.

GClasses::GBayesNet::~GBayesNet ( )

Member Function Documentation

GBNConstant* GClasses::GBayesNet::def ( )
inline

Return a constant value that can be used as a default parameter for various nodes.

GBNBeta* GClasses::GBayesNet::newBeta ( )

Return a pointer to a node that represents a Beta distribution.

GBNCategorical* GClasses::GBayesNet::newCat ( size_t  categories)

Return a pointer to a node that represents a categorical distribution.

GBNConstant* GClasses::GBayesNet::newConst ( double  val)

Return a pointer to a node that represents a constant value.

GBNExponential* GClasses::GBayesNet::newExponential ( )

Return a pointer to a node that represents an Exponential distribution.

GBNGamma* GClasses::GBayesNet::newGamma ( )

Return a pointer to a node that represents a Gamma distribution.

GBNInverseGamma* GClasses::GBayesNet::newInverseGamma ( )

Return a pointer to a node that represents an Inverse-Gamma distribution.

GBNLogNormal* GClasses::GBayesNet::newLogNormal ( )

Return a pointer to a node that represents a lognormal distribution.

GBNMath* GClasses::GBayesNet::newMath ( GBNNode pParent,
GBNMath::math_op  operation 
)

Return a pointer to a node that sums all of its parent values.

GBNNormal* GClasses::GBayesNet::newNormal ( )

Return a pointer to a node that represents a normal distribution.

GBNPareto* GClasses::GBayesNet::newPareto ( )

Return a pointer to a node that represents a Pareto distribution.

GBNPoisson* GClasses::GBayesNet::newPoisson ( )

Return a pointer to a node that represents a Poisson distribution.

GBNProduct* GClasses::GBayesNet::newProduct ( )

Return a pointer to a node that sums all of its parent values.

GBNSum* GClasses::GBayesNet::newSum ( )

Return a pointer to a node that sums all of its parent values.

GBNUniformContinuous* GClasses::GBayesNet::newUniformContinuous ( )

Return a pointer to a node that represents a uniform continuous distribution.

GBNUniformDiscrete* GClasses::GBayesNet::newUniformDiscrete ( )

Return a pointer to a node that represents a uniform discrete distribution.

GRand& GClasses::GBayesNet::rand ( )
inline

Returns a reference to the pseudo-random number generator used by this network. You might use this, for example, to change the random seed.

void GClasses::GBayesNet::sample ( )

Draw a Gibbs sample for each node in the graph in random order.

static void GClasses::GBayesNet::test ( )
static

Performs unit tests for this class. Throws an exception if any tests fail.

Member Data Documentation

GHeap GClasses::GBayesNet::m_heap
protected
std::vector<GBNNode*> GClasses::GBayesNet::m_nodes
protected
GBNConstant* GClasses::GBayesNet::m_pConstOne
protected
GRand GClasses::GBayesNet::m_rand
protected
std::vector<GBNVariable*> GClasses::GBayesNet::m_sampleNodes
protected