Math & Units

Curve Fitting

/kurv FIT-ing/
A numerical procedure that builds a continuous mathematical function to approximate a set of discrete measurement points, usually by minimizing the sum of squared residuals between the model and the data. In RF and microwave work it converts swept measurements, such as S-parameters, gain, and noise figure, into compact analytic models that support interpolation between frequency points, smooth extrapolation, and broadband de-embedding. Common methods range from low-order least-squares polynomials for magnitude trends to rational and vector-fitting models with 2 to 20 poles for resonant networks, and the engineer balances residual error against model order to avoid fitting instrument noise rather than device physics.
Category: Math & Units
Common Method: Least Squares / Vector Fit
Target RMS Error: < 0.1 dB

From Discrete Samples to Continuous RF Models

A vector network analyzer reports a device under test only at the discrete frequencies it sweeps, perhaps 201 or 1601 points across a band. Many downstream tasks need values everywhere in between or a closed-form expression that a circuit simulator can evaluate: time-domain convolution, statistical yield analysis, and behavioral macromodeling all require a continuous description. Curve fitting supplies that description by selecting a parameterized function family and solving for the parameter set that minimizes the deviation from the measured samples. The defining feature is that the model has fewer free parameters than data points, so it cannot pass through every sample; instead it captures the dominant behavior while averaging out random measurement noise on the order of 0.05 dB in magnitude and a few hundredths of a degree in phase.

The most common formulation is linear least squares, where the model is linear in its coefficients even if it is a high-degree polynomial in frequency. The normal equations then yield a closed-form solution. Resonant RF structures, however, are poorly represented by polynomials because their sharp poles and zeros demand a ratio of polynomials. Rational fitting and the closely related vector-fitting algorithm address this by placing complex-conjugate pole pairs that correspond directly to physical resonances, which is why vector fitting has become the standard route from measured S-parameters to passive, causal SPICE macromodels.

Across both formulations the central engineering judgment is model order. Too few parameters underfit and leave structured residual error; too many overfit, chasing noise and producing models that ring or go non-passive when extrapolated outside the measured band. Plotting root-mean-square residual versus order reveals a knee where added parameters stop reducing real error, and that knee sets the order an experienced engineer accepts.

Least Squares and Goodness of Fit

Least-Squares Objective:
minimize  S = ∑i=1N wi × |yi − f(xi, β)|2

Coefficient of Determination:
R2 = 1 − (SSres / SStot)

Root-Mean-Square Residual:
RMSE = √( (1/N) × ∑i=1N |yi − f(xi, β)|2 )

Rational / Vector-Fit Model:
f(s) ≈ ∑k=1P rk / (s − pk) + d + s·e

Where yi = measured data, f = model, β = parameter vector, wi = weights, N = sample count, SSres/SStot = residual/total sum of squares, P = pole count, pk/rk = poles/residues, s = jω. Example: a 4-pole vector fit of a cavity S21 reaches RMSE ≈ 0.03 dB.

Choosing a Fitting Method

MethodModel FormTypical OrderBest ForMain Risk
Linear least squares (polynomial)Polynomial in f2 to 6 degreeSmooth magnitude / gain slopeOscillation at high degree
Rational fittingRatio of polynomials4 to 16 polesResonant S-parametersSpurious poles
Vector fittingPole-residue sum8 to 20 polesPassive SPICE macromodelsNon-passivity if unconstrained
Nonlinear least squaresArbitrary f(x, β)3 to 8 paramsEquivalent-circuit extractionLocal minima, needs seed
Cubic spline (interpolation)Piecewise cubicN segmentsNoise-free dense sweepsAmplifies measurement noise
Common Questions

Frequently Asked Questions

What is the difference between curve fitting and interpolation?

Interpolation forces the model through every measured point, so it reproduces all samples but can oscillate between them and amplify instrument noise. Curve fitting uses fewer parameters than data points and minimizes aggregate residual error, capturing the underlying trend while rejecting random noise on the order of 0.05 to 0.1 dB. Use interpolation for noise-free dense sweeps; use fitting to extract a compact, noise-robust model.

How do you choose the model order for fitting S-parameters?

Order is the pole count in a rational or vector fit, or polynomial degree in least squares. Increase order while watching the RMS residual: it drops then flattens, and the knee sets the right order. A single resonance needs 2 to 4 poles, a multi-cavity filter 8 to 20. Beyond the knee you fit noise, not physics, which causes overfitting and unstable extrapolation. Vector fitting with passivity enforcement is the standard for SPICE macromodels.

What does R-squared tell you about an RF curve fit?

R2 reports the fraction of data variance the model explains, from 0 to 1; above 0.99 is usually adequate for magnitude data. It is not sufficient alone: it always rises with more parameters and underweights nulls, so a fit can look excellent yet miss a stopband notch. Engineers also inspect the residual plot for structure, report RMSE in dB, and verify the complex model stays causal and passive across the band.

Measured-Data Modeling

Need Validated Component Models?

RF Essentials delivers millimeter-wave components with measured S-parameters and vector-fitted models you can drop straight into your simulator. Talk to our engineering team about your design.

Get in Touch