Ejemplo n.º 1
0
    def compute_log_likelihood(self, hyps):
        r"""Compute the objective_type measure at the specified hyperparameters.

        :return: value of log_likelihood evaluated at hyperparameters (``LL(y | X, \theta)``)
        :rtype: float64

        """
        # Bound the hyperparameter space to keep things sane. Note all
        # hyperparameters live on a log scale
        if numpy.any((-20 > hyps) + (hyps > 20)):
          return -numpy.inf
        if not self.noisy:
          hyps[(self.dim+1):] = numpy.log((1+self._num_derivatives)*[1.e-8])

        posterior = 1
        if self.prior is not None:
          posterior = self.prior.lnprob(hyps)

        hyps = numpy.exp(hyps)
        cov_hyps = hyps[:(self.dim+1)]
        noise = hyps[(self.dim+1):]

        if posterior == -numpy.inf:
            return -numpy.inf
        else:
            return posterior + C_GP.compute_log_likelihood(
                cpp_utils.cppify(self._points_sampled),
                cpp_utils.cppify(self._points_sampled_value),
                self.dim,
                self._num_sampled,
                self.objective_type,
                cpp_utils.cppify_hyperparameters(cov_hyps),
                cpp_utils.cppify(self._derivatives), self._num_derivatives,
                cpp_utils.cppify(noise),
                )
Ejemplo n.º 2
0
    def compute_log_likelihood(self):
        r"""Compute the objective_type measure at the specified hyperparameters.

        :return: value of log_likelihood evaluated at hyperparameters (``LL(y | X, \theta)``)
        :rtype: float64

        """
        return C_GP.compute_log_likelihood(
            cpp_utils.cppify(self._points_sampled),
            cpp_utils.cppify(self._points_sampled_value),
            self.dim,
            self._num_sampled,
            self.objective_type,
            cpp_utils.cppify_hyperparameters(self.hyperparameters),
            cpp_utils.cppify(self._points_sampled_noise_variance),
        )
Ejemplo n.º 3
0
    def compute_log_likelihood(self):
        r"""Compute the objective_type measure at the specified hyperparameters.

        :return: value of log_likelihood evaluated at hyperparameters (``LL(y | X, \theta)``)
        :rtype: float64

        """
        return C_GP.compute_log_likelihood(
            cpp_utils.cppify(self._points_sampled),
            cpp_utils.cppify(self._points_sampled_value),
            self.dim,
            self._num_sampled,
            self.objective_type,
            cpp_utils.cppify_hyperparameters(self.hyperparameters),
            cpp_utils.cppify(self._points_sampled_noise_variance),
        )