PLearn 0.1
|
#include <RandomVar.h>
Public Member Functions | |
StochasticRandomVariable (int length=1) | |
StochasticRandomVariable. | |
StochasticRandomVariable (const RVArray ¶ms, int length) | |
StochasticRandomVariable (const RVArray ¶ms, int length, int width) | |
virtual bool | isNonRandom () |
define RandomVariable functions | |
virtual bool | isDiscrete () |
most common default | |
virtual void | setKnownValues () |
There are two main types of random variables: (1) StochasticRandomVariables: represents an unconditional "stochastic" distribution. e.g., NormalRV, ExponentialRV, UniformRV, etc... but that also includes such building bloks as the EmpiricalRV (whose density is a weighted sum of diracs). Uncertainty even parents are given ==> Stochastic. (2) FunctionalRandomVariables: represents a RV that is a deterministic function of other RVs, e.g., the sum, mixture, product, exponential, etc... of parent RVs. A FunctionalRandomVariable, unlike a StochasticRandomVariable, can be nonRandom() if its parents are non-random (or if it has no parents).
A StochasticRandomVariable represents a "stochastic" distribution. Most "ordinary" distributions are of this type. Its parameters are its parents (which can be random or not). A StochasticRandomVariable can NEVER be random, even when its parents are non-random. Some sub-classes of StochasticRandomVariable can be defined which have no RandomVar parameters (i.e., no parents).
Definition at line 961 of file RandomVar.h.
PLearn::StochasticRandomVariable::StochasticRandomVariable | ( | int | length = 1 | ) |
Definition at line 948 of file RandomVar.cc.
:RandomVariable(parameters,length) {}
PLearn::StochasticRandomVariable::StochasticRandomVariable | ( | const RVArray & | params, |
int | length, | ||
int | width | ||
) |
Definition at line 953 of file RandomVar.cc.
:RandomVariable(parameters,length,width) { }
virtual bool PLearn::StochasticRandomVariable::isDiscrete | ( | ) | [inline, virtual] |
most common default
Implements PLearn::RandomVariable.
Reimplemented in PLearn::MixtureRandomVariable, and PLearn::MultinomialRandomVariable.
Definition at line 974 of file RandomVar.h.
{ return false; }
virtual bool PLearn::StochasticRandomVariable::isNonRandom | ( | ) | [inline, virtual] |
define RandomVariable functions
the only exception to this default would be a dirac distribution
Implements PLearn::RandomVariable.
Definition at line 971 of file RandomVar.h.
Referenced by setKnownValues().
{ return false; }
void PLearn::StochasticRandomVariable::setKnownValues | ( | ) | [virtual] |
traverse the graph of ancestors of this node and mark nodes which are deterministic descendents of marked nodes while setting their "value" field as a function of their parents.
Reimplemented from PLearn::RandomVariable.
Reimplemented in PLearn::MixtureRandomVariable.
Definition at line 959 of file RandomVar.cc.
References isNonRandom(), PLearn::RandomVariable::marked, PLearn::RandomVariable::parents, PLearn::RandomVariable::pmark, PLearn::RandomVariable::setValueFromParentsValue(), and PLearn::TVec< T >::size().
{ if (!marked && !pmark) { pmark=true; // a StochasticRandomVariable cannot be non-random // unless it is a "dirac" distribution (i.e., isNonRandom()==true). for (int i=0;i<parents.size();i++) parents[i]->setKnownValues(); setValueFromParentsValue(); if (isNonRandom()) marked=true; } }