PLearn 0.1
|
#include <RandomVar.h>
Public Member Functions | |
JointRandomVariable (const RVArray &variables) | |
JointRandomVariable. | |
virtual char * | classname () |
void | setValueFromParentsValue () |
set the field value from the values of the parents | |
bool | invertible (const Var &obs, RVInstanceArray &unobserved_parents, Var **JacobianCorrection) |
functions specific to FunctionalRandomVariable's | |
void | EMBprop (const Vec obs, real post) |
Definition at line 1109 of file RandomVar.h.
PLearn::JointRandomVariable::JointRandomVariable | ( | const RVArray & | variables | ) |
Definition at line 1096 of file RandomVar.cc.
References PLERROR, and PLearn::TVec< T >::size().
:FunctionalRandomVariable(variables,variables.length()) { if (variables.size()==0) PLERROR("JointRandomVariables(RVArray) expects an array with >0 elements"); }
virtual char* PLearn::JointRandomVariable::classname | ( | ) | [inline, virtual] |
Implements PLearn::RandomVariable.
Definition at line 1114 of file RandomVar.h.
{ return "JointRandomVariable"; }
************ 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".
Implements PLearn::RandomVariable.
Definition at line 1130 of file RandomVar.cc.
References i, PLearn::RVArray::length(), PLearn::RandomVariable::parents, PLearn::TVec< T >::size(), and PLearn::TVec< T >::subVec().
{ int p=0; for (int i=0;i<parents.size();i++) { int l = parents[i]->length(); // watch for redundant computation! parents[i]->EMBprop(obs.subVec(p,l),posterior); p+=l; } }
bool PLearn::JointRandomVariable::invertible | ( | const Var & | obs, |
RVInstanceArray & | unobserved_parents, | ||
Var ** | JacobianCorrection | ||
) | [virtual] |
functions specific to FunctionalRandomVariable's
!< SUBCLASS WRITERS: IMPLEMENT FUNCTIONS BELOW //!<
check whether it is possible to invert the function which maps the given unobserved parents to the observed value of the RV (obs). If invertible, do the inversion, and set the value fields of the RVInstances to Var's which are functionally dependent on obs. If the absolute value of the Jacobian of the map from the unobserved parents to this R.V.'s value is different from 1, then JacobianCorrection should point to a Var that is the logarithm of the determinant of this Jacobian (first derivatives) matrix. If the function is not invertible but it is possible to write P(Y==obs | unobserved_parents) in terms of the unobserved_parents logP functions, then the sub-class writer should instead redefine the logP function appropriately.
Reimplemented from PLearn::FunctionalRandomVariable.
Definition at line 1112 of file RandomVar.cc.
References i, PLearn::RVArray::length(), PLearn::RandomVariable::parents, PLERROR, PLearn::TVec< T >::size(), and PLearn::Var::subVec().
{ int p=0; int j=0; int nun=unobserved_parents.size(); for (int i=0;i<parents.size();i++) { if (j==nun) PLERROR("JointRandomVariable::invertible ==> logic error"); int l = parents[i]->length(); if (unobserved_parents[j].V==parents[i]) unobserved_parents[j++].v = obs->subVec(p,l); p+=l; } return true; }
void PLearn::JointRandomVariable::setValueFromParentsValue | ( | ) | [virtual] |
set the field value from the values of the parents
Implements PLearn::FunctionalRandomVariable.
Definition at line 1103 of file RandomVar.cc.
References PLearn::RandomVariable::marked, PLearn::RandomVariable::parents, PLearn::TVec< T >::size(), PLearn::RandomVariable::value, and PLearn::vconcat().
{ if (marked) return; VarArray values(parents.size()); for (int i=0;i<parents.size();i++) values[i]=parents[i]->value; value = vconcat(values); }