class_docstr: In its most common representation, a multivariate Gaussian distribution
  over X1, X2, ..., Xn is characterized by an n-dimensional mean vector μ,
  and a symmetric n x n covariance matrix Σ.
  
  This is the base class for its representation.
docstr: Returns an equivalent CanonicalDistribution object.
  
  The formulas for calculating the canonical factor parameters
  for N(μ; Σ) = C(K; h; g) are as follows -
  
  K = sigma^(-1)
  h = sigma^(-1) * mu
  g = -(0.5) * mu.T * sigma^(-1) * mu -
      log((2*pi)^(n/2) * det(sigma)^(0.5))
  
  where,
  K,h,g are the canonical factor parameters
  sigma is the covariance_matrix of the distribution,
  mu is the mean_vector of the distribution,
  mu.T is the transpose of the matrix mu,
  and det(sigma) is the determinant of the matrix sigma.
  
  Example
  -------
  >>> import numpy as np
  >>> from pgmpy.factors.distributions import GaussianDistribution as GD
  >>> dis = GD(variables=['x1', 'x2', 'x3'],
  ...          mean=[1, -3, 4],
  ...          cov=[[4, 2, -2],
  ...               [2, 5, -5],
  ...               [-2, -5, 8]])
  >>> phi = dis.to_canonical_factor()
  >>> phi.variables
  ['x1', 'x2', 'x3']
  >>> phi.K
  array([[0.3125, -0.125, 0.],
         [-0.125, 0.5833, 0.333],
         [     0., 0.333, 0.333]])
  >>> phi.h
  array([[  0.6875],
         [-0.54166],
         [ 0.33333]]))
  >>> phi.g
  -6.51533
docstr_tok: ["Returns","an","equivalent","CanonicalDistribution","object",".","The","formulas","for","calculating","the","canonical","factor","parameters","for","N","(","\u03bc",";","\u03a3",")","=","C","(","K",";","h",";","g",")","are","as","follows","-","K","=","sigma^","(","-1",")","h","=","sigma^","(","-1",")","*","mu","g","=","-","(","0.5",")","*","mu.T","*","sigma^","(","-1",")","*","mu","-","log","(","(","2","*","pi",")","^","(","n\/2",")","*","det","(","sigma",")","^","(","0.5",")",")","where",",","K",",","h",",","g","are","the","canonical","factor","parameters","sigma","is","the","covariance_matrix","of","the","distribution",",","mu","is","the","mean_vector","of","the","distribution",",","mu.T","is","the","transpose","of","the","matrix","mu",",","and","det","(","sigma",")","is","the","determinant","of","the","matrix","sigma",".","Example","--","--","--","-",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.factors.distributions","import","GaussianDistribution","as","GD",">",">",">","dis","=","GD","(","variables=","[","'x1","'",",","'x2","'",",","'x3","'","]",",","...","mean=","[","1",",","-3",",","4","]",",","...","cov=","[","[","4",",","2",",","-2","]",",","...","[","2",",","5",",","-5","]",",","...","[","-2",",","-5",",","8","]","]",")",">",">",">","phi","=","dis.to_canonical_factor","(",")",">",">",">","phi.variables","[","'x1","'",",","'x2","'",",","'x3","'","]",">",">",">","phi.K","array","(","[","[","0.3125",",","-0.125",",","0",".","]",",","[","-0.125",",","0.5833",",","0.333","]",",","[","0.",",","0.333",",","0.333","]","]",")",">",">",">","phi.h","array","(","[","[","0.6875","]",",","[","-0.54166","]",",","[","0.33333","]","]",")",")",">",">",">","phi.g","-6.51533"]
code: def to_canonical_factor(self):
      """
      Returns an equivalent CanonicalDistribution object.
  
      The formulas for calculating the canonical factor parameters
      for N(μ; Σ) = C(K; h; g) are as follows -
  
      K = sigma^(-1)
      h = sigma^(-1) * mu
      g = -(0.5) * mu.T * sigma^(-1) * mu -
          log((2*pi)^(n/2) * det(sigma)^(0.5))
  
      where,
      K,h,g are the canonical factor parameters
      sigma is the covariance_matrix of the distribution,
      mu is the mean_vector of the distribution,
      mu.T is the transpose of the matrix mu,
      and det(sigma) is the determinant of the matrix sigma.
  
      Example
      -------
      >>> import numpy as np
      >>> from pgmpy.factors.distributions import GaussianDistribution as GD
      >>> dis = GD(variables=['x1', 'x2', 'x3'],
      ...          mean=[1, -3, 4],
      ...          cov=[[4, 2, -2],
      ...               [2, 5, -5],
      ...               [-2, -5, 8]])
      >>> phi = dis.to_canonical_factor()
      >>> phi.variables
      ['x1', 'x2', 'x3']
      >>> phi.K
      array([[0.3125, -0.125, 0.],
             [-0.125, 0.5833, 0.333],
             [     0., 0.333, 0.333]])
      >>> phi.h
      array([[  0.6875],
             [-0.54166],
             [ 0.33333]]))
      >>> phi.g
      -6.51533
      """
      from pgmpy.factors.continuous import CanonicalDistribution
  
      mu = self.mean
      sigma = self.covariance
  
      K = self.precision_matrix
  
      h = np.dot(K, mu)
  
      g = -(0.5) * np.dot(mu.T, h)[0, 0] - np.log(
          np.power(2 * np.pi, len(self.variables) / 2)
          * np.power(abs(np.linalg.det(sigma)), 0.5)
      )
  
      return CanonicalDistribution(self.variables, K, h, g)
  
imports: import numpy
  from scipy.stats import multivariate_normal
  from pgmpy.factors.distributions import BaseDistribution
label_desc: Use image node_id 9 for calling the GaussianDistribution obj's underlying member method code with example usage: obj.to_canonical_factor() and returns: CanonicalDistribution