mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 12:02:38 +02:00
Partial changes to symbolic, including adding mapping covariance and beginning to unify code generation.
This commit is contained in:
parent
19b3784389
commit
9b5a1edb23
9 changed files with 252 additions and 132 deletions
|
|
@ -1,18 +1,21 @@
|
|||
import numpy as np
|
||||
from scipy.special import erf, erfcx
|
||||
from scipy.special import erf, erfc, erfcx
|
||||
import sys
|
||||
epsilon = sys.float_info.epsilon
|
||||
lim_val = -np.log(epsilon)
|
||||
|
||||
def cum_gaussian(x):
|
||||
g=0.5*(1+erf(x/np.sqrt(2)))
|
||||
def logisticln(x):
|
||||
return np.where(x<lim_val, np.where(x>-lim_val, -np.log(1+np.exp(-x)), -x), -np.log(1+epsilon))
|
||||
|
||||
def logistic(x):
|
||||
return np.where(x<lim_val, np.where(x>-lim_val, 1/(1+np.exp(-x)), epsilon/(epsilon+1)), 1/(1+epsilon))
|
||||
|
||||
def normcdf(x):
|
||||
g=0.5*erfc(-x/np.sqrt(2))
|
||||
return np.where(g==0, epsilon, np.where(g==1, 1-epsilon, g))
|
||||
|
||||
def ln_cum_gaussian(x):
|
||||
return np.where(x < 0, -.5*x*x + np.log(.5) + np.log(erfcx(-np.sqrt(2)/2*x)), np.log(cum_gaussian(x)))
|
||||
def normcdfln(x):
|
||||
return np.where(x < 0, -.5*x*x + np.log(.5) + np.log(erfcx(-x/np.sqrt(2))), np.log(normcdf(x)))
|
||||
|
||||
def clip_exp(x):
|
||||
if any(x>=lim_val) or any(x<=-lim_val):
|
||||
return np.where(x<lim_val, np.where(x>-lim_val, np.exp(x), np.exp(-lim_val)), np.exp(lim_val))
|
||||
else:
|
||||
return np.exp(x)
|
||||
return np.where(x<lim_val, np.where(x>-lim_val, np.exp(x), epsilon), 1/epsilon)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue