Early Preview·This tool is in active development. Results may need verification.

Curve Fitting

Fit Gaussian, Lorentzian, and pseudo-Voigt peaks to spectral data with Levenberg-Marquardt optimization

Your spectral data is never saved on our servers. Runs in your browser.
Use Full Workbench →

Supported Formats

JCAMP-DXSPCBruker OPUSThermo SPARenishaw WDFHoriba NGS/L6SPerkinElmer SPCSVTXT

What Is Curve Fitting in Spectroscopy?

Curve fitting — also called peak deconvolution or band decomposition — is the process of modeling a measured spectrum as a sum of individual peak functions. Every spectral band arises from a physical transition (molecular vibration, electronic excitation, Raman shift), and when bands overlap, the raw spectrum shows a single broad feature. Curve fitting recovers the individual components, giving you center positions, widths, and areas you can use for quantitative analysis, band assignment, and material identification.

SpectralBench uses Levenberg-Marquardt nonlinear least-squares optimization — the same algorithm used in Origin, Fityk, and MATLAB's Curve Fitting Toolbox — running entirely in your browser with no server upload. Drop a file, initialize peaks, click “Run Fit,” and get R², FWHM, and integrated areas in seconds.

Peak Shape Models

Gaussian

f(x) = A · exp(-4 ln(2) · (x - x₀)² / w²)

The Gaussian (normal distribution) profile models peaks broadened by inhomogeneous effects — statistical distributions of slightly different environments. Common in solid-state FTIR (amorphous polymers, powders), Doppler-broadened emission lines, and any situation where the broadening arises from a distribution of center frequencies rather than a single decay process.

Lorentzian

f(x) = A · w² / (4(x - x₀)² + w²)

The Lorentzian (Cauchy) profile arises from homogeneous broadening — a single exponential decay in the time domain, as described by the Fourier transform of a damped oscillator. It produces broader tails than a Gaussian. Common in Raman spectroscopy (natural linewidths of vibrational modes), pressure-broadened gas-phase spectra, and NMR lineshapes.

Pseudo-Voigt

f(x) = η · L(x) + (1 - η) · G(x),   0 ≤ η ≤ 1

The pseudo-Voigt profile is a linear combination of Gaussian and Lorentzian functions, controlled by the mixing parameter η. When η = 0 the peak is pure Gaussian; when η = 1 it is pure Lorentzian. Real spectroscopic peaks often exhibit both broadening mechanisms simultaneously, making the pseudo-Voigt the most physically general model. SpectralBench optimizes η alongside amplitude, center, and width.

When to Use Curve Fitting

  • Overlapping band deconvolution — Resolve peaks hidden under a broad envelope, such as the amide I and amide II bands in protein FTIR or overlapping C-H stretches in polymer spectra.
  • Quantitative analysis — Integrated peak areas are proportional to concentration (Beer-Lambert law). Curve fitting gives accurate areas even when bands overlap, enabling compositional analysis of mixtures.
  • Band assignment — Extract precise center frequencies for comparison against reference databases. Fitted centers are more accurate than apparent maxima when peaks are asymmetric or overlapping.
  • Linewidth studies — FWHM values from curve fitting reveal broadening mechanisms, crystallinity, molecular ordering, and instrument resolution effects.

Understanding R² (Goodness of Fit)

R² measures the fraction of variance in your measured data that is explained by the fitted model. An R² of 1.0 means a perfect fit; 0 means the model explains nothing. In practice:

  • > 0.99Excellent — the model captures essentially all spectral features.
  • 0.95–0.99Good for most analytical work. Minor residual structure may indicate a missing minor peak or baseline artifact.
  • 0.90–0.95Acceptable for qualitative work, but inspect the residual plot for systematic patterns.
  • < 0.90Poor — likely missing peaks, wrong model, or baseline not corrected. Try preprocessing first.

Beware overfitting:adding more peaks always increases R², but peaks without a physical basis produce meaningless parameters. Every peak in your model should correspond to a real spectral transition. Use the residual plot — random noise in the residual means a good fit; systematic wiggles mean a missing peak or wrong model.

Need baseline correction or smoothing before fitting? Spectral Preprocessing →

Identify functional groups from peak positions? FTIR Peak Identifier →

Classify multi-spectrum datasets? PCA & Chemometrics →

Frequently Asked Questions

What is curve fitting in spectroscopy?

Curve fitting in spectroscopy is the process of decomposing a measured spectrum into individual peak components. Each peak is modeled with a mathematical function (Gaussian, Lorentzian, or Voigt), and an optimization algorithm adjusts the parameters — center, amplitude, and width — until the sum of all peaks matches the measured data. This reveals overlapping bands that visual inspection alone cannot resolve.

When should I use Gaussian vs. Lorentzian vs. Voigt profiles?

Use Gaussian profiles for peaks broadened by inhomogeneous effects (e.g., Doppler broadening, solid-state disorder in FTIR). Use Lorentzian profiles for peaks broadened by homogeneous mechanisms (e.g., natural lifetime broadening, pressure broadening in Raman). Use pseudo-Voigt when both mechanisms contribute — it blends Gaussian and Lorentzian with a mixing parameter η that the optimizer adjusts automatically.

What is R² and what value indicates a good fit?

R² (coefficient of determination) measures how well the fitted curve explains the variance in your data. An R² above 0.99 indicates an excellent fit; 0.95–0.99 is good for most spectroscopic applications. Values below 0.90 suggest missing peaks, wrong peak models, or a poor baseline. Adding more peaks improves R², but be cautious of overfitting — every peak should correspond to a physically meaningful spectral feature.

What is FWHM and why does it matter?

FWHM (Full Width at Half Maximum) is the width of a peak measured at half its maximum height. In spectroscopy, FWHM reflects the broadening mechanism: narrower peaks indicate higher spectral resolution or crystalline samples, while broader peaks suggest amorphous materials, overlapping transitions, or instrument-limited resolution. FWHM is directly comparable across spectra when peaks are fitted to the same model.

How does Levenberg-Marquardt optimization work?

Levenberg-Marquardt (LM) is a nonlinear least-squares algorithm that interpolates between gradient descent and the Gauss-Newton method. It iteratively adjusts peak parameters to minimize the sum of squared residuals between the data and the model. LM is the standard for spectroscopic curve fitting because it converges quickly for well-initialized peaks and handles correlated parameters (like overlapping peak centers) robustly.

Can I fix or constrain peak parameters during fitting?

Yes. SpectralBench lets you lock any parameter (amplitude, center, width, or Voigt mixing ratio) to prevent the optimizer from changing it. This is useful when you know a peak position from reference data or want to constrain the width to a physically reasonable range. Locked parameters are marked with a lock icon in the sidebar.

Features(7)
  • Gaussian, Lorentzian, and pseudo-Voigt peak models
  • Levenberg-Marquardt nonlinear least-squares optimization
  • Auto-initialize peaks from automatic detection or click to add manually
  • Lock/unlock individual parameters — center, amplitude, width, mixing ratio
  • R² goodness-of-fit, FWHM, integrated area, and percentage contribution per peak
  • Residual plot for visual inspection of fit quality
  • 100% client-side — no data uploaded, no account required

Related Tools