def grad_log_likelihood(self, y, quiet=False):
        """
        Compute the gradient of :func:`GP.log_likelihood` as a function of the
        parameters returned by :func:`GP.get_parameter_vector`. You must call
        :func:`GP.compute` before this function.

        :param y: ``(nsamples,)``
            The list of observations at coordinates ``x`` provided to the
            :func:`compute` function.

        :param quiet:
            If ``True`` return a gradient of zero instead of raising an
            exception when there is an invalid kernel or linear algebra
            failure. (default: ``False``)

        """
        # Make sure that the model is computed and try to recompute it if it's
        # dirty.
        if not self.recompute(quiet=quiet):
            return np.zeros(len(self), dtype=np.float64)

        # Pre-compute some factors.
        try:
            alpha = self._compute_alpha(y, False)
        except ValueError:
            if quiet:
                return np.zeros(len(self), dtype=np.float64)
            raise

        if len(self.white_noise) or len(self.kernel):
            K_inv = self.solver.get_inverse()
            A = np.einsum("i,j", alpha, alpha) - K_inv

        # Compute each component of the gradient.
        grad = np.empty(len(self))
        n = 0

        l = len(self.mean)
        if l:
            try:
                mu = self._call_mean_gradient(self._x)
            except ValueError:
                if quiet:
                    return np.zeros(len(self), dtype=np.float64)
                raise
            grad[n:n+l] = np.dot(mu, alpha)
            n += l

        l = len(self.white_noise)
        if l:
            wn = self._call_white_noise(self._x)
            wng = self._call_white_noise_gradient(self._x)
            grad[n:n+l] = 0.5 * np.sum((np.exp(wn)*np.diag(A))[None, :]*wng,
                                       axis=1)
            n += l

        l = len(self.kernel)
        if l:
            Kg = self.kernel.get_gradient(self._x)
            grad[n:n+l] = 0.5 * np.einsum("ijk,ij", Kg, A)

        return grad
def grad_log_likelihood ( self , y , quiet = False ) : if not self . recompute ( quiet = quiet ) : return np . zeros ( len ( self ) , dtype = np . float64 ) try : alpha = self . _compute_alpha ( y , False ) except ValueError : if quiet : return np . zeros ( len ( self ) , dtype = np . float64 ) raise if len ( self . white_noise ) or len ( self . kernel ) : K_inv = self . solver . get_inverse ( ) A = np . einsum ( "i,j" , alpha , alpha ) - K_inv grad = np . empty ( len ( self ) ) n = 0 l = len ( self . mean ) if l : try : mu = self . _call_mean_gradient ( self . _x ) except ValueError : if quiet : return np . zeros ( len ( self ) , dtype = np . float64 ) raise grad [ n : n + l ] = np . dot ( mu , alpha ) n += l l = len ( self . white_noise ) if l : wn = self . _call_white_noise ( self . _x ) wng = self . _call_white_noise_gradient ( self . _x ) grad [ n : n + l ] = 0.5 * np . sum ( ( np . exp ( wn ) * np . diag ( A ) ) [ None , : ] * wng , axis = 1 ) n += l l = len ( self . kernel ) if l : Kg = self . kernel . get_gradient ( self . _x ) grad [ n : n + l ] = 0.5 * np . einsum ( "ijk,ij" , Kg , A ) return grad
Compute the gradient of :func:`GP.log_likelihood` as a function of the
        parameters returned by :func:`GP.get_parameter_vector`. You must call
        :func:`GP.compute` before this function.

        :param y: ``(nsamples,)``
            The list of observations at coordinates ``x`` provided to the
            :func:`compute` function.

        :param quiet:
            If ``True`` return a gradient of zero instead of raising an
            exception when there is an invalid kernel or linear algebra
            failure. (default: ``False``)