Curve Regression & Estimation Calculator

Curve Regression & Estimation Calculator

Growing AI Skill PRO

Enter Calculation

Formula

y^=A+Bxwhere{B=n∑xy−∑x∑yn∑x2−(∑x)2A=∑y−B∑xn\begin{gathered} \hat{y} = A + B\,x \\[1.5em] \text{where}\quad \left\{ \begin{aligned} B &= \frac{n\sum xy - \sum x \sum y}{n\sum x^2 - \left(\sum x\right)^2} \\ A &= \frac{\sum y - B\sum x}{n} \end{aligned} \right. \end{gathered}
Usage stats

Advertisement

Results

Estimated value
122.285714
from the fitted curve
Coefficient A 1.1428571429
Coefficient B 1.8928571429
Correlation (r) 0.994527

Report an error on this page

What this calculator does

This tool fits a chosen curve-regression model to your table of paired observations (x, y) using the method of least squares. It reports the fitted coefficients (A, B, and C for quadratic), the correlation coefficient r that measures how well the model describes the data, and an estimated value computed directly from the fitted equation. It is a universal mathematics and statistics tool with no region-specific rules.

The seven models

You can choose Linear (\(y = A + B\cdot x\)), Logarithmic (\(y = A + B\cdot \ln x\)), e-Exponential (\(y = A\cdot e^{Bx}\)), ab-Exponential (\(y = A\cdot B^{x}\)), Power (\(y = A\cdot x^{B}\)), Inverse (\(y = A + B/x\)), or Quadratic (\(y = A + B\cdot x + C\cdot x^{2}\)). All except the quadratic are fitted by linearizing into the form \(Y = a + b\cdot X\) and applying ordinary least squares; the quadratic is solved from its \(3\times 3\) normal equations.

Seven small scatter plots each fitted with a different regression curve shape
The seven curve models compared: linear, logarithmic, exponential, power, inverse and quadratic fits.

How to use it

Enter your x values and y values as comma-separated lists of equal length, pick a regression type, choose whether you want to estimate y from x or x from y, and type the known input value. The calculator returns the coefficients, the correlation r, and the estimate.

The formula explained

For the linearized pairs (X, Y): \(b = S_{xy} / S_{xx}\) and \(a = \bar{Y} - b\cdot \bar{X}\), where \(S_{xx} = \sum X^2 - n\bar{X}^2\) and \(S_{xy} = \sum XY - n\bar{X}\bar{Y}\). The correlation is $$r = \frac{S_{xy}}{\sqrt{S_{xx}\cdot S_{yy}}}.$$ Coefficients are then back-substituted (for example \(A = e^a\) in exponential and power models).

Advertisement
Scatter of points with a best-fit line and vertical residual segments
Least squares fits the curve that minimizes the squared vertical distances (residuals) from the points.

Worked example

For x = [1,2,3,4,5,6,7] and y = [3,5,7,8,11,13,14] with a linear fit: \(S_{xx} = 28\), \(S_{xy} = 53\), so $$B = \frac{53}{28} = 1.892857$$ and $$A = 8.714286 - 1.892857\cdot 4 = 1.142857.$$ The correlation is $$r = \frac{53}{\sqrt{28\cdot 101.4286}} = 0.99453.$$ Estimating y at \(x = 64\) gives $$1.142857 + 1.892857\cdot 64 = 122.2857$$ (an extrapolation well beyond the data range).

Step-by-Step: Fitting a Curve by Hand

  1. Choose the model. Pick linear, logarithmic, exponential (e-form or ab-form), power, inverse or quadratic, based on the shape of a scatter plot and what you know about the process.
  2. Check domain restrictions. Logarithmic needs x > 0. Exponential needs y > 0. Power needs both x > 0 and y > 0. Inverse needs x ≠ 0. If any data point violates the rule, that model cannot be fitted to the data.
  3. Transform the data. Replace x and y with X and Y as the model requires: X = ln x, Y = ln y, or X = 1/x. Leave a variable unchanged if the model does not transform it.
  4. Compute the sums, means and sums of squares on the transformed data (n points):
    $$S_{xx}=\sum X^2-\frac{(\sum X)^2}{n},\quad S_{xy}=\sum XY-\frac{\sum X\,\sum Y}{n},\quad S_{yy}=\sum Y^2-\frac{(\sum Y)^2}{n}$$ and the means \(\bar X=\sum X/n\), \(\bar Y=\sum Y/n\).
  5. Get the slope and intercept of the straight line \(Y = a + bX\):
    $$b=\frac{S_{xy}}{S_{xx}},\qquad a=\bar Y-b\,\bar X$$
  6. Back-substitute to the original parameters. For the ab-exponential model, \(A=e^{a}\) and \(B=e^{b}\). For the e-exponential and power models, \(A=e^{a}\) and \(B=b\). For the logarithmic and inverse models, \(A=a\) and \(B=b\).
  7. Compute the correlation coefficient:
    $$r=\frac{S_{xy}}{\sqrt{S_{xx}\,S_{yy}}}$$ This is calculated on the transformed data.
  8. Estimate. Put your x into the fitted equation (for example \(\hat y = A\,x^{B}\) for a power fit). To estimate x from a given y, rearrange the equation, and check that the result lies in the model's domain.

Quadratic note. The quadratic \(\hat y = A + Bx + Cx^2\) is not linearized. Instead, solve the 3×3 normal equations:

$$\begin{aligned}\sum y &= nA + B\sum x + C\sum x^2\\ \sum xy &= A\sum x + B\sum x^2 + C\sum x^3\\ \sum x^2y &= A\sum x^2 + B\sum x^3 + C\sum x^4\end{aligned}$$

You need the sums Σx, Σx², Σx³, Σx⁴, Σy, Σxy and Σx²y. Solve the system by Cramer's rule or Gaussian elimination. At least three distinct x values are required.

Advertisement

Linearization Transforms by Model

Model Equation Transformed X Transformed Y Linear form Back-substitution (a, b from the line) Domain restriction
Linear \(y = A + Bx\) x y \(y = a + bx\) A = a, B = b None
Logarithmic \(y = A + B\ln x\) ln x y \(y = a + bX\) A = a, B = b x > 0
Exponential (e-form) \(y = A e^{Bx}\) x ln y \(\ln y = a + bx\) A = ea, B = b y > 0
Exponential (ab-form) \(y = A B^{x}\) x ln y \(\ln y = a + bx\) A = ea, B = eb y > 0
Power \(y = A x^{B}\) ln x ln y \(\ln y = a + bX\) A = ea, B = b x > 0 and y > 0
Inverse \(y = A + B/x\) 1/x y \(y = a + bX\) A = a, B = b x ≠ 0
Quadratic \(y = A + Bx + Cx^2\) No linearization Solve the 3×3 normal equations A, B, C come directly from the solution None (needs at least 3 distinct x values)

The e-form and ab-form exponentials describe the same curve family: \(B_{ab}=e^{B_{e}}\). They give the same fit and the same r.

Interpreting r and Choosing Between Models

  • Range and sign. r lies between −1 and 1. A positive r means Y tends to increase with X, and a negative r means it tends to decrease. |r| near 1 indicates a strong fit to the fitted form, and |r| near 0 indicates a weak fit.
  • Transformed models. For logarithmic, exponential, power and inverse fits, r is computed on the transformed data (for example ln y against ln x). It is therefore not directly comparable with the r of a linear fit on the original scale. Comparing models by r is only a rough guide.
  • r² (explained variance). r² is the proportion of variance in the (transformed) Y explained by the fitted line. For example, r = 0.90 gives r² = 0.81, so about 81% of the variance is explained.
  • Correlation is not causation. A high r does not show that one variable causes the other, nor that the chosen model is the true relationship. Different curves can fit the same data about equally well.
  • Check residuals. Plot the differences between observed and fitted values. They should scatter randomly around zero. A visible pattern, such as a curve or a funnel shape, means the model is poorly suited, even when r is high.
  • Extrapolation risk. Estimates inside the range of your x data (interpolation) are usually far more reliable than estimates outside it. Exponential, power and quadratic curves can diverge sharply beyond the data.
  • Quadratic versus linear. A quadratic always fits at least as well as a linear model on the same data, because it has more parameters and contains the linear model as a special case (C = 0). A better fit alone therefore does not justify the extra term. Prefer the simpler model unless the improvement is meaningful and the curvature makes sense for the process.
  • Sample size. With very few points, even a high r can arise by chance. Use as much data as is practical.

FAQ

How is r interpreted? Roughly: \(0.7 < |r| \le 1\) strong, \(0.4 < |r| < 0.7\) moderate, \(0.2 < |r| < 0.4\) weak, below \(0.2\) negligible.

Why are some models rejected? Logarithmic and power models require \(x > 0\), exponential and power models require \(y > 0\), and inverse requires \(x \ne 0\), because of the log or reciprocal transforms.

Can I extrapolate? Yes, but estimates outside the observed data range are extrapolations and should be treated with caution.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators