madgui.util.fit module

Utilities for fitting objective functions.

Functions

fit(f, x0[, algorithm])

Fit objective function f(x) = y, start from x0.

reduced_chisq(residuals[, ddof])

Compute reduced chi-squared.

fit_basinhopping(f, x0[, iterations, T, …])

Global optimization of f(x) = y based on scipy.optimize.basinhopping().

fit_diffevo(f, x0[, delta, bounds, …])

Global optimization of f(x) = y based on scipy.optimize.differential_evolution().

fit_minimize(f, x0[, iterations])

Fit objective function f(x) = y using least-squares fit via scipy.optimize.minimize.

fit_svd(f, x0[, jac, tol, delta, …])

Fit objective function f(x) = y using a naive repeated linear least-squares fit using the svd-based pseudo inverse.

fit_lstsq(f, x0[, jac, tol, delta, …])

Fit objective function f(x) = y using a naive repeated linear least-squares fit.

fit_lstsq_oneshot(lstsq, f, x0[, y0, delta, …])

Single least squares fit for f(x) = y around x0.

jac_twopoint(f, x0[, y0, delta])

Compute jacobian df/dx_i using two point-finite differencing.

madgui.util.fit.fit(f, x0, algorithm='minimize', **kwargs) → scipy.optimize.optimize.OptimizeResult[source]

Fit objective function f(x) = y, start from x0. Returns scipy.optimize.OptimizeResult.

madgui.util.fit.fit_basinhopping(f, x0, iterations=20, T=1.0, stepsize=0.01, **kwargs)[source]

Global optimization of f(x) = y based on scipy.optimize.basinhopping().

madgui.util.fit.fit_diffevo(f, x0, delta=0.001, bounds=None, iterations=20, method='best1bin', **kwargs)[source]

Global optimization of f(x) = y based on scipy.optimize.differential_evolution().

madgui.util.fit.fit_lstsq(f, x0, jac=None, tol=1e-08, delta=None, iterations=None, callback=None, rcond=0.01, lstsq=None)[source]

Fit objective function f(x) = y using a naive repeated linear least-squares fit.

madgui.util.fit.fit_lstsq_oneshot(lstsq, f, x0, y0=None, delta=None, jac=None, rcond=1e-08)[source]

Single least squares fit for f(x) = y around x0. Returns (Δx, Δy), where Δy is the linear hypothesis for how much y will change due to change in x.

madgui.util.fit.fit_minimize(f, x0, iterations=None, **kwargs)[source]

Fit objective function f(x) = y using least-squares fit via scipy.optimize.minimize.

madgui.util.fit.fit_svd(f, x0, jac=None, tol=1e-08, delta=None, iterations=None, callback=None, rcond=0.01)[source]

Fit objective function f(x) = y using a naive repeated linear least-squares fit using the svd-based pseudo inverse.

madgui.util.fit.jac_twopoint(f, x0, y0=None, delta=0.001)[source]

Compute jacobian df/dx_i using two point-finite differencing.

madgui.util.fit.reduced_chisq(residuals, ddof=0)[source]

Compute reduced chi-squared.