36 template <
typename GUM_SCALAR >
42 _sampling_bn(BN), _hardEv(hardEv), _nbr(nbr), _atRandom(atRandom) {
47 template <
typename GUM_SCALAR >
52 template <
typename GUM_SCALAR >
60 "No node to sample (too many nodes or too much evidence)!")
69 template <
typename GUM_SCALAR >
84 template <
typename GUM_SCALAR >
94 template <
typename GUM_SCALAR >
96 for (
Idx i = 0; i <
_nbr; i++) {
106 template <
typename GUM_SCALAR >
113 GUM_ASSERT(p.
nbrDim() == 1);
aGrUM's Potential is a multi-dimensional array with tensor operators.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual Idx nbrDim() const final
Returns the number of vars in the multidimensional container.
void clear()
Clear the sequence.
GibbsOperator(const IBayesNet< GUM_SCALAR > &BN, const NodeProperty< Idx > *hardEv, Size nbr=1, bool atRandom=false)
constructor
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
Size size() const noexcept
Returns the size of the sequence.
const Potential< GUM_SCALAR > & normalize() const
normalisation of this do nothing if sum is 0
Sequence< NodeId > _samplingNodes
void __drawVarMonteCarlo(NodeId nod, Instantiation *I)
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
Class representing the minimal interface for Bayesian Network.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
const IBayesNet< GUM_SCALAR > & _sampling_bn
Size _counting
number of samples drawn
Idx draw() const
get a value at random from a 1-D distribution
Instantiation nextSample(Instantiation prev)
draws next sample of Gibbs sampling
void __GibbsSample(NodeId id, Instantiation *I)
change in Instantiation I a new drawn value for id
virtual ~GibbsOperator()
Destructor.
const NodeProperty< Idx > * _hardEv
Class for assigning/browsing values to tuples of discrete variables.
Instantiation monteCarloSample()
draws a Monte Carlo sample
void __updateSamplingNodes()
GUM_SCALAR sum() const
sum of all elements in the Potential
Size Idx
Type for indexes.
void add(const DiscreteVariable &v) final
Adds a new variable in the Instantiation.
void erase(const DiscreteVariable &v) final
Removes a variable from the Instantiation.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size NodeId
Type for node ids.
#define GUM_ERROR(type, msg)
class containing all variables and methods required for Gibbssampling
void insert(const Key &k)
Insert an element at the end of the sequence.