MCPcopy
hub / github.com/hyperopt/hyperopt / lognormal_cdf

Function lognormal_cdf

hyperopt/tpe.py:180–198  ·  view source on GitHub ↗
(x, mu, sigma)

Source from the content-addressed store, hash-verified

178
179@scope.define
180def lognormal_cdf(x, mu, sigma):
181 # wikipedia claims cdf is
182 # .5 + .5 erf( log(x) - mu / sqrt(2 sigma^2))
183 #
184 # the maximum is used to move negative values and 0 up to a point
185 # where they do not cause nan or inf, but also don't contribute much
186 # to the cdf.
187 if len(x) == 0:
188 return np.asarray([])
189 if x.min() < 0:
190 raise ValueError("negative arg to lognormal_cdf", x)
191 olderr = np.seterr(divide="ignore")
192 try:
193 top = np.log(np.maximum(x, EPS)) - mu
194 bottom = np.maximum(np.sqrt(2) * sigma, EPS)
195 z = old_div(top, bottom)
196 return 0.5 + 0.5 * erf(z)
197 finally:
198 np.seterr(**olderr)
199
200
201@scope.define

Callers 2

qlognormal_lpdfFunction · 0.85
LGMM1_lpdfFunction · 0.85

Calls 1

minMethod · 0.80

Tested by

no test coverage detected