Curve Fitting
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
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
| Method | Model Form | Typical Order | Best For | Main Risk |
|---|---|---|---|---|
| Linear least squares (polynomial) | Polynomial in f | 2 to 6 degree | Smooth magnitude / gain slope | Oscillation at high degree |
| Rational fitting | Ratio of polynomials | 4 to 16 poles | Resonant S-parameters | Spurious poles |
| Vector fitting | Pole-residue sum | 8 to 20 poles | Passive SPICE macromodels | Non-passivity if unconstrained |
| Nonlinear least squares | Arbitrary f(x, β) | 3 to 8 params | Equivalent-circuit extraction | Local minima, needs seed |
| Cubic spline (interpolation) | Piecewise cubic | N segments | Noise-free dense sweeps | Amplifies measurement noise |
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.