aGrUM  0.15.1
GibbsSampling_tpl.h
Go to the documentation of this file.
1 
31 
32 #define GIBBS_SAMPLING_DEFAULT_EPSILON std::exp(-1.6)
33 #define GIBBS_SAMPLING_DEFAULT_MIN_EPSILON_RATE std::exp(-5)
34 #define GIBBS_SAMPLING_DEFAULT_BURNIN 300
35 
36 #define GIBBS_SAMPLING_POURCENT_DRAWN_SAMPLE 50 // percent drawn
37 #define GIBBS_SAMPLING_DRAWN_AT_RANDOM true
38 
39 namespace gum {
40 
42  template < typename GUM_SCALAR >
44  SamplingInference< GUM_SCALAR >(bn),
45  GibbsOperator< GUM_SCALAR >(
46  *bn,
47  &this->hardEvidence(),
48  1 + (bn->size() * GIBBS_SAMPLING_POURCENT_DRAWN_SAMPLE / 100),
50  GUM_CONSTRUCTOR(GibbsSampling);
51 
55  }
56 
58  template < typename GUM_SCALAR >
60  GUM_DESTRUCTOR(GibbsSampling);
61  }
62 
63 
64  template < typename GUM_SCALAR >
67  }
68 
69 
70  template < typename GUM_SCALAR >
73  if (this->burnIn() == 0) return Ip;
74 
75  GUM_SCALAR w = 1.0f;
76  Ip = _monteCarloSample();
77  for (Size i = 1; i < this->burnIn(); i++)
78  Ip = this->_draw(&w, Ip);
79 
80  return Ip;
81  }
82 
84 
85  template < typename GUM_SCALAR >
87  Instantiation prev) {
88  *w = 1.0;
90  }
91 } // namespace gum
~GibbsSampling() override
Destructor.
GibbsSampling(const IBayesNet< GUM_SCALAR > *bn)
Default constructor.
void setBurnIn(Size b)
Number of burn in for one iteration.
Definition: GibbsSampling.h:74
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:62
Instantiation _draw(GUM_SCALAR *w, Instantiation prev) override
draws a sample given previous one according to Gibbs sampling
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void setMinEpsilonRate(double rate)
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
#define GIBBS_SAMPLING_DEFAULT_BURNIN
#define GIBBS_SAMPLING_DEFAULT_MIN_EPSILON_RATE
<agrum/BN/inference/gibbsSampling.h>
Definition: GibbsSampling.h:55
#define GIBBS_SAMPLING_DEFAULT_EPSILON
Instantiation nextSample(Instantiation prev)
draws next sample of Gibbs sampling
#define GIBBS_SAMPLING_POURCENT_DRAWN_SAMPLE
Size burnIn() const
Returns the number of burn in.
Definition: GibbsSampling.h:80
Instantiation _monteCarloSample()
draws a Monte Carlo sample
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Instantiation monteCarloSample()
draws a Monte Carlo sample
void setEpsilon(double eps)
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
#define GIBBS_SAMPLING_DRAWN_AT_RANDOM
Instantiation _burnIn() override
draws a defined number of samples without updating the estimators
class containing all variables and methods required for Gibbssampling
Definition: gibbsOperator.h:50