33 template <
typename GUM_SCALAR >
39 _sampling_bn(BN), _hardEv(hardEv), _nbr(nbr), _atRandom(atRandom) {
44 template <
typename GUM_SCALAR >
49 template <
typename GUM_SCALAR >
57 "No node to sample (too many nodes or too much evidence)!")
66 template <
typename GUM_SCALAR >
81 template <
typename GUM_SCALAR >
91 template <
typename GUM_SCALAR >
93 for (
Idx i = 0; i <
_nbr; i++) {
103 template <
typename GUM_SCALAR >
110 GUM_ASSERT(p.
nbrDim() == 1);
aGrUM's Potential is a multi-dimensional array with tensor operators.
This file contains Gibbs sampling (for BNs) class definitions.
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.
gum is the global namespace for all aGrUM entities
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.
Contains usefull methods for random stuff.
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.