Worked example: a spectrum with peaks and baseline
Fit two Gaussian bands and a linear background together, then check the residuals at the original wavelengths.
GX-TXT DEV112 P011-bis
Prepare the spectrum
Download the synthetic two-band spectrum (unzip the archive first). It contains 121 rows from 400 to 700 nm in steps of 2.5 nm. The absorbance combines a straight line equal to 0.2 at 550 nm, slope 0.00022 nm −1, two Gaussians and a reproducible perturbation of amplitude 0.005. For the sample numbered from zero, the perturbation is 0.005*sin(2.11*i). The reference centers are 491 and 608 nm.
In Acquisition → Generic CSV import it as table.generic, ID c28_two_peaks. Variables declare nm for wavelength_nm and 1 for absorbance. In Curve Fitter, assign these columns to X and Y, add the curve and choose Y = f(X), components, all points and source domain.
Build the model
Open Fit → Models and fitting → Model components…. Choose Linear baseline and press Add component. Add twice Gaussian peak (height, sigma). Each component opens a panel with equation, parameters, Initial, Lower, Upper, Fixed and sharing field. Remove selected component removes only the currently selected component. Cancel returns to the previous configuration.
| Component | Initial values | Case constraints |
|---|---|---|
| Baseline | intercept 0.079, slope 0.00022 nm⁻¹ | Free coefficients. |
| Low band | height 1.16, center 490 nm, sigma 14 nm | Height ≥ 0, center 470 – 515 nm, sigma ≥ 1 nm. |
| High band | height 0.72, center 609 nm, sigma 20 nm | Height ≥ 0, center 580 – 640 nm, sigma ≥ 1 nm. |
Leave Fixed off and the sharing empty for all quantities. The separate constraints on the centers preserve the identity of the bands. Apply saves the list. Press Preview fit.
Verify the centers, widths, and baseline
The fit returned centers of about 490.9998 and 607.9992 nm, sigma values of 12.9990 and 20.9952 nm, and peak heights of 1.19995 and 0.75991. The baseline slope is 0.00022047 nm⁻¹. The model uses intercept + slope × λ. At 550 nm this gives a baseline of about 0.200096. An independent least-squares calculation on the CSV reproduced these values to the rounding shown here.
In Residuals verify that 121 rows are available, with Y residual (observed − fit). The RMSE is about 0.00353117 in absorbance. Examine the residuals in regions far from the peaks and on the flanks of the bands. Comparing several backgrounds over the same range is more informative than reading only the peak heights. The purpose of the exercise is to estimate a baseline together with the bands, so the preparation uses the original data and the declared units.
Continue with a different candidate
To study the effect of the baseline, repeat the exercise with a different fit name and no linear component. Keep the range and the 121 observations. In the test with the two Gaussians alone, the RMSE rose to about 0.103382, compared with 0.00353117 with the baseline. Also compare the residuals in regions far from the peaks and at the centers, as in Compare models and accepted results. For an experimental spectrum, choose a correction or a baseline with a physical motivation and keep the original data.


