class_docstr: The intermediate factors in a Gaussian network can be described
  compactly using a simple parametric representation called the
  canonical form. This representation is closed under the basic
  operations used in inference: factor product, factor division,
  factor reduction, and marginalization. Thus, we define this
  CanonicalDistribution class that allows the inference process to be
  performed on joint Gaussian networks.
  
  A canonical form C (X; K,h,g) is defined as
  
  C (X; K,h,g) = exp( ((-1/2) * X.T * K * X) + (h.T * X) + g)
  
  References
  ----------
  Probabilistic Graphical Models, Principles and Techniques,
  Daphne Koller and Nir Friedman, Section 14.2, Chapter 14.
class_docstr_tok: ["The","intermediate","factors","in","a","Gaussian","network","can","be","described","compactly","using","a","simple","parametric","representation","called","the","canonical","form",".","This","representation","is","closed","under","the","basic","operations","used","in","inference",":","factor","product",",","factor","division",",","factor","reduction",",","and","marginalization",".","Thus",",","we","define","this","CanonicalDistribution","class","that","allows","the","inference","process","to","be","performed","on","joint","Gaussian","networks",".","A","canonical","form","C","(","X\u037e","K",",","h",",","g",")","is","defined","as","C","(","X\u037e","K",",","h",",","g",")","=","exp","(","(","(","-1\/2",")","*","X.T","*","K","*","X",")","+","(","h.T","*","X",")","+","g",")","References","--","--","--","--","--","Probabilistic","Graphical","Models",",","Principles","and","Techniques",",","Daphne","Koller","and","Nir","Friedman",",","Section","14.2",",","Chapter","14","."]
docstr: Return an equivalent Joint Gaussian Distribution.
  
  Examples
  --------
  
  >>> import numpy as np
  >>> from pgmpy.factors.continuous import CanonicalDistribution
  >>> phi = CanonicalDistribution(['x1', 'x2'], np.array([[3, -2], [-2, 4]]),
                            np.array([[5], [-1]]), 1)
  >>> jgd = phi.to_joint_gaussian()
  >>> jgd.variables
  ['x1', 'x2']
  >>> jgd.covariance
  array([[ 0.5  ,  0.25 ],
         [ 0.25 ,  0.375]])
  >>> jgd.mean
  array([[ 2.25 ],
         [ 0.875]])
docstr_tok: ["Return","an","equivalent","Joint","Gaussian","Distribution",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.factors.continuous","import","CanonicalDistribution",">",">",">","phi","=","CanonicalDistribution","(","[","'x1","'",",","'x2","'","]",",","np.array","(","[","[","3",",","-2","]",",","[","-2",",","4","]","]",")",",","np.array","(","[","[","5","]",",","[","-1","]","]",")",",","1",")",">",">",">","jgd","=","phi.to_joint_gaussian","(",")",">",">",">","jgd.variables","[","'x1","'",",","'x2","'","]",">",">",">","jgd.covariance","array","(","[","[","0.5",",","0.25","]",",","[","0.25",",","0.375","]","]",")",">",">",">","jgd.mean","array","(","[","[","2.25","]",",","[","0.875","]","]",")"]
code: def to_joint_gaussian(self):
      """
      Return an equivalent Joint Gaussian Distribution.
  
      Examples
      --------
  
      >>> import numpy as np
      >>> from pgmpy.factors.continuous import CanonicalDistribution
      >>> phi = CanonicalDistribution(['x1', 'x2'], np.array([[3, -2], [-2, 4]]),
                                np.array([[5], [-1]]), 1)
      >>> jgd = phi.to_joint_gaussian()
      >>> jgd.variables
      ['x1', 'x2']
      >>> jgd.covariance
      array([[ 0.5  ,  0.25 ],
             [ 0.25 ,  0.375]])
      >>> jgd.mean
      array([[ 2.25 ],
             [ 0.875]])
  
      """
      covariance = np.linalg.inv(self.K)
      mean = np.dot(covariance, self.h)
  
      return GaussianDistribution(self.variables, mean, covariance)
  
file_path: pgmpy/pgmpy/factors/distributions/CanonicalDistribution.py
imports: import numpy
  from pgmpy.factors.distributions import BaseDistribution
  from pgmpy.factors.distributions import GaussianDistribution
label_desc: Use image node_id 5 for calling the CanonicalDistribution obj's underlying member method code with example usage: obj.to_joint_gaussian() and returns: GaussianDistribution