Nonlinear Curve Fitting in SciDAVis: A Step-by-Step Guide

Curve fitting finds the parameters of a mathematical model that best describe your data — a straight line for calibration curves, a Gaussian for a spectral peak, a sigmoid for a dose-response. SciDAVis offers two routes: Quick Fit for the most common models in one click, and the Fit Wizard for full control including custom formulas. Both live in the Analysis menu. This guide assumes your data is already in a table and plotted; if not, see how to import data first.

Version note: written for v2.9.x (SourceForge binaries are 2.8). The Analysis menu, Fit Wizard dialogs, and fitting engine are unchanged between the two.

Step 1 — Plot the curve you want to fit

Fitting always starts from a curve in a graph window, not from the raw table. Select your X and Y columns in the table, then create a plot (e.g. Scatter or Line+Symbol from the Plot menu). Click the curve in the graph so it is selected — the fit dialogs operate on the active curve of the active layer.

Step 2 — Try Quick Fit first

For the standard models, go to Analysis → Quick Fit and pick one: Fit Linear, Fit Gaussian, Fit Lorentzian, Fit Boltzmann (Sigmoidal), or Fit Multipeak → Gaussian for spectra with several peaks (you’ll be asked to click the approximate peak positions).

Quick Fit guesses the initial parameters from your data automatically, runs the fit, and draws the result curve onto your graph. For a calibration line or a single clean peak, this is often all you need.

Gauss vs. GaussAmp: the built-in list contains two Gaussian variants. Gauss uses a width parameter w (where w = 2σ), while GaussAmp is parameterized by amplitude. They fit the same shape — pick the one whose parameters match the convention of your field, and be consistent when comparing with other software.

Step 3 — Open the Fit Wizard for full control

When Quick Fit isn’t enough — a custom model, fixed parameters, or a fit range — choose Analysis → Fit Wizard. The wizard walks you through three decisions:

  1. Select the curve. Confirm which curve of the graph the fit applies to.
  2. Choose the model. Under Category: Built-in you’ll find the standard library: Linear, Polynomial, Exponential (and double/triple exponential), Gauss, GaussAmp, Lorentz, Sigmoidal, and more. Choose User-defined instead to type your own formula (next step).
  3. Set initial values. Enter starting guesses for every parameter. Then run the fit.

Step 4 — Write a custom model with muParser

For a user-defined fit, type the formula in muParser syntax — the same expression language SciDAVis uses for column formulas. The independent variable is x; declare your fit parameters as names. A Gaussian with baseline, for example:

y0 + A*exp(-((x-xc)/w)^2)

Available functions include exp(), ln(), log(), sin(), cos(), sqrt(), abs(), erf(), and the constants pi and e (see the scripting guide for the full function list). Keep the parameter count small: every extra parameter makes convergence harder.

Step 5 — Give good initial values (this is where fits fail)

Nonlinear fitting is iterative: the algorithm refines your guesses, and bad guesses converge to nonsense or don’t converge at all. Practical rules:

  • Read starting values off the plot: peak position from the x-axis, amplitude from the y-range, baseline from the flat regions.
  • Fit the simplest model first. A linear fit of a subset of the data gives you a baseline and slope to seed the nonlinear model.
  • If a fit diverges, fix the worst-behaved parameter to a reasonable constant and refit the rest — then release it.
  • Restrict the x-range to the region where the model actually applies (the wizard lets you limit the fit interval); outliers and unrelated shoulders poison the result.

Step 6 — Read the results

After the fit, SciDAVis does two things:

  • It draws the fit curve on your graph in red, so you can judge visually.
  • It writes the numbers to the Results Log (the log window collects every calculation): each parameter with its standard error, plus chi-square and R² as goodness-of-fit measures.
What to look atWhat it tells you
Parameter errorsAn error larger than the parameter value itself means that parameter is not determined by your data — simplify the model.
Chi-square (reduced)Near 1 suggests the model describes the data within its noise; far above 1 means a poor model or underestimated errors.
R²Fraction of variance explained. Useful for comparison, but a high R² with a systematic residual pattern still means the wrong model.
Residuals by eyeZoom the graph: residuals should scatter randomly around zero. A wave or trend in the residuals is the strongest signal to change models.

Step 7 — The same fit from Python (optional)

Repetitive fitting — the same peak model over dozens of spectra — belongs in a script. The documented Python API mirrors the wizard:

f = GaussFit(graph("Graph1").activeLayer(), "table1_2")
f.guessInitialValues()
f.fit()
print(f.results(), f.errors(), f.chiSquare(), f.rSquare())

Other verified fit classes: LinearFit, PolynomialFit, ExponentialFit, TwoExpFit, ThreeExpFit, GaussAmpFit, LorentzFit, SigmoidalFit, and NonLinearFit (with setFormula() for muParser expressions). Full details in the Python scripting guide.

Next steps

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *