Ejemplo n.º 1
0
 def test_cdfNormal(self):
     from GPy.util.univariate_Gaussian import cdfNormal
     pySols = [
         2.86651571879e-07, 0.211855398583, 0.5, 0.691462461274,
         0.977249868052, 1.0
     ]
     diff = 0.0
     for i in range(len(pySols)):
         diff += abs(cdfNormal(self.zz[i]) - pySols[i])
     self.assertTrue(diff < 1e-10)
Ejemplo n.º 2
0
import GPy
import numpy as np
import scipy as sp
from GPy.inference.latent_function_inference.posterior import Posterior
from GPy.util import choleskies
from GPy.util.linalg import dpotrs, dtrtrs, jitchol, pdinv, tdot
from GPy.util.univariate_Gaussian import cdfNormal, derivLogCdfNormal, logCdfNormal, std_norm_cdf, std_norm_pdf
from scipy.integrate import dblquad, quad
from scipy.linalg import block_diag, inv, sqrtm
from scipy.special import logsumexp
from scipy.stats import multivariate_normal, norm

from ..util import adam

# Helper functions
phi = lambda x: cdfNormal(x)
sigmoid = lambda x: 1.0 / (1 + np.exp(-x))

dlogphi_df = lambda x: derivLogCdfNormal(x)
dlogsigmoid_df = lambda x: sigmoid(-x)
d2logsigmoid_df = lambda x: -sigmoid(-x) * sigmoid(x)


def dL_fr(L: np.ndarray, dsigma: np.ndarray, alpha: np.ndarray,
          beta: np.ndarray, K: np.ndarray):
    """
    Partial derivative of function with respect to beta using cholesky decomposition and the generalized matrix chain rule
    The ending _fr comes from "full rank", this method should be used when we use the full rank parametrization

    :param L: Cholesky decomposition of Sigma: Sigma= L L^T
    :param dsigma: derivative of the function with respect to Sigma