Curve Fitting Calculator

Enter points, choose a model, and calculate instantly. See equation, R-squared, and residual diagnostics below. Download CSV or PDF, then share insights with teams.

White Theme • Responsive

Calculator

Pick a curve type that matches your process.
Used only for polynomial fits.
Lines can be “x,y” or “x y”.
Use “x, y, w” where w > 0.
Removes points with |residual| > z·σ.
Repeat fit+filter up to 5 passes.
Controls rounding in equation and metrics.
More points make a smoother fitted line.
Adds a point estimate to the summary.
One point per line. Format: x, y or x y. With weights: x, y, w.

Example Data Table

Use this as a quick template. Add a third column for weights if needed.

Point x y w (optional)
101.01
212.11
323.91
436.21
547.81
6510.11

Formula Used

Least Squares (core idea)

The calculator finds parameters that minimize the weighted sum of squared residuals:

minimize   Σ wᵢ·(yᵢ − ŷᵢ)²

Weights are optional. If omitted, wᵢ = 1 for all points.

Linear Model

For y = a + b·x, the slope uses weighted covariance/variance:

b = Σ wᵢ(xᵢ−x̄w)(yᵢ−ȳw) / Σ wᵢ(xᵢ−x̄w)²

Then a = ȳw − b·x̄w.

Polynomial Model

For y = c₀ + c₁x + ... + cₙxⁿ, coefficients come from normal equations:

(Xᵀ W X)·c = Xᵀ W y

Solved with Gaussian elimination for degrees 2–6.

Transformed Nonlinear Models

Some models use a log transform then apply linear fitting:

  • y = a·e^(b·x) → fit ln(y) vs x (requires y>0)
  • y = a + b·ln(x) → fit y vs ln(x) (requires x>0)
  • y = a·x^b → fit ln(y) vs ln(x) (requires x>0, y>0)
Metrics include , RMSE, MAE, and optional MAPE. AIC/BIC are reported to compare models with different parameter counts.

How to Use This Calculator

  1. Paste your data as one point per line: x, y.
  2. If you have measurement confidence, enable weights and add w.
  3. Select a model. Use polynomial degree 2–6 when appropriate.
  4. Optionally set an outlier z-threshold to reduce noisy points.
  5. Click Calculate to view the equation and metrics above.
  6. Use the chart to inspect trend fit and residual behavior.
  7. Download CSV or PDF to share your fitted results.

Choosing a Model That Matches Your Data

Linear fits suit steady-rate change across the full x range. Polynomial fits capture curvature, but higher degrees can overfit: degree 2–3 often works for smooth trends, while degree 5–6 should be reserved for dense, low-noise samples. Exponential and power fits are common for growth and scaling laws, and logarithmic fits often model diminishing returns.

Minimum Points and Domain Rules

Model feasibility depends on data volume and sign constraints. Polynomial degree n needs at least n+1 points. Exponential fitting requires y>0 because it uses ln(y). Logarithmic fitting requires x>0 because it uses ln(x). Power fitting requires x>0 and y>0 because it uses ln(x) and ln(y). When constraints fail, the calculator automatically excludes invalid points and reports warnings.

Interpreting Accuracy Metrics

R² measures explained variance and ranges from 0 to 1 when a mean-based baseline is meaningful. RMSE and MAE are in the same units as y, making them practical for tolerances. MAPE is reported only where y ≠ 0, helping compare relative error across datasets. AIC and BIC penalize extra parameters, so they are useful when comparing models with different complexity.

The standard error uses sqrt(SS_res/df), where df = n − p and p is parameter count. Lower values indicate tighter residual spread. When R² is undefined (flat y), rely on RMSE/MAE and visual residual symmetry instead for decisions.

Weights and Outlier Control

Weights let reliable measurements influence the fit more strongly. For example, use w=4 for a sensor with half the standard deviation of another (variance scales inversely with weight). Outlier filtering uses a residual z-threshold: points with |residual| greater than z·σ are removed, and the fit can be repeated for up to five passes. This approach reduces the impact of spikes without hiding systematic bias.

Reporting, Prediction, and Exports

After calculation, the fitted equation, curve chart, and residual table help validate shape and error patterns. Use the prediction input to estimate ŷ at a specific x within the observed range; extrapolation beyond the range should be treated cautiously. The CSV export captures x, y, ŷ, and residuals for audits, while the PDF export packages the summary and table for sharing in reports.

FAQs

What model should I start with if I’m unsure?

Start with linear, then polynomial degree 2. Compare RMSE and MAE with the residual plot. If errors scale with y, try exponential or power. Choose the simplest model showing pattern-free residuals.

Why are some points removed for certain models?

Exponential needs y>0, logarithmic needs x>0, and power needs both x>0 and y>0 because they use logarithms. Points violating these rules are excluded and a warning is shown.

How do weights change the fit?

Weights multiply each squared residual in the objective Σ w·(y−ŷ)². Larger weights pull the curve toward those points, which is useful when some measurements are more reliable than others.

What does the outlier z-threshold do?

It computes residuals, estimates σ from SS_res/df, and removes points with |residual| > z·σ. Multiple passes can refine the fit, but aggressive thresholds may remove valid structure.

Can I trust predictions outside my data range?

Extrapolation can be risky because curves may behave unrealistically beyond observed x. Prefer predicting within the min–max x range, and validate with domain knowledge or additional points.

How do I export results for reporting?

Use CSV to capture x, y, ŷ, and residuals for spreadsheets or audits. Use PDF to share the equation, metrics, and the full results table in a single document.

Related Calculators

Linear Regression CalculatorMultiple Regression CalculatorLogistic Regression CalculatorSimple Regression CalculatorPower Regression CalculatorLogarithmic Regression CalculatorR Squared CalculatorAdjusted R SquaredSlope Intercept CalculatorCorrelation Coefficient Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.