Linear Gaussian CPD

class pgmpy.factors.continuous.LinearGaussianCPD.LinearGaussianCPD(variable, beta, std, evidence=[])[source]

Defines a Linear Gaussian CPD.

The Linear Gaussian CPD makes the following assumptions:
  1. The variable is Gaussian/Normally distributed.

  2. The mean of the variable depends on the values of the parents and the

    intercept term.

  3. The variance is independent of other variables.

For example,

p(Y|X) = N(0.9 - 2x; 1)

Here, 0.9 - 2x is the mean of the variable Y and the standard deviation is 1.

In generalized terms, let Y be a Gaussian variable with parents X_1, X_2, \cdots, X_k. Assuming linear relationship between Y and mathbf{X}, the conditional distribution of Y can be defined as:

p(Y |x1, x2, ..., xk) = \mathcal{N}(\beta_0 + x1*\beta_1 + ......... + xk*\beta_k ; \sigma)

References

Parameters:
  • variable (any hashable python object) – The variable whose CPD is defined.

  • beta (list (array-like)) – The coefficients corresponding to each of the evidence variable. The first term of the beta array is the intercept term.

  • std (float) – The standard deviation of variable.

  • evidence (iterator (array-like)) – List of parents/evidence variables of variable. The order in which evidence is specified should match the order of beta.

Examples

# To represent the conditional distribution, P(Y| X1, X2, X3) = N(0.2 - 2*x1 + 3*x2 + 7*x3 ; 9.6), we can write:

>>> from pgmpy.factors.continuous import LinearGaussianCPD
>>> cpd = LinearGaussianCPD('Y',  [0.2, -2, 3, 7], 9.6, ['X1', 'X2', 'X3'])
>>> cpd.variable
'Y'
>>> cpd.evidence
['x1', 'x2', 'x3']
>>> cpd.beta_vector
[0.2, -2, 3, 7]
copy()[source]

Returns a copy of the distribution.

Returns:

LinearGaussianCPD

Return type:

copy of the distribution

Examples

>>> from pgmpy.factors.continuous import LinearGaussianCPD
>>> cpd = LinearGaussianCPD('Y',  [0.2, -2, 3, 7], 9.6, ['X1', 'X2', 'X3'])
>>> copy_cpd = cpd.copy()
>>> copy_cpd.variable
'Y'
>>> copy_cpd.evidence
['X1', 'X2', 'X3']