docs: def to_canonical_factor(self):
          u"""
          Returns an equivalent CanonicalDistribution object.
  
          The formulas for calculating the cannonical 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)