52 template <
typename GUM_SCALAR >
60 template <
typename GUM_SCALAR >
71 template <
typename GUM_SCALAR >
80 template <
typename GUM_SCALAR >
100 template <
typename GUM_SCALAR >
103 GUM_SCALAR virtualLBPSize) {
104 for (
const auto& node: lbp->
BN().nodes()) {
106 std::vector< GUM_SCALAR > v;
111 v.push_back(p[inst] * virtualLBPSize);
123 template <
typename GUM_SCALAR >
135 template <
typename GUM_SCALAR >
137 Tensor< GUM_SCALAR >* p =
nullptr;
145 p =
new Tensor< GUM_SCALAR >();
157 template <
typename GUM_SCALAR >
164 template <
typename GUM_SCALAR >
166 GUM_SCALAR p =
EV(name, val);
173 template <
typename GUM_SCALAR >
175 GUM_SCALAR ic_max = 0;
178 for (
Idx i = 0; i < iter.val().size(); i++) {
179 GUM_SCALAR ic = GUM_SCALAR(2 * 1.96 * std::sqrt(
variance(iter.key(), i) / (
ntotal_ - 1)));
180 if (ic > ic_max) ic_max = ic;
187 template <
typename GUM_SCALAR >
virtual const IBayesNet< GUM_SCALAR > & BN() const final
Returns a constant reference over the IBayesNet referenced by this class.
const NodeGraphPart & nodes() const final
Returns a constant reference to the dag of this Bayes Net.
Base class for discrete random variable.
virtual Size domainSize() const =0
GUM_SCALAR wtotal_
cumulated weights of all samples
HashTable< std::string, std::vector< GUM_SCALAR > > estimator_
estimator represented by hashtable between each variable name and a vector of cumulative sample weigh...
void setFromLBP(LoopyBeliefPropagation< GUM_SCALAR > *lbp, const NodeSet &hardEvidence, GUM_SCALAR virtualLBPSize)
sets the estimatoor object with posteriors obtained by LoopyBeliefPropagation
GUM_SCALAR EV(std::string name, Idx val)
returns expected value of Bernouilli variable (called by it's name) of given parameter
void setFromBN(const IBayesNet< GUM_SCALAR > *bn, const NodeSet &hardEvidence)
estimator initializing
const IBayesNet< GUM_SCALAR > * bn_
Bayesian network on which approximation is done.
const Tensor< GUM_SCALAR > & posterior(const DiscreteVariable &var)
returns the posterior of a node
Estimator()
Default constructor.
void clear()
refresh the estimator state as empty
Size ntotal_
number of generated samples
void update(Instantiation I, GUM_SCALAR w)
updates the estimator with a given sample
HashTable< std::string, Tensor< GUM_SCALAR > * > _target_posteriors_
the set of single posteriors computed during the last inference
GUM_SCALAR confidence()
computes the maximum length of confidence interval for each possible value of each variable
GUM_SCALAR variance(std::string name, Idx val)
returns variance of Bernouilli variable (called by it's name) of given parameter
Class representing the minimal interface for Bayesian network with no numerical data.
virtual const DiscreteVariable & variable(NodeId id) const =0
Returns a constant reference over a variable given it's node id.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setFirst()
Assign the first values to the tuple of the Instantiation.
const DiscreteVariable & variable(Idx i) const final
Returns the variable at position i in the tuple.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
<agrum/BN/inference/loopyBeliefPropagation.h>
virtual const Tensor< GUM_SCALAR > & posterior(NodeId node)
Computes and returns the posterior of a node.
Unsafe iterator on the node set of a graph.
node_iterator begin() const noexcept
a begin iterator to parse the set of nodes contained in the NodeGraphPart
const node_iterator & end() const noexcept
the end iterator to parse the set of nodes contained in the NodeGraphPart
Exception : the element we looked for cannot be found.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities