Curve Fitting and Regression
Experimental data is always noisy. Curve fitting constructs a mathematical model that represents the underlying trend while tolerating random error. Unlike interpolation, the fitted curve need not pass through every data point.
Method of Least Squares
The dominant technique is the method of least squares, which minimizes the sum of squared residuals S = Σ (yi − f(xi))2. Least squares is computationally tractable, has a unique solution for linear models, and has sound statistical interpretations when errors are normally distributed.
Linear Regression
The simplest model is a line y = a + b x. Minimizing S leads to the normal equations: b = (nΣ xiyi − Σ xi Σ yi) / (nΣ xi2 − (Σ xi)2), and a = (Σ yi − b Σ xi) / n. This linear regression is implemented in every statistics package.
Polynomial Regression
When linear models are inadequate, a polynomial y = a0 + a1x + ... + amxm can be fit. The parameters still satisfy a linear system, though the system becomes ill-conditioned for high degrees. Orthogonal polynomials mitigate this.
Multiple Regression
With multiple independent variables, multiple linear regression fits y = β0 + β1x1 + ... + βkxk. The solution is given in matrix form by β = (XTX)-1XTy. Modern methods use QR decomposition or singular value decomposition for numerical stability.
Nonlinear Regression
When the model cannot be made linear by a transformation, we minimize S iteratively. Gauss–Newton and Levenberg–Marquardt algorithms are common. They require initial guesses and can converge to local minima, demanding careful use.
Linearization of Nonlinear Models
Some nonlinear models become linear after transformation. Exponential y = aebx yields ln y = ln a + bx; power law y = axb yields log y = log a + b log x. Transformation alters the error structure, so results differ slightly from direct nonlinear fits.
Goodness of Fit
The coefficient of determination R2 measures the fraction of variance explained by the fit, ranging from 0 (no fit) to 1 (perfect). The correlation coefficient r is its square root in linear regression. Residual plots reveal whether the model captures systematic trends or merely fits noise.
Overfitting and Model Selection
Adding more parameters always decreases residual sum of squares but can capture noise rather than signal—overfitting. Information criteria (AIC, BIC), cross-validation, and statistical hypothesis tests help choose a model with an appropriate complexity.
Outliers and Robust Regression
Least squares is sensitive to outliers; a single bad data point can dominate the fit. Robust regression methods, such as least absolute deviations (L1) or M-estimators like Huber's, reduce outlier influence.
Summary
Curve fitting extracts structure from noisy data. Linear and polynomial regression solve most practical problems; nonlinear regression handles the rest. Beyond fitting, thoughtful analysis of residuals and model complexity is essential for reliable conclusions.