def ff(self, x, mu, sigma): r""" Failure (CDF or unreliability) function for the LogNormal Distribution: .. math:: F(x) = \Phi \left( \frac{\ln(x) - \mu}{\sigma} \right ) Parameters ---------- x : numpy array or scalar The values at which the function will be calculated mu : numpy array or scalar The location parameter for the LogNormal distribution sigma : numpy array or scalar The scale parameter for the LogNormal distribution Returns ------- ff : scalar or numpy array The value(s) of the failure function at x. Examples -------- >>> import numpy as np >>> from surpyval import LogNormal >>> x = np.array([1, 2, 3, 4, 5]) >>> LogNormal.ff(x, 3, 4) array([0.22662735, 0.28206661, 0.31726986, 0.34331728, 0.36405509]) """ return norm.cdf(np.log(x), mu, sigma)
def ff(self, x, mu, sigma): r""" CDF (or unreliability or failure) function for the Normal Distribution: .. math:: F(x) = \Phi \left( \frac{x - \mu}{\sigma} \right ) Parameters ---------- x : numpy array or scalar The values at which the function will be calculated mu : numpy array or scalar The location parameter for the Normal distribution sigma : numpy array or scalar The scale parameter for the Normal distribution Returns ------- ff : scalar or numpy array The value(s) of the failure function at x. Examples -------- >>> import numpy as np >>> from surpyval import Normal >>> x = np.array([1, 2, 3, 4, 5]) >>> Normal.ff(x, 3, 4) array([0.30853754, 0.40129367, 0.5 , 0.59870633, 0.69146246]) """ return norm.cdf(x, mu, sigma)
def reparameterize(x, prior=None): if prior == None: return x elif prior == 'horseshoe': eta = np.tan(.5 * np.pi * norm.cdf(x)) return eta**2 * x elif prior == 'exp': return -np.log(x) elif prior == 'laplace': return -np.sign(x) * np.log(1 - 2 * x) elif prior == 'lognorm': return np.exp(x) elif prior == 'IG': return 1 / x elif prior == 'dropout': return npr.binomial(1, .8, size=x.shape) * x
def expected_new_max(mean, std, max_so_far): return max_so_far - \ (mean - max_so_far) * norm.cdf(mean, max_so_far, std) \ + std * norm.pdf(mean, max_so_far, std)
def probability_of_improvement(mean, std, max_so_far): return norm.cdf(max_so_far, mean, std)
import autograd.numpy as np import pylab as plt from autograd.scipy.stats import norm, t, multivariate_normal as mvn import GPy from util import plot_with_uncertainty import ep_unimodality_2d as ep from importlib import reload reload(ep) # auxilary functions phi = lambda x: norm.cdf(x) npdf = lambda x, m, v: 1. / np.sqrt(2 * np.pi * v) * np.exp(-(x - m)**2 / (2 * v)) ####################################################################################################################################################3 # Parameters ####################################################################################################################################################3 # set seed np.random.seed(1000) # dimension D = 4 ####################################################################################################################################################3 # Define test objective function ####################################################################################################################################################3
def objective(p): return norm.cdf(p)
def _cumulative_hazard(self, params, times): mu_, sigma_ = params Z = (np.log(times) - mu_) / sigma_ cdf = norm.cdf(Z, loc=0, scale=1) cdf = np.clip(cdf, 0.0, 1 - 1e-14) return -np.log1p(-cdf)