What Is Curve Fitting?
Curve fitting means choosing a function and estimating its parameters so that it follows your data. Different shapes suit different patterns: a polynomial for general bends, an exponential for growth or decay, a power law for scaling and a logarithmic curve for slowing growth.
Comparing models by R² alone favours complex models, so the calculator also reports adjusted R² and AICc, which penalise extra parameters, and tells you which model AICc prefers. For a fit that is not reducible to a straight line, see the nonlinear regression calculator.
Below you will find the formulas, a variables table, a worked example and answers to common questions such as how to choose between models and why extrapolation is risky.
How to Use the Curve Fitting Calculator
- Enter x and y values in matching order (at least 4 points).
- Leave the model on “Automatic” to feature the best by AICc, or choose a specific model.
- Check the comparison table and the scatter plot. A good fit follows the points without wild swings.
- Optionally enter an x to predict y. Be cautious outside the range of your data.
Curve Fitting Formula
Polynomial of degree d
Exponential
Power
Logarithmic
Corrected Akaike criterion
Curve Fitting Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| x, y | Your paired data | |
| ŷ | Fitted value from the model | |
| R² | Share of variation explained | 1 − SSE ÷ SST |
| AICc | Small-sample corrected AIC | Lower is better |
| RMSE | Root mean squared error | Same units as y |
Curve Fitting Worked Example
Using the example values (press “Load example” above to try them):
- Each model is fitted by least squares: polynomials directly, and exponential, power and logarithmic models by transforming the data with logarithms and fitting a straight line.
- Models are then compared on the original y scale using SSE, R², RMSE and AICc, which penalises extra parameters to avoid overfitting.
- Selected model: Exponential. y = 0.99798 · e^(1.0003x).
- R² = 1 − SSE ÷ SST = 1 − 340.56 ÷ 439,675,520 = 1.
Result: Best model (lowest AICc): Exponential = y = 0.99798 · e^(1.0003x); R² = 1.
Choosing the right type of curve
Draw the scatter plot first. The shape usually tells you which families are plausible, and theory about the process should guide the choice more than R² alone.
| Pattern in the scatter plot | Try | Typical example |
|---|---|---|
| Straight line | Linear | Cost vs quantity |
| One bend, parabola | Quadratic | Projectile height, profit vs price |
| Rapid growth or decay by constant percentage | Exponential | Population, compound interest, radioactive decay |
| Straight on a log-log plot | Power | Area vs length, allometric scaling |
| Fast then levelling off | Logarithmic | Learning curves, diminishing returns |
| S-shaped | Logistic (use non-linear regression) | Adoption, saturation |
Overfitting: why R² alone is not enough
A polynomial of degree n − 1 passes exactly through n points and gives R² = 1, yet it is useless for prediction because it wiggles between the points. Adjusted R² and AICc penalise complexity. Prefer the simplest model that captures the pattern, and when you can, test the model on data it was not fitted to.
How the fits are computed
Polynomials are fitted by least squares on centred data for numerical stability. Exponential and power curves are fitted by taking logarithms and fitting a straight line, which is fast and robust but minimises error on the log scale; for the exact least squares fit on the original scale, use the non-linear regression calculator. All models are then compared using errors measured on the original y values.
Cautions
- Extrapolating polynomial curves beyond the data can give absurd values.
- Exponential and power fits require positive y (and positive x for power and log).
- Outliers can distort a fit; check residuals.
- A good fit does not prove the model reflects the underlying mechanism.
Where Curve Fitting Is Used
Finding a trend equation
Getting a formula that describes how y changes with x.
Comparing candidate models
Judging which shape fits the data best without just chasing R².
Interpolation
Estimating values between the measured points.
Lab and coursework
Fitting measured data to a model and reporting the equation.
Common Curve Fitting Mistakes to Avoid
- Use the lowest degree that fits well.
- Compare models by AICc, not R² alone.
- Transform checks: a straight line on semi-log paper suggests exponential; on log-log suggests a power law.
Curve Fitting Terms and Definitions
- Overfitting
- A model so flexible that it fits noise rather than the underlying pattern.
- AICc
- Akaike information criterion corrected for small samples; lower is better.
- RMSE
- Root mean squared error of the fit, in the units of y.
Curve Fitting FAQs
What is curve fitting?
Finding a function whose graph follows your data points as closely as possible, using a criterion such as least squares.
How do I choose between a polynomial and an exponential fit?
Look at the plot and the physical process. Compare AICc and adjusted R². If growth is by a constant percentage, exponential is usually right.
Why does a high-degree polynomial fit so well but predict badly?
It adapts to random noise in the points and oscillates between and beyond them. This is overfitting.
What does R² mean for a curve fit?
The share of the variation in y explained by the curve. It is 1 for a perfect fit, though that may be overfitting.
Why do some models not appear?
Exponential and power models need positive y, and power and logarithmic models need positive x.
Can I get the exact least squares exponential fit?
This tool fits via logarithms. For an exact non-linear least squares fit of y = Ae^{Bx}, use the non-linear regression calculator.