![]() |
aGrUM
0.16.0
|
#include <estimator.h>
Public Member Functions | |
Estimator () | |
Default constructor. More... | |
Estimator (const IBayesNet< GUM_SCALAR > *bn) | |
Constructor with Bayesian Network. More... | |
~Estimator () | |
GUM_SCALAR | confidence () |
computes the maximum length of confidence interval for each possible value of each variable More... | |
void | update (Instantiation I, GUM_SCALAR w) |
updates the estimator with a given sample More... | |
const Potential< GUM_SCALAR > & | posterior (const DiscreteVariable &var) |
returns the posterior of a node More... | |
void | clear () |
refresh the estimator state as empty More... | |
void | setFromBN (const IBayesNet< GUM_SCALAR > *bn, const NodeSet &hardEvidence) |
estimator initializing More... | |
void | setFromLBP (LoopyBeliefPropagation< GUM_SCALAR > *lbp, const NodeSet &hardEvidence, GUM_SCALAR virtualLBPSize) |
sets the estimatoor object with posteriors obtained by LoopyBeliefPropagation More... | |
Definition at line 40 of file estimator.h.
Estimator::Estimator | ( | ) |
Default constructor.
Definition at line 34 of file estimator_tpl.h.
|
explicit |
Constructor with Bayesian Network.
Definition at line 43 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_bn, gum::Estimator< GUM_SCALAR >::_estimator, gum::HashTable< Key, Val, Alloc >::insert(), gum::DAGmodel::nodes(), and gum::IBayesNet< GUM_SCALAR >::variable().
INLINE Estimator::~Estimator | ( | ) |
Definition at line 59 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::clear().
void Estimator::clear | ( | ) |
refresh the estimator state as empty
this function remove all the statistics in order to restart the computations.
Definition at line 186 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::__target_posteriors, gum::Estimator< GUM_SCALAR >::_estimator, gum::Estimator< GUM_SCALAR >::_ntotal, gum::Estimator< GUM_SCALAR >::_wtotal, and gum::HashTable< Key, Val, Alloc >::clear().
Referenced by gum::Estimator< GUM_SCALAR >::~Estimator().
GUM_SCALAR Estimator::confidence | ( | ) |
computes the maximum length of confidence interval for each possible value of each variable
Definition at line 171 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_estimator, gum::Estimator< GUM_SCALAR >::_ntotal, gum::HashTable< Key, Val, Alloc >::begin(), gum::HashTable< Key, Val, Alloc >::end(), and gum::Estimator< GUM_SCALAR >::variance().
|
private |
returns expected value of Bernouilli variable (called by it's name) of given parameter
name | variable's name, considered as a Bernouilli variable |
val | the parameter of the Bernouilli variable |
computes the amount of cumulative weights for paramater val over the amount of total cumulative weights
Definition at line 153 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_estimator, and gum::Estimator< GUM_SCALAR >::_wtotal.
Referenced by gum::Estimator< GUM_SCALAR >::variance().
const Potential< GUM_SCALAR > & Estimator::posterior | ( | const DiscreteVariable & | var | ) |
returns the posterior of a node
var | the variable node which we want posterior for |
returns the vector of cumulated weight bias for each value of the variable normalized as a CPT
NotFound | if variable node is not in estimator. |
Definition at line 129 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::__target_posteriors, gum::Estimator< GUM_SCALAR >::_estimator, gum::HashTable< Key, Val, Alloc >::exists(), gum::Potential< GUM_SCALAR >::fillWith(), GUM_ERROR, gum::Variable::name(), and gum::Potential< GUM_SCALAR >::normalize().
void Estimator::setFromBN | ( | const IBayesNet< GUM_SCALAR > * | bn, |
const NodeSet & | hardEvidence | ||
) |
estimator initializing
sets the estimator object with 0-filled vectors corresponding to each non evidence node
Definition at line 69 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_estimator, gum::Set< Key, Alloc >::contains(), gum::HashTable< Key, Val, Alloc >::exists(), gum::HashTable< Key, Val, Alloc >::insert(), gum::DAGmodel::nodes(), and gum::IBayesNet< GUM_SCALAR >::variable().
void Estimator::setFromLBP | ( | LoopyBeliefPropagation< GUM_SCALAR > * | lbp, |
const NodeSet & | hardEvidence, | ||
GUM_SCALAR | virtualLBPSize | ||
) |
sets the estimatoor object with posteriors obtained by LoopyBeliefPropagation
Definition at line 92 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_estimator, gum::Estimator< GUM_SCALAR >::_ntotal, gum::Estimator< GUM_SCALAR >::_wtotal, gum::BayesNetInference< GUM_SCALAR >::BN(), gum::Set< Key, Alloc >::contains(), gum::Instantiation::end(), gum::HashTable< Key, Val, Alloc >::insert(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), and gum::Instantiation::setFirst().
void Estimator::update | ( | Instantiation | I, |
GUM_SCALAR | w | ||
) |
updates the estimator with a given sample
I | the sample used to update the estimators |
weight | bias for the given sample |
adds the sample weight to each node's given value in the estimator
Definition at line 115 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::_estimator, gum::Estimator< GUM_SCALAR >::_ntotal, gum::Estimator< GUM_SCALAR >::_wtotal, gum::HashTable< Key, Val, Alloc >::exists(), gum::Variable::name(), gum::Instantiation::nbrDim(), gum::Instantiation::val(), and gum::Instantiation::variable().
|
private |
returns variance of Bernouilli variable (called by it's name) of given parameter
name | variable's name, considered as a Bernouilli variable |
val | the parameter of the Bernouilli variable |
computes variance for Bernouilli law using EV(name, val)
Definition at line 161 of file estimator_tpl.h.
References gum::Estimator< GUM_SCALAR >::EV().
Referenced by gum::Estimator< GUM_SCALAR >::confidence().
|
private |
the set of single posteriors computed during the last inference
the posteriors are owned by LazyPropagation.
Definition at line 158 of file estimator.h.
Referenced by gum::Estimator< GUM_SCALAR >::clear(), and gum::Estimator< GUM_SCALAR >::posterior().
|
private |
bayesian network on which approximation is done
Definition at line 128 of file estimator.h.
Referenced by gum::Estimator< GUM_SCALAR >::Estimator().
|
private |
estimator represented by hashtable between each variable name and a vector of cumulative sample weights
Definition at line 119 of file estimator.h.
Referenced by gum::Estimator< GUM_SCALAR >::clear(), gum::Estimator< GUM_SCALAR >::confidence(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::Estimator< GUM_SCALAR >::EV(), gum::Estimator< GUM_SCALAR >::posterior(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::Estimator< GUM_SCALAR >::setFromLBP(), and gum::Estimator< GUM_SCALAR >::update().
|
private |
number of generated samples
Definition at line 125 of file estimator.h.
Referenced by gum::Estimator< GUM_SCALAR >::clear(), gum::Estimator< GUM_SCALAR >::confidence(), gum::Estimator< GUM_SCALAR >::setFromLBP(), and gum::Estimator< GUM_SCALAR >::update().
|
private |
cumulated weights of all samples
Definition at line 122 of file estimator.h.
Referenced by gum::Estimator< GUM_SCALAR >::clear(), gum::Estimator< GUM_SCALAR >::EV(), gum::Estimator< GUM_SCALAR >::setFromLBP(), and gum::Estimator< GUM_SCALAR >::update().