aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::SimpleCPTDisturber< GUM_SCALAR > Class Template Reference

<agrum/BN/generator/simpleCPTDisturber.h> More...

#include <simpleCPTDisturber.h>

Inheritance diagram for gum::SimpleCPTDisturber< GUM_SCALAR >:

Public Member Functions

Constructors / Destructor
 SimpleCPTDisturber ()
 Default constructor.
 ~SimpleCPTDisturber () override
 Destructor.
CPT disturbing methods
void disturbReducCPT (NodeId node, BayesNet< GUM_SCALAR > &bayesNet, Tensor< GUM_SCALAR > &src, Tensor< GUM_SCALAR > &marg) override
 Disturb a CPT using GUM_SCALAR when removing parent varIdi.
void disturbAugmCPT (NodeId node, BayesNet< GUM_SCALAR > &bayesNet, Tensor< GUM_SCALAR > &src, GUM_SCALAR variation) override
 Disturb a CPT using GUM_SCALAR when inserting a new parent new_parent.

Detailed Description

template<typename GUM_SCALAR>
class gum::SimpleCPTDisturber< GUM_SCALAR >

<agrum/BN/generator/simpleCPTDisturber.h>

Class for disturbing Conditional Probability Tables.

This class implements a CPTGenerator CPT generation algorithm.

Definition at line 68 of file simpleCPTDisturber.h.

Constructor & Destructor Documentation

◆ SimpleCPTDisturber()

template<typename GUM_SCALAR>
INLINE gum::SimpleCPTDisturber< GUM_SCALAR >::SimpleCPTDisturber ( )

Default constructor.

Definition at line 55 of file simpleCPTDisturber_tpl.h.

55 : ICPTDisturber< GUM_SCALAR >() {
57 }
<agrum/BN/generator/simpleCPTDisturber.h>
SimpleCPTDisturber()
Default constructor.

References SimpleCPTDisturber().

Referenced by SimpleCPTDisturber(), and ~SimpleCPTDisturber().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~SimpleCPTDisturber()

template<typename GUM_SCALAR>
INLINE gum::SimpleCPTDisturber< GUM_SCALAR >::~SimpleCPTDisturber ( )
override

Destructor.

Definition at line 61 of file simpleCPTDisturber_tpl.h.

References SimpleCPTDisturber().

Here is the call graph for this function:

Member Function Documentation

◆ disturbAugmCPT()

template<typename GUM_SCALAR>
void gum::SimpleCPTDisturber< GUM_SCALAR >::disturbAugmCPT ( NodeId node,
BayesNet< GUM_SCALAR > & bayesNet,
Tensor< GUM_SCALAR > & src,
GUM_SCALAR variation )
override

Disturb a CPT using GUM_SCALAR when inserting a new parent new_parent.

Parameters
nodeA reference on the CPT owner.
bayesNetthe Bayesian network.
srccopy of the CPT before augmentation.
variationdegree of variation from the initial probability.

Definition at line 94 of file simpleCPTDisturber_tpl.h.

97 {
99
100 for (i.setFirst(); !i.end(); ++i)
101 bayesNet.cpt(node).set(i, src.get(i) + GUM_SCALAR(randomProba()) * variation);
102
103 bayesNet.cpt(node).normalizeAsCPT();
104 }
double randomProba()
Returns a random double between 0 and 1 included (i.e.

◆ disturbReducCPT()

template<typename GUM_SCALAR>
void gum::SimpleCPTDisturber< GUM_SCALAR >::disturbReducCPT ( NodeId node,
BayesNet< GUM_SCALAR > & bayesNet,
Tensor< GUM_SCALAR > & src,
Tensor< GUM_SCALAR > & marg )
override

Disturb a CPT using GUM_SCALAR when removing parent varIdi.

Parameters
nodeThe variable on the CPT owner.
bayesNetthe Bayesian network.
srccopy of the CPT before reduction.
margof the inference before reduction on the node varIdi.

Definition at line 70 of file simpleCPTDisturber_tpl.h.

73 {
77
78 for (i_dest.setFirst(); !i_dest.end(); ++i_dest) {
80
81 i_src.setVals(i_dest);
82 for (i_marg.setFirst(); !i_marg.end(); ++i_marg) {
83 i_src.setVals(i_marg);
84 potval += src.get(i_src) * marg.get(i_marg);
85 }
86
87 bayesNet.cpt(node).set(i_dest, potval);
88 }
89
90 bayesNet.cpt(node).normalizeAsCPT();
91 }

References gum::Instantiation::end(), gum::Instantiation::setFirst(), and gum::Instantiation::setVals().

Here is the call graph for this function:

The documentation for this class was generated from the following files: