parameters: (self)
return_statement: return log_marginal_term1 + log_marginal_term2 + log_marginal_term3
docstring: r"""Compute the _log_likelihood_type measure at the specified hyperparameters.
  
          .. NOTE:: These comments are copied from LogMarginalLikelihoodEvaluator::ComputeLogLikelihood in gpp_model_selection.cpp.
  
          ``log p(y | X, \theta) = -\frac{1}{2} * y^T * K^-1 * y - \frac{1}{2} * \log(det(K)) - \frac{n}{2} * \log(2*pi)``
          where n is ``num_sampled``, ``\theta`` are the hyperparameters, and ``\log`` is the natural logarithm.  In the following,
          ``term1 = -\frac{1}{2} * y^T * K^-1 * y``
          ``term2 = -\frac{1}{2} * \log(det(K))``
          ``term3 = -\frac{n}{2} * \log(2*pi)``
  
          For an SPD matrix ``K = L * L^T``,
          ``det(K) = \Pi_i L_ii^2``
          We could compute this directly and then take a logarithm.  But we also know:
          ``\log(det(K)) = 2 * \sum_i \log(L_ii)``
          The latter method is (currently) preferred for computing ``\log(det(K))`` due to reduced chance for overflow
          and (possibly) better numerical conditioning.
  
          :return: value of log_likelihood evaluated at hyperparameters (``LL(y | X, \theta)``)
          :rtype: float64
docstring_summary: r"""Compute the _log_likelihood_type measure at the specified hyperparameters.
docstring_tokens: r Compute the _log_likelihood_type measure at the specified hyperparameters .
function: def compute_log_likelihood(self):
          r"""Compute the _log_likelihood_type measure at the specified hyperparameters.
  
          .. NOTE:: These comments are copied from LogMarginalLikelihoodEvaluator::ComputeLogLikelihood in gpp_model_selection.cpp.
  
          ``log p(y | X, \theta) = -\frac{1}{2} * y^T * K^-1 * y - \frac{1}{2} * \log(det(K)) - \frac{n}{2} * \log(2*pi)``
          where n is ``num_sampled``, ``\theta`` are the hyperparameters, and ``\log`` is the natural logarithm.  In the following,
          ``term1 = -\frac{1}{2} * y^T * K^-1 * y``
          ``term2 = -\frac{1}{2} * \log(det(K))``
          ``term3 = -\frac{n}{2} * \log(2*pi)``
  
          For an SPD matrix ``K = L * L^T``,
          ``det(K) = \Pi_i L_ii^2``
          We could compute this directly and then take a logarithm.  But we also know:
          ``\log(det(K)) = 2 * \sum_i \log(L_ii)``
          The latter method is (currently) preferred for computing ``\log(det(K))`` due to reduced chance for overflow
          and (possibly) better numerical conditioning.
  
          :return: value of log_likelihood evaluated at hyperparameters (``LL(y | X, \theta)``)
          :rtype: float64
  
          """
          covariance_matrix = python_utils.build_covariance_matrix(
              self._covariance,
              self._points_sampled,
              noise_variance=self._points_sampled_noise_variance,
          )
          K_chol = scipy.linalg.cho_factor(covariance_matrix, lower=True, overwrite_a=True)
  
          log_marginal_term2 = -numpy.log(K_chol[0].diagonal()).sum()
  
          K_inv_y = scipy.linalg.cho_solve(K_chol, self._points_sampled_value)
          log_marginal_term1 = -0.5 * numpy.inner(self._points_sampled_value, K_inv_y)
  
          log_marginal_term3 = -0.5 * numpy.float64(self._points_sampled_value.size) * numpy.log(2.0 * numpy.pi)
          return log_marginal_term1 + log_marginal_term2 + log_marginal_term3
function_tokens: def compute_log_likelihood ( self ) : covariance_matrix = python_utils . build_covariance_matrix ( self . _covariance , self . _points_sampled , noise_variance = self . _points_sampled_noise_variance , ) K_chol = scipy . linalg . cho_factor ( covariance_matrix , lower = True , overwrite_a = True ) log_marginal_term2 = - numpy . log ( K_chol [ 0 ] . diagonal ( ) ) . sum ( ) K_inv_y = scipy . linalg . cho_solve ( K_chol , self . _points_sampled_value ) log_marginal_term1 = - 0.5 * numpy . inner ( self . _points_sampled_value , K_inv_y ) log_marginal_term3 = - 0.5 * numpy . float64 ( self . _points_sampled_value . size ) * numpy . log ( 2.0 * numpy . pi ) return log_marginal_term1 + log_marginal_term2 + log_marginal_term3