This module provides tools for creating and using an individual factorized representation of a node. See description of factorized representations in tablecpdfactorization.
This class represents a factorized representation of a conditional probability distribution table. It contains the attributes inputvertex, inputbn, vals, scope, stride, and card, and the methods multiplyfactor, sumout, reducefactor, and copy.
This class is constructed with a DiscreteBayesianNetwork instance and a vertex name as arguments. First it stores these inputs in inputvertex and inputbn. Then, it creates a factorized representation of vertex, storing the values in vals, the names of the variables involved in scope the cardinality of each of these variables in card and the stride of each of these variables in stride.
The name of the vertex.
The DiscreteBayesianNetwork instance that the vertex lives in.
A flat array of all the values from the CPD.
An array of vertices that affect the vals found in vals. Normally, this is the node itself and its parents.
A list of the cardinalities of each vertex in scope, where cardinality is the number of values that the vertex may take. The cardinalities are indexed according to the vertex’s index in scope.
A dict of {vertex: value} pairs for each vertex in scope, where vertex is the name of the vertex and value is the stride of that vertex in the vals array.
Multiply the factor by another TableCPDFactor. Multiplying factors means taking the union of the scopes, and for each combination of variables in the scope, multiplying together the probabilities from each factor that that combination will be found.
For more information cf. Koller et al. 359.
Sum out the variable specified by vertex from the factor. Summing out means summing all sets of entries together where vertex is the only variable changing in the set. Then vertex is removed from the scope of the factor.
For more information see Koller et al. 297.
Reduce the factor knowing that vertex equals value. Reducing the factor means erasing all possibilities for vertex other than value from the distribution, and removing vertex from the scope.