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

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

#include <simpleCPTDisturber.h>

Inherits gum::ICPTDisturber< GUM_SCALAR >.

Public Member Functions

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

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 47 of file simpleCPTDisturber.h.

Constructor & Destructor Documentation

◆ SimpleCPTDisturber()

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

Default constructor.

Definition at line 34 of file simpleCPTDisturber_tpl.h.

References gum::Set< Key, Alloc >::emplace().

34  : ICPTDisturber< GUM_SCALAR >() {
35  GUM_CONSTRUCTOR(SimpleCPTDisturber);
36  }
SimpleCPTDisturber()
Default constructor.
+ Here is the call graph for this function:

◆ ~SimpleCPTDisturber()

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

Destructor.

Definition at line 40 of file simpleCPTDisturber_tpl.h.

References gum::Set< Key, Alloc >::emplace().

40  {
41  GUM_DESTRUCTOR(SimpleCPTDisturber);
42  }
SimpleCPTDisturber()
Default constructor.
+ 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,
Potential< 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 73 of file simpleCPTDisturber_tpl.h.

References gum::Set< Key, Alloc >::emplace().

76  {
77  Instantiation i(bayesNet.cpt(node));
78 
79  for (i.setFirst(); !i.end(); ++i)
80  bayesNet.cpt(node).set(i, src.get(i) + GUM_SCALAR(randomProba()) * variation);
81 
82  bayesNet.cpt(node).normalizeAsCPT();
83  }
double randomProba()
Returns a random double between 0 and 1 included (i.e.
+ Here is the call graph for this function:

◆ disturbReducCPT()

template<typename GUM_SCALAR >
void gum::SimpleCPTDisturber< GUM_SCALAR >::disturbReducCPT ( NodeId  node,
BayesNet< GUM_SCALAR > &  bayesNet,
Potential< GUM_SCALAR > &  src,
Potential< 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 49 of file simpleCPTDisturber_tpl.h.

References gum::Set< Key, Alloc >::emplace().

52  {
53  Instantiation i_src(src);
54  Instantiation i_dest(bayesNet.cpt(node));
55  Instantiation i_marg(marg);
56 
57  for (i_dest.setFirst(); !i_dest.end(); ++i_dest) {
58  GUM_SCALAR potval = 0;
59 
60  i_src.setVals(i_dest);
61  for (i_marg.setFirst(); !i_marg.end(); ++i_marg) {
62  i_src.setVals(i_marg);
63  potval += src.get(i_src) * marg.get(i_marg);
64  }
65 
66  bayesNet.cpt(node).set(i_dest, potval);
67  }
68 
69  bayesNet.cpt(node).normalizeAsCPT();
70  }
+ Here is the call graph for this function:

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