aGrUM  0.14.2
estimator.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_ESTIMATOR_H
27 #define GUM_ESTIMATOR_H
28 
29 #include <agrum/BN/IBayesNet.h>
31 #include <agrum/core/hashTable.h>
32 #include <vector>
33 
34 namespace gum {
35 
36  template < typename GUM_SCALAR >
37  class Estimator {
38  public:
50  Estimator();
51 
55  explicit Estimator(const IBayesNet< GUM_SCALAR >* bn);
56 
57  /* Destructor */
58  ~Estimator();
59 
68  void setFromBN(const IBayesNet< GUM_SCALAR >* bn, const NodeSet& hardEvidence);
69 
75  const NodeSet& hardEvidence,
76  GUM_SCALAR virtualLBPSize);
79 
84  GUM_SCALAR confidence();
85 
87 
93  void update(Instantiation I, GUM_SCALAR w);
94 
96 
106 
108 
111  void clear();
112 
113  private:
117 
119  GUM_SCALAR _wtotal;
120 
123 
126 
129 
138  GUM_SCALAR EV(std::string name, Idx val);
139 
142 
150  GUM_SCALAR variance(std::string name, Idx val); // variance corrigĂ©e
151 
152  private:
154 
156  };
157 
158 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
159  extern template class Estimator< double >;
160 #endif
161 
162 } // namespace gum
163 
165 #endif
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
void setFromBN(const IBayesNet< GUM_SCALAR > *bn, const NodeSet &hardEvidence)
estimator initializing
Definition: estimator_tpl.h:66
void clear()
refresh the estimator state as empty
This file contains gibbs sampling (for BNs) class definitions.
const Potential< GUM_SCALAR > & posterior(const DiscreteVariable &var)
returns the posterior of a node
HashTable< std::string, std::vector< GUM_SCALAR > > _estimator
estimator represented by hashtable between each variable name and a vector of cumulative sample weigh...
Definition: estimator.h:116
GUM_SCALAR _wtotal
cumulated weights of all samples
Definition: estimator.h:119
Size _ntotal
number of generated samples
Definition: estimator.h:122
Class representing Bayesian networks.
void update(Instantiation I, GUM_SCALAR w)
updates the estimator with a given sample
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:59
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
GUM_SCALAR EV(std::string name, Idx val)
returns expected value of Bernouilli variable (called by it&#39;s name) of given parameter ...
void setFromLBP(LoopyBeliefPropagation< GUM_SCALAR > *lbp, const NodeSet &hardEvidence, GUM_SCALAR virtualLBPSize)
sets the estimatoor object with posteriors obtained by LoopyBeliefPropagation
Definition: estimator_tpl.h:89
Implementation of Estimator for approximate inference in bayesian networks.
const IBayesNet< GUM_SCALAR > * _bn
bayesian network on which approximation is done
Definition: estimator.h:125
<agrum/BN/inference/loopyBeliefPropagation.h>
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
GUM_SCALAR variance(std::string name, Idx val)
returns variance of Bernouilli variable (called by it&#39;s name) of given parameter
Size Idx
Type for indexes.
Definition: types.h:50
Estimator()
Default constructor.
Definition: estimator_tpl.h:31
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Class hash tables iterators.
HashTable< std::string, Potential< GUM_SCALAR > *> __target_posteriors
the set of single posteriors computed during the last inference
Definition: estimator.h:155
GUM_SCALAR confidence()
computes the maximum length of confidence interval for each possible value of each variable ...