aGrUM 3.0.0
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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR>
gum::SimpleCPTDisturber< GUM_SCALAR >::SimpleCPTDisturber ( )

Default constructor.

Definition at line 56 of file simpleCPTDisturber_tpl.h.

56 : ICPTDisturber< GUM_SCALAR >() {
58 }
<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<GUM_Numeric GUM_SCALAR>
gum::SimpleCPTDisturber< GUM_SCALAR >::~SimpleCPTDisturber ( )
override

Destructor.

Definition at line 62 of file simpleCPTDisturber_tpl.h.

References SimpleCPTDisturber().

Here is the call graph for this function:

Member Function Documentation

◆ disturbAugmCPT()

template<GUM_Numeric 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 95 of file simpleCPTDisturber_tpl.h.

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

◆ disturbReducCPT()

template<GUM_Numeric 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 71 of file simpleCPTDisturber_tpl.h.

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

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: