INNER CODE UNIT · Python
xt
sdv-dev/Copulas · copulas/optimize/__init__.py:98
xt = np.clip(a + t * (b - a), xmin, xmax)
ft = f(xt)
# update our history of the last few points so that
# - a is the newest estimate (we're going to update it from xt)
# - c and b get the preceding two estimates
# - a and b maintain opposite signs for f(a) and f(b)
samesign = np.sign(ft) == np.sign(fa)
c = np.choose(samesign, [b, a])
b = np.choose(samesign, [a, b])
fc = np.choose(samesign, [fb, fa])
fb = np.choose(samesign, [fa, fb])
a = xt
fa = ft
# set xm so that f(xm) is the minimum magnitude of f(a) and f(b)
fa_is_smaller = np.abs(fa) < np.abs(fb)
xm = np.choose(fa_is_smaller, [b, a])