Instructions
Data formats
1. MRA style, with an optional sigma column for instrumental weighting:
any notes, ignored until the first double colon...
:: Title of the run <- text after the marker becomes the title
1 2 3 x, y, sigma columns <- sigma column optional (leave it off or 0 = none)
0.0 11.52 0.40 <- RAW data rows: spaces, tabs or commas
...
15.0 1.53 0.12 :: End <- a double colon ends the data; this row is kept
2. Raw / AD3 files (as GRIDFIT 1990 read them): with no double colon anywhere, every line that
starts with two numbers is a data point (x, y) and everything else is skipped. AD3 acquisition files
(ADCHAN-A.DAT) load directly; their "Experiment Title:" line becomes the title.
Do not type a double colon in notes above the start marker of an MRA-style file.
Weighting (GRIDFIT mode)
| Weighting | w per point | Use for | Std errors |
| none (mode 0) | 1 | equal, unknown noise | scaled by χ²/df |
| statistical (mode −1) | 1/|y| (y = 0 → 1) | counts, Poisson noise σ² = y | scaled by χ²/df |
| instrumental (mode +1) | 1/σ² from the sigma column | known measurement errors | absolute; χ²/df ≈ 1 means model and σ agree |
All methods minimise χ² = Σ w·(y − f)². With instrumental weighting the report adds
P(χ² ≥ observed): a very small value means the model or the stated σs are wrong.
Model block contract (model.js)
The block is the body of a function and must return an object:
return {
TITLE: "Exponential decay",
EQUATION: "y = A·exp(−k·x) + C", // shown under the parameter table
LABEL_X: "time (s)", LABEL_Y: "signal",
LOG_X: false, // start with a log x axis
PARAMS: [ // order = order of p[] in f()
{ name: "A", init: 5 },
{ name: "k", init: 1, min: 0 }, // optional min / max bounds,
// optional step (Bevington DELTAA)
{ name: "C", init: 0 },
],
f: function (x, p) {
const [A, k, C] = p;
return A * Math.exp(-k * x) + C;
},
};
Methods and switching
GO runs the selected method; STOP halts it. Change the Method menu at any time: while running
the switch is immediate, or STOP → switch → GO. Every method continues from the current
parameters. Step runs one iteration of the selected method.
| Method | Use it when | Notes |
| AUTO | you do not know which to pick | global search first (DE if every parameter has min and max, otherwise NM) until progress stops, then hands over to LM by itself; the log shows the handover |
| LM Levenberg-Marquardt | almost always | blends gradient descent (far) and Gauss-Newton (near) through its damping λ |
| GN Gauss-Newton | already close to the answer | fastest near the minimum; step-halving keeps it stable, but it can stall far away |
| NM Nelder-Mead | poor starting values, rough models | no derivatives; its simplex follows correlated valleys; finish with LM |
| DE Differential Evolution | several local minima (oscillations, peaks) | global search inside the bounds; unbounded parameters search ±(2·|value|+1); finish with LM |
| GRIDLS (Bevington) | teaching, comparison | one parameter at a time with a parabola through the last 3 points; slow when parameters are correlated (zig-zags across the valley) |
| GRADLS (Bevington) | teaching, comparison | steepest descent with a line search; also zig-zags in narrow valleys |
| CHIFIT (Bevington) | teaching, comparison | Newton step on a numerical χ² Hessian (many evaluations per step), damped by 0.2 and a line search |
| CURFIT (Bevington) | same job as LM | Marquardt's method; the 1990 port evaluated χ² at the old parameters, so the λ test never fired. Restored here, with a finer derivative step |
The Bevington methods step each parameter by an increment Δa (Bevington's DELTAA): a parameter's
step in PARAMS, else 10% of its starting value (0.1 if it starts at 0). GRIDLS
adapts Δa as it goes. The χ² evaluations counter (full passes over the data) lets you
compare how much work each method needs; Reset clears it.
Report
- Standard errors come from (J′WJ)−1 at the final parameters: scaled by χ²/df for none and
statistical weighting, absolute for instrumental weighting. This is the usual asymptotic (linearised) estimate,
matching SciPy curve_fit (absolute_sigma False / True).
- Confidence intervals and p-values assume independent, normally distributed errors. Points along one smooth
trace are correlated, so treat them as optimistic there.
- High parameter correlations (|r| > 0.95) mean the data cannot separate those parameters well.
- AIC = n·ln(SSE/n) + 2p compares models on the same data: lower is better.
Lua / Pascal to JavaScript
| x ^ 2 | x ** 2 |
| exp(x), ln(x) | Math.exp(x), Math.log(x) |
| arrays from 1 | arrays from 0: p[0] is the first parameter |
NLCF V2026.2 Web · Non-Linear Curve Fitting © CompuRight Industries, G. Argraves · by Gary Argraves & Claude