GClasses
|
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 () | |
GBNConstant * | def () |
Return a constant value that can be used as a default parameter for various nodes. More... | |
GBNBeta * | newBeta () |
Return a pointer to a node that represents a Beta distribution. More... | |
GBNCategorical * | newCat (size_t categories) |
Return a pointer to a node that represents a categorical distribution. More... | |
GBNConstant * | newConst (double val) |
Return a pointer to a node that represents a constant value. More... | |
GBNExponential * | newExponential () |
Return a pointer to a node that represents an Exponential distribution. More... | |
GBNGamma * | newGamma () |
Return a pointer to a node that represents a Gamma distribution. More... | |
GBNInverseGamma * | newInverseGamma () |
Return a pointer to a node that represents an Inverse-Gamma distribution. More... | |
GBNLogNormal * | newLogNormal () |
Return a pointer to a node that represents a lognormal distribution. More... | |
GBNMath * | newMath (GBNNode *pParent, GBNMath::math_op operation) |
Return a pointer to a node that sums all of its parent values. More... | |
GBNNormal * | newNormal () |
Return a pointer to a node that represents a normal distribution. More... | |
GBNPareto * | newPareto () |
Return a pointer to a node that represents a Pareto distribution. More... | |
GBNPoisson * | newPoisson () |
Return a pointer to a node that represents a Poisson distribution. More... | |
GBNProduct * | newProduct () |
Return a pointer to a node that sums all of its parent values. More... | |
GBNSum * | newSum () |
Return a pointer to a node that sums all of its parent values. More... | |
GBNUniformContinuous * | newUniformContinuous () |
Return a pointer to a node that represents a uniform continuous distribution. More... | |
GBNUniformDiscrete * | newUniformDiscrete () |
Return a pointer to a node that represents a uniform discrete distribution. More... | |
GRand & | rand () |
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 |
GBNConstant * | m_pConstOne |
GRand | m_rand |
std::vector< GBNVariable * > | m_sampleNodes |
GClasses::GBayesNet::GBayesNet | ( | size_t | seed = 0 | ) |
General-purpose constructor.
GClasses::GBayesNet::~GBayesNet | ( | ) |
|
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.
|
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 |
Performs unit tests for this class. Throws an exception if any tests fail.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |