#include <RandomVar.h>
Inheritance diagram for PLearn::RandomVariable:
Public Member Functions | |
RandomVariable (int thelength, int thewidth=1) | |
All these constructors give rise to a RV with no parents. | |
RandomVariable (const Vec &the_value) | |
RandomVariable (const Mat &the_value) | |
RandomVariable (const Var &the_value) | |
RandomVariable (const RVArray &parents, int thelength) | |
these constructors give rise to a RV with parents | |
RandomVariable (const RVArray &parents, int thelength, int thewidth) | |
virtual char * | classname ()=0 |
virtual int | length () |
virtual int | width () |
int | nelems () |
bool | isScalar () |
bool | isVec () |
bool | isColumnVec () |
bool | isRowVec () |
virtual bool | isNonRandom ()=0 |
bool | isConstant () |
non-random is not the same thing as constant: (a Var is constant if it does not depend on other vars) | |
virtual bool | isDiscrete ()=0 |
true if a discrete random variable, false otherwise. | |
RandomVar | subVec (int start, int length) |
virtual void | setValueFromParentsValue ()=0 |
void | markRHSandSetKnownValues (const RVInstanceArray &RHS) |
virtual void | EMBprop (const Vec obs, real posterior)=0 |
virtual void | EMUpdate () |
virtual bool | canStopEM () |
virtual void | EMTrainingInitialize (const RVArray ¶meters_to_learn) |
Initialization of EM training (before all the iterations start). | |
virtual void | EMEpochInitialize () |
Initialization of an individual EMEpoch. | |
virtual void | mark (Var v) |
!< ALL BELOW THIS IS NOT NECESSARY FOR ORDINARY USERS OR SUBCLASS WRITERS //!< | |
virtual void | mark () |
virtual void | unmark () |
virtual void | clearEMmarks () |
virtual void | unmarkAncestors () |
clear not only the marked field but also that of parents | |
virtual bool | isMarked () |
virtual void | setKnownValues () |
virtual Var | logP (const Var &obs, const RVInstanceArray &RHS, RVInstanceArray *parameters_to_learn=0)=0 |
virtual Var | P (const Var &obs, const RVInstanceArray &RHS) |
virtual Var | ElogP (const Var &obs, RVArray ¶meters_to_learn, const RVInstanceArray &RHS) |
virtual real | EM (const RVArray ¶meters_to_learn, VarArray &prop_path, VarArray &observedVars, VMat distr, int n_samples, int max_n_iterations, real relative_improvement_threshold, bool accept_worsening_likelihood=false) |
virtual real | epoch (VarArray &prop_path, VarArray &observed_vars, const VMat &distr, int n_samples, bool do_EM_learning=true) |
virtual | ~RandomVariable () |
Public Attributes | |
const RVArray | parents |
other random variables, whose value give rise | |
Var | value |
used either when marked, non-random, or to assess P(This=value) | |
Protected Attributes | |
const int | rv_number |
takes the value rv_counter upon construction | |
bool | marked |
bool | EMmark |
mark used by EM to avoid repeated calls to EMBprop/EMUpdate | |
bool | pmark |
yet another mark | |
bool * | learn_the_parameters |
learn_the_parameters[i] says if parent[i] should be learned in the current call to EM (as a parameter of the distribution). | |
Static Private Attributes | |
int | rv_counter = 0 |
RandomVariable *. |
|
All these constructors give rise to a RV with no parents.
Definition at line 184 of file RandomVar.cc. |
|
Definition at line 190 of file RandomVar.cc. References PLearn::Vec. |
|
Definition at line 196 of file RandomVar.cc. References PLearn::Mat. |
|
Definition at line 202 of file RandomVar.cc. |
|
these constructors give rise to a RV with parents
Definition at line 208 of file RandomVar.cc. |
|
Definition at line 215 of file RandomVar.cc. |
|
Definition at line 396 of file RandomVar.cc. References learn_the_parameters. |
|
Has the distribution seen enough EM iterations to meaningfully stop EM iterative training? This is a way for a RandomVariable sub-class to force continuation of the EM iterations beyond the criteria given by the caller of EM. the default just propagates to the unmarked parents. Reimplemented in PLearn::MixtureRandomVariable. Definition at line 348 of file RandomVar.cc. References parents, and PLearn::TVec< RandomVar >::size(). Referenced by EM(). |
|
|
Reimplemented in PLearn::MixtureRandomVariable. Definition at line 313 of file RandomVar.cc. References EMmark, parents, and PLearn::TVec< RandomVar >::size(). |
|
the latter is like logP but it represents the expected log-probability of obs given the RHS, where the expectation is over the "hidden" random variables of EM in mixtures, as a function of the values of the parameters_to_learn. Definition at line 399 of file RandomVar.cc. References classname(), and PLERROR. |
|
NOTE NOTE NOTE: THE ORDER OF THE VALUES IN THE DISTRIBUTION MUST BE: (1) conditioning variables (RHS), (2) output variables Definition at line 229 of file RandomVar.cc. References canStopEM(), clearEMmarks(), EMTrainingInitialize(), PLearn::endl(), and epoch(). |
|
************ EM STUFF ********** propagate posterior information to parents in order to perform an EMupdate at the end of an EMEpoch. In the case of mixture-like RVs and their components, the posterior is the probability of the component "this" given the observation "obs". Implemented in PLearn::NonRandomVariable, PLearn::JointRandomVariable, PLearn::RandomElementOfRandomVariable, PLearn::RVArrayRandomElementRandomVariable, PLearn::NegRandomVariable, PLearn::ExpRandomVariable, PLearn::LogRandomVariable, PLearn::DiagonalNormalRandomVariable, PLearn::MixtureRandomVariable, PLearn::PlusRandomVariable, PLearn::MinusRandomVariable, PLearn::ElementWiseDivisionRandomVariable, PLearn::ProductRandomVariable, PLearn::SubVecRandomVariable, PLearn::MultinomialRandomVariable, PLearn::ExtendedRandomVariable, and PLearn::ConcatColumnsRandomVariable. Referenced by epoch(). |
|
Initialization of an individual EMEpoch. the default just propagates to the unmarked parents Reimplemented in PLearn::DiagonalNormalRandomVariable, PLearn::MixtureRandomVariable, PLearn::PlusRandomVariable, PLearn::MinusRandomVariable, PLearn::ElementWiseDivisionRandomVariable, PLearn::ProductRandomVariable, and PLearn::MultinomialRandomVariable. Definition at line 384 of file RandomVar.cc. References EMmark, parents, and PLearn::TVec< RandomVar >::size(). Referenced by epoch(). |
|
Initialization of EM training (before all the iterations start). the default just propagates to the unmarked parents Reimplemented in PLearn::MixtureRandomVariable, PLearn::PlusRandomVariable, PLearn::MinusRandomVariable, PLearn::ElementWiseDivisionRandomVariable, and PLearn::ProductRandomVariable. Definition at line 358 of file RandomVar.cc. References PLearn::TVec< RandomVar >::contains(), EMmark, learn_the_parameters, parents, PLERROR, and PLearn::TVec< RandomVar >::size(). Referenced by EM(). |
|
update the fixed (non-random) parameters using internal learning mechanism, at end of an EMEpoch. the default just propagates to the unmarked parents. Reimplemented in PLearn::DiagonalNormalRandomVariable, PLearn::MixtureRandomVariable, PLearn::PlusRandomVariable, PLearn::MinusRandomVariable, PLearn::ElementWiseDivisionRandomVariable, PLearn::ProductRandomVariable, and PLearn::MultinomialRandomVariable. Definition at line 340 of file RandomVar.cc. References EMmark, parents, and PLearn::TVec< RandomVar >::size(). Referenced by epoch(). |
|
Do one iteration of EM or compute the likelihood of the given data. This method should not be redefined for most types of random variables, but it may be necessary for things like sequential data. This method can be used for doing one epoch of EM (do_EM_learning=true) or simply for computing the likelihood, if do_EM_learning=false. Definition at line 260 of file RandomVar.cc. References clearEMmarks(), EMBprop(), EMEpochInitialize(), EMUpdate(), PLearn::endl(), PLearn::VarArray::fprop(), PLearn::TVec< Var >::last(), PLearn::VarArray::printInfo(), and PLearn::VMat::width(). Referenced by EM(). |
|
Definition at line 600 of file RandomVar.h. References width(). |
|
non-random is not the same thing as constant: (a Var is constant if it does not depend on other vars)
Definition at line 612 of file RandomVar.h. References isNonRandom(), and value. |
|
true if a discrete random variable, false otherwise. Most of the RVs of interest here are continuous, so this is the default. Implemented in PLearn::StochasticRandomVariable, PLearn::FunctionalRandomVariable, PLearn::MixtureRandomVariable, and PLearn::MultinomialRandomVariable. |
|
Definition at line 690 of file RandomVar.h. References marked. |
|
Random means that its value cannot be known deterministically. Note that StochasticRandomVariable's are never non-random, but a FunctionalRandomVariable is non-random if it has no parents (i.e. it is a NonRandomVariable) or if all its parents are non-random. Implemented in PLearn::StochasticRandomVariable, and PLearn::FunctionalRandomVariable. Referenced by isConstant(). |
|
Definition at line 601 of file RandomVar.h. References length(). |
|
Definition at line 598 of file RandomVar.h. |
|
Definition at line 599 of file RandomVar.h. |
|
Definition at line 595 of file RandomVar.h. References PLearn::Var::length(), and value. Referenced by PLearn::SubVecRandomVariable::EMBprop(), PLearn::DiagonalNormalRandomVariable::EMBprop(), PLearn::SubVecRandomVariable::invertible(), isRowVec(), isScalar(), isVec(), PLearn::FunctionalRandomVariable::logP(), and PLearn::RVArrayRandomElementRandomVariable::RVArrayRandomElementRandomVariable(). |
|
Construct a Var that computes logP(This = obs | RHS ). This function SHOULD NOT be used directly, but is called by the global function logP (same argument), which does proper massaging of the network before and after this call. Implemented in PLearn::FunctionalRandomVariable, PLearn::RVArrayRandomElementRandomVariable, PLearn::DiagonalNormalRandomVariable, PLearn::MixtureRandomVariable, and PLearn::MultinomialRandomVariable. |
|
Definition at line 683 of file RandomVar.h. References marked. |
|
!< ALL BELOW THIS IS NOT NECESSARY FOR ORDINARY USERS OR SUBCLASS WRITERS //!<
Definition at line 682 of file RandomVar.h. |
|
Definition at line 640 of file RandomVar.h. References markRHSandSetKnownValues(), setKnownValues(), and PLearn::TVec< RVInstance >::size(). Referenced by markRHSandSetKnownValues(). |
|
Definition at line 597 of file RandomVar.h. References value. |
|
Definition at line 392 of file RandomVar.cc. References PLearn::exp(), and PLearn::logP(). |
|
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 in PLearn::StochasticRandomVariable, and PLearn::MixtureRandomVariable. Definition at line 323 of file RandomVar.cc. References marked, parents, pmark, setValueFromParentsValue(), and PLearn::TVec< RandomVar >::size(). Referenced by markRHSandSetKnownValues(). |
|
define the formula that gives a value to this RV given its parent's value (sets the value field). If the RV is stochastic, the formula may also be "stochastic" (using SampleVariable's to define the Var). Implemented in PLearn::FunctionalRandomVariable, PLearn::NonRandomVariable, PLearn::JointRandomVariable, PLearn::RandomElementOfRandomVariable, PLearn::RVArrayRandomElementRandomVariable, PLearn::NegRandomVariable, PLearn::ExpRandomVariable, PLearn::LogRandomVariable, PLearn::DiagonalNormalRandomVariable, PLearn::MixtureRandomVariable, PLearn::PlusRandomVariable, PLearn::MinusRandomVariable, PLearn::ElementWiseDivisionRandomVariable, PLearn::ProductRandomVariable, PLearn::SubVecRandomVariable, PLearn::MultinomialRandomVariable, PLearn::ExtendedRandomVariable, and PLearn::ConcatColumnsRandomVariable. Referenced by PLearn::StochasticRandomVariable::setKnownValues(), and setKnownValues(). |
|
Return a new RandomVar which is obtained by extracting a sub-vector of length "length" from the value of this, starting at position "start". Definition at line 225 of file RandomVar.cc. |
|
Definition at line 684 of file RandomVar.h. References marked. |
|
clear not only the marked field but also that of parents
Reimplemented in PLearn::MixtureRandomVariable. Definition at line 302 of file RandomVar.cc. References marked, parents, pmark, and PLearn::TVec< RandomVar >::size(). |
|
Definition at line 596 of file RandomVar.h. References value, and PLearn::Var::width(). Referenced by isColumnVec(), isScalar(), and isVec(). |
|
mark used by EM to avoid repeated calls to EMBprop/EMUpdate
Definition at line 576 of file RandomVar.h. Referenced by clearEMmarks(), EMEpochInitialize(), EMTrainingInitialize(), and EMUpdate(). |
|
learn_the_parameters[i] says if parent[i] should be learned in the current call to EM (as a parameter of the distribution).
Definition at line 581 of file RandomVar.h. Referenced by EMTrainingInitialize(), and ~RandomVariable(). |
|
temporary used in various procedures that traverse the graphical model. For example, for logP it means "conditionally non-random". Definition at line 574 of file RandomVar.h. Referenced by isMarked(), mark(), setKnownValues(), unmark(), and unmarkAncestors(). |
|
other random variables, whose value give rise
Definition at line 561 of file RandomVar.h. Referenced by canStopEM(), clearEMmarks(), EMEpochInitialize(), EMTrainingInitialize(), EMUpdate(), setKnownValues(), and unmarkAncestors(). |
|
yet another mark
Definition at line 577 of file RandomVar.h. Referenced by setKnownValues(), and unmarkAncestors(). |
|
Definition at line 182 of file RandomVar.cc. |
|
takes the value rv_counter upon construction
Definition at line 558 of file RandomVar.h. |
|
used either when marked, non-random, or to assess P(This=value) stochastically or deterministically to this value. This field basically defines the NETWORK of the model. Note that this oriented graphical model must not have cycles. Definition at line 567 of file RandomVar.h. Referenced by isConstant(), length(), mark(), nelems(), and width(). |