56 template < GUM_Numeric GUM_SCALAR >
58 GUM_SCALAR default_weight) :
65 template < GUM_Numeric GUM_SCALAR >
67 GUM_SCALAR causal_weight)
const {
69 if (causal_weight < external_weight) {
71 "In a NoisyOR compound (Henrion), a causal weight ("
72 << causal_weight <<
") cannot be lower than the leak (" << external_weight
79 template < GUM_Numeric GUM_SCALAR >
87 template < GUM_Numeric GUM_SCALAR >
97 template < GUM_Numeric GUM_SCALAR >
102 template < GUM_Numeric GUM_SCALAR >
108 if (i.
val(C) > 1)
return (GUM_SCALAR)0.0;
112 GUM_SCALAR fact = (GUM_SCALAR)ratio;
114 if (fact != (GUM_SCALAR)0) {
115 for (
Idx j = 1; j < this->
nbrDim(); j++) {
121 if (pr == (GUM_SCALAR)0.0) {
122 fact = (GUM_SCALAR)0.0;
131 return (i.
val(C) != 1) ? fact : (GUM_SCALAR)1.0 - fact;
134 template < GUM_Numeric GUM_SCALAR >
137 s << MultiDimImplementation< GUM_SCALAR >::variable(0) <<
"=noisyORCompound(["
140 for (
Idx i = 1; i < MultiDimImplementation< GUM_SCALAR >::nbrDim(); i++)
150 template < GUM_Numeric GUM_SCALAR >
155 template < GUM_Numeric GUM_SCALAR >
162 template < GUM_Numeric GUM_SCALAR >
164 static const std::string str =
"MultiDimNoisyORCompound";
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
Class for assigning/browsing values to tuples of discrete variables.
Idx val(Idx i) const
Returns the current value of the variable at position i.
static void checkWeightsAreProbabilities_(GUM_SCALAR external_weight, GUM_SCALAR causal_weight)
GUM_SCALAR _external_weight_
MultiDimICIModel(GUM_SCALAR external_weight, GUM_SCALAR default_weight=(GUM_SCALAR) 1.0)
GUM_SCALAR externalWeight() const
GUM_SCALAR _default_weight_
GUM_SCALAR causalWeight(const DiscreteVariable &v) const
const DiscreteVariable & variable(Idx i) const override
Idx nbrDim() const override
MultiDimNoisyORCompound(GUM_SCALAR external_weight, GUM_SCALAR default_weight=(GUM_SCALAR) 1.0)
Default constructor.
const std::string & name() const override
returns the real name of the multiDimArray
MultiDimContainer< GUM_SCALAR > * newFactory() const override
This method creates a clone of this object, withouth its content (including variable),...
~MultiDimNoisyORCompound() override
Destructor.
void checkCausalWeight_(GUM_SCALAR external_weight, GUM_SCALAR causal_weight) const override
In Henrion's parametrization, a causal weight is the probability of the effect when only this cause i...
GUM_SCALAR get(const Instantiation &i) const override
returns the real name of the multiDimArray
std::string toString() const override
returns the real name of the multiDimArray
Exception : operation not allowed.
Exception : out of bound.
#define GUM_ERROR(type, msg)
Size Idx
Type for indexes.
class for multiDimNoisyORCompound
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree