Calculator
Example Data Table
Use this as a quick template. Add a third column for weights if needed.
| Point | x | y | w (optional) |
|---|---|---|---|
| 1 | 0 | 1.0 | 1 |
| 2 | 1 | 2.1 | 1 |
| 3 | 2 | 3.9 | 1 |
| 4 | 3 | 6.2 | 1 |
| 5 | 4 | 7.8 | 1 |
| 6 | 5 | 10.1 | 1 |
Formula Used
Least Squares (core idea)
The calculator finds parameters that minimize the weighted sum of squared residuals:
Weights are optional. If omitted, wᵢ = 1 for all points.
Linear Model
For y = a + b·x, the slope uses weighted covariance/variance:
Then a = ȳw − b·x̄w.
Polynomial Model
For y = c₀ + c₁x + ... + cₙxⁿ, coefficients come from normal equations:
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)
How to Use This Calculator
- Paste your data as one point per line: x, y.
- If you have measurement confidence, enable weights and add w.
- Select a model. Use polynomial degree 2–6 when appropriate.
- Optionally set an outlier z-threshold to reduce noisy points.
- Click Calculate to view the equation and metrics above.
- Use the chart to inspect trend fit and residual behavior.
- 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.