class_docstr: For, X -> Y the Linear Gaussian model assumes that the mean
  of Y is a linear function of mean of X and the variance of Y does
  not depend on X.
  
  For example,
  
  .. math::
  
    p(Y|X) = N(-2x + 0.9 ; 1)
  
  Here, :math:`x` is the mean of the variable :math:`X`.
  
  Let :math:`Y` be a continuous variable with continuous parents
  :math:`X1, X2, \cdots, Xk`. We say that :math:`Y` has a linear Gaussian CPD
  if there are parameters :math:`\beta_0, \beta_1, ..., \beta_k`
  and :math:`\sigma_2` such that,
  
  .. math:: p(Y |x1, x2, ..., xk) = \mathcal{N}(\beta_0 + x1*\beta_1 + ......... + xk*\beta_k ; \sigma_2)
  
  In vector notation,
  
  .. math:: p(Y |x) = \mathcal{N}(\beta_0 + \boldmath{β}.T * \boldmath{x} ; \sigma_2)
  
  References
  ----------
  .. [1] https://cedar.buffalo.edu/~srihari/CSE574/Chap8/Ch8-PGM-GaussianBNs/8.5%20GaussianBNs.pdf
class_docstr_tok: ["For",",","X","-",">","Y","the","Linear","Gaussian","model","assumes","that","the","mean","of","Y","is","a","linear","function","of","mean","of","X","and","the","variance","of","Y","does","not","depend","on","X",".","For","example",",","..","math",":",":","p","(","Y|X",")","=","N","(","-2x","+","0.9",";","1",")","Here",",",":","math",":","`","x","`","is","the","mean","of","the","variable",":","math",":","`","X","`",".","Let",":","math",":","`","Y","`","be","a","continuous","variable","with","continuous","parents",":","math",":","`","X1",",","X2",",","\\cdots",",","Xk","`",".","We","say","that",":","math",":","`","Y","`","has","a","linear","Gaussian","CPD","if","there","are","parameters",":","math",":","`","\\beta_0",",","\\beta_1",",","...",",","\\beta_k","`","and",":","math",":","`","\\sigma_2","`","such","that",",","..","math",":",":","p","(","Y","|x1",",","x2",",","...",",","xk",")","=","\\mathcal","{","N","}","(","\\beta_0","+","x1","*","\\beta_1","+",".........","+","xk","*","\\beta_k","\u037e","\\sigma_2",")","In","vector","notation",",","..","math",":",":","p","(","Y","|x",")","=","\\mathcal","{","N","}","(","\\beta_0","+","\\boldmath","{","\u03b2","}",".T","*","\\boldmath","{","x","}","\u037e","\\sigma_2",")","References","--","--","--","--","--","..","[","1","]","https",":","\/\/cedar.buffalo.edu\/~srihari\/CSE574\/Chap8\/Ch8-PGM-GaussianBNs\/8.5","%","20GaussianBNs.pdf"]
docstr: Fit using MLE method.
  
  Parameters
  ----------
  data: pandas.DataFrame or 2D array
      Dataframe of values containing samples from the conditional distribution, (Y|X)
      and corresponding X values.
  
  states: All the input states that are jointly gaussian.
  
  Returns
  -------
  beta, variance (tuple): Returns estimated betas and the variance.
docstr_tok: ["Fit","using","MLE","method",".","Parameters","--","--","--","--","--","data",":","pandas.DataFrame","or","2D","array","Dataframe","of","values","containing","samples","from","the","conditional","distribution",",","(","Y|X",")","and","corresponding","X","values",".","states",":","All","the","input","states","that","are","jointly","gaussian",".","Returns","--","--","--","-","beta",",","variance","(","tuple",")",":","Returns","estimated","betas","and","the","variance","."]
code: def maximum_likelihood_estimator(self, data, states):
      """
      Fit using MLE method.
  
      Parameters
      ----------
      data: pandas.DataFrame or 2D array
          Dataframe of values containing samples from the conditional distribution, (Y|X)
          and corresponding X values.
  
      states: All the input states that are jointly gaussian.
  
      Returns
      -------
      beta, variance (tuple): Returns estimated betas and the variance.
      """
      x_df = pd.DataFrame(data, columns=states)
      x_len = len(self.evidence)
  
      sym_coefs = []
      for i in range(0, x_len):
          sym_coefs.append("b" + str(i + 1) + "_coef")
  
      sum_x = x_df.sum()
      x = [sum_x["(Y|X)"]]
      coef_matrix = pd.DataFrame(columns=sym_coefs)
  
      # First we compute just the coefficients of beta_1 to beta_N.
      # Later we compute beta_0 and append it.
      for i in range(0, x_len):
          x.append(
              self.sum_of_product(x_df["(Y|X)"], x_df[self.evidence[i]])
          )
          for j in range(0, x_len):
              coef_matrix.loc[i, sym_coefs[j]] = self.sum_of_product(
                  x_df[self.evidence[i]], x_df[self.evidence[j]]
              )
  
      coef_matrix.insert(0, "b0_coef", sum_x[self.evidence].values)
      row_1 = np.append([len(x_df)], sum_x[self.evidence].values)
      coef_matrix.loc[-1] = row_1
      coef_matrix.index = coef_matrix.index + 1  # shifting index
      coef_matrix.sort_index(inplace=True)
  
      beta_coef_matrix = np.matrix(coef_matrix.values, dtype="float")
      coef_inv = np.linalg.inv(beta_coef_matrix)
      beta_est = np.array(np.matmul(coef_inv, np.transpose(x)))
      self.beta = beta_est[0]
  
      sigma_est = 0
      x_len_df = len(x_df)
      for i in range(0, x_len):
          for j in range(0, x_len):
              sigma_est += (
                  self.beta[i + 1]
                  * self.beta[j + 1]
                  * (
                      self.sum_of_product(
                          x_df[self.evidence[i]], x_df[self.evidence[j]]
                      )
                      / x_len_df
                      - np.mean(x_df[self.evidence[i]])
                      * np.mean(x_df[self.evidence[j]])
                  )
              )
  
      sigma_est = np.sqrt(
          self.sum_of_product(x_df["(Y|X)"], x_df["(Y|X)"]) / x_len_df
          - np.mean(x_df["(Y|X)"]) * np.mean(x_df["(Y|X)"])
          - sigma_est
      )
      self.sigma_yx = sigma_est
      return self.beta, self.sigma_yx
  
file_path: pgmpy/pgmpy/factors/continuous/LinearGaussianCPD.py
imports: import numpy
  import pandas
  from scipy.stats import multivariate_normal
  from pgmpy.factors.base import BaseFactor
label_desc: Use image node_id 3 for calling the LinearGaussianCPD obj's underlying member method code with example usage: obj.maximum_likelihood_estimator(data, states) and returns: self,  self