Node for computing sums of Gaussian nodes: .
Shapes of the nodes must be identical. Plates are broadcasted.
This node sums nodes that are independent in the posterior approximation. However, summing variables puts a strong coupling among the variables, which is lost in this construction. Thus, it is usually better to use a single Gaussian node to represent the set of the summed variables and use SumMultiply node to compute the sum. In that way, the correlation between the variables is not lost. However, in some cases it is necessary or useful to use Add node.
>>> import numpy as np >>> from bayespy import nodes >>> X = nodes.Gaussian(np.zeros(2), np.identity(2), plates=(3,)) >>> Y = nodes.Gaussian(np.ones(2), np.identity(2)) >>> Z = nodes.Add(X, Y) >>> print("Mean:\n", Z.get_moments()) Mean: [[1. 1.]] >>> print("Second moment:\n", Z.get_moments()) Second moment: [[[3. 1.] [1. 3.]]]
__init__(X1, X2, ...)¶
__init__(X1, X2, …)
Delete this node and the children
Return True if the node has a plotter
Plot the node distribution using the plotter of the node
Plate multiplier is applied to messages to parents