![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
#include <estimator.h>
Public Member Functions | |
| Estimator () | |
| Default constructor. | |
| Estimator (const IBayesNet< GUM_SCALAR > *bn) | |
| Constructor with Bayesian network. | |
| ~Estimator () | |
| GUM_SCALAR | confidence () |
| computes the maximum length of confidence interval for each possible value of each variable | |
| void | update (Instantiation I, GUM_SCALAR w) |
| updates the estimator with a given sample | |
| const Tensor< GUM_SCALAR > & | posterior (const DiscreteVariable &var) |
| returns the posterior of a node | |
| void | clear () |
| refresh the estimator state as empty | |
| void | setFromBN (const IBayesNet< GUM_SCALAR > *bn, const NodeSet &hardEvidence) |
| estimator initializing | |
| void | setFromLBP (LoopyBeliefPropagation< GUM_SCALAR > *lbp, const NodeSet &hardEvidence, GUM_SCALAR virtualLBPSize) |
| sets the estimatoor object with posteriors obtained by LoopyBeliefPropagation | |
Private Member Functions | |
| GUM_SCALAR | EV (std::string name, Idx val) |
| returns expected value of Bernouilli variable (called by it's name) of given parameter | |
| GUM_SCALAR | variance (std::string name, Idx val) |
| returns variance of Bernouilli variable (called by it's name) of given parameter | |
Private Attributes | |
| HashTable< std::string, std::vector< GUM_SCALAR > > | estimator_ |
| estimator represented by hashtable between each variable name and a vector of cumulative sample weights | |
| GUM_SCALAR | wtotal_ |
| cumulated weights of all samples | |
| Size | ntotal_ |
| number of generated samples | |
| const IBayesNet< GUM_SCALAR > * | bn_ |
| Bayesian network on which approximation is done. | |
| HashTable< std::string, Tensor< GUM_SCALAR > * > | _target_posteriors_ |
| the set of single posteriors computed during the last inference | |
Definition at line 58 of file estimator.h.
| Estimator::Estimator | ( | ) |
Default constructor.
Definition at line 53 of file estimator_tpl.h.
References Estimator(), bn_, ntotal_, and wtotal_.
Referenced by Estimator(), Estimator(), and ~Estimator().
|
explicit |
Constructor with Bayesian network.
Definition at line 61 of file estimator_tpl.h.
References Estimator(), gum::NodeGraphPart::begin(), bn_, gum::DiscreteVariable::domainSize(), gum::NodeGraphPart::end(), estimator_, gum::Variable::name(), gum::DAGmodel::nodes(), and gum::IBayesNet< GUM_SCALAR >::variable().
| INLINE Estimator::~Estimator | ( | ) |
Definition at line 72 of file estimator_tpl.h.
References Estimator(), and 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 188 of file estimator_tpl.h.
References _target_posteriors_, estimator_, ntotal_, and wtotal_.
Referenced by ~Estimator().
| GUM_SCALAR Estimator::confidence | ( | ) |
computes the maximum length of confidence interval for each possible value of each variable
Definition at line 174 of file estimator_tpl.h.
References estimator_, ntotal_, and 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 158 of file estimator_tpl.h.
References estimator_, and wtotal_.
Referenced by variance().
| const Tensor< 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 136 of file estimator_tpl.h.
References _target_posteriors_, estimator_, GUM_ERROR, and gum::Variable::name().
| 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 81 of file estimator_tpl.h.
References gum::NodeGraphPart::begin(), gum::Set< Key >::contains(), gum::DiscreteVariable::domainSize(), gum::NodeGraphPart::end(), estimator_, gum::Variable::name(), 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 101 of file estimator_tpl.h.
References gum::BayesNetInference< GUM_SCALAR >::BN(), gum::Set< Key >::contains(), gum::Instantiation::end(), estimator_, ntotal_, gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), gum::Instantiation::setFirst(), and wtotal_.
| 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 124 of file estimator_tpl.h.
References estimator_, gum::Variable::name(), gum::Instantiation::nbrDim(), ntotal_, gum::Instantiation::val(), gum::Instantiation::variable(), and wtotal_.
|
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 165 of file estimator_tpl.h.
References EV().
Referenced by confidence().
|
private |
the set of single posteriors computed during the last inference
the posteriors are owned by LazyPropagation.
Definition at line 176 of file estimator.h.
Referenced by clear(), and posterior().
|
private |
Bayesian network on which approximation is done.
Definition at line 146 of file estimator.h.
Referenced by Estimator(), and Estimator().
|
private |
estimator represented by hashtable between each variable name and a vector of cumulative sample weights
Definition at line 137 of file estimator.h.
Referenced by Estimator(), clear(), confidence(), EV(), posterior(), setFromBN(), setFromLBP(), and update().
|
private |
number of generated samples
Definition at line 143 of file estimator.h.
Referenced by Estimator(), clear(), confidence(), setFromLBP(), and update().
|
private |
cumulated weights of all samples
Definition at line 140 of file estimator.h.
Referenced by Estimator(), clear(), EV(), setFromLBP(), and update().