fit
Nonlinear least-squares fit of a model to measured data (Levenberg-Marquardt and trust-region, SciPy, exact complex-step derivatives, tolerances at machine precision): parameters, standard errors from s^2 (J^T J)^-1, residual sum of squares, residual standard deviation, predictions at given x. Files: fit.csv (x, y, fitted, residual), fit.png (data, curve, residuals). `converged` is true only when the solution passes its checks (stop reason, gradient, conditioning, finite errors); otherwise `warnings` says why.
- Field
- Measurement and data
- Version
- 0.2.0
- Runs as
- Compiled (Rust)
- Typical run
- 2 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001exact data y = 3 exp(-0.5 x) + 1 from a poor start: parameters recovered to 1e-9, RSS 0passed
params.a{"value": 3, "rel_tol": 1e-09}params.k{"value": 0.5, "rel_tol": 1e-09}params.c{"value": 1, "rel_tol": 1e-09}rss≤ 1e-203.9443e-31lockedinside the ranger0002straight line against the ordinary-least-squares formulas: slope 1.99 (SE 0.0597216), intercept 0.05 (SE 0.198074), RSS 0.107, prediction 11.99 at x = 6passed
params.b1{"value": 1.99, "rel_tol": 1e-09}params.b0{"value": 0.05, "rel_tol": 1e-07}std_errors.b1{"value": 0.0597215762, "rel_tol": 1e-06}std_errors.b0{"value": 0.1980740602, "rel_tol": 1e-06}rss0.107 ± 1.1e-100.107lockedunder 0.01 % of the tolerance usedpredictions.6{"value": 11.99, "rel_tol": 1e-09}r0003a saturated start is caught: a exp(-k x) from k = 60 with lm alone must not be reported convergedpassed
converged= falsefalselockedexact match
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
csv | Data with a header row. | ||
data | Inline CSV text, used when csv is not given. | ||
x | Predictor column. Default: the first column. | ||
y | Response column. Default: the second column. | ||
model | Expression in x and the parameters, e.g. "b1*(1-exp(-b2*x))". ^ is a power. Functions: exp, log, log10, sqrt, sin, cos, tan, tanh, arctan, abs, pi, e. | ||
params | Parameter names and starting values, e.g. {"b1": 1, "b2": 1}. | ||
method | auto | auto: Levenberg-Marquardt and trust-region, keep the better trustworthy fit. lm, trf, dogbox: one method. | |
max_evaluations | 20000 | ||
predict | x values at which to report the fitted model. | ||
title |
Readings
| Name | Unit | Meaning |
|---|---|---|
params | ||
std_errors | ||
rss | ||
residual_sd | ||
dof | ||
converged | ||
predictions | ||
fit.csv | ||
fit.png | ||
warnings | ||
condition | ||
method |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.