Linear Regression & Correlation (r, r²)

Linear Regression & Correlation (r, r²): Calculates slope m = (N*Σxy - ΣxΣy) / (N*Σx^2 - (Σx)^2) and y-intercept b = (Σy - mΣx) / N.

Loading tool module...

About this linear regression & correlation (r, r²)

Linear Regression & Correlation (r, r²) — browser-based utility.

How this tool works

Calculation and parameter relationship: slope=Σ((x−x̄)(y−ȳ))/Σ(x−x̄)²; intercept=ȳ−slope×x̄; rSquared=correlation²

  1. Paste the sample input into “Input”.
  2. Click “Run locally”.
  3. Compare “Raw Output Data” with the example; revise inputs when an error is shown.

Worked example

Scenario: Fit a least-squares line to three supplied x,y pairs and inspect correlation.

Sample input:

1,2 2,4 3,5

Processing: Parse finite x,y rows; calculate means, covariance, sums of squares, slope, intercept, Pearson correlation and its square.

Illustrative output:

{ "points": 3, "slope": 1.5, "intercept": 0.6666666666666665, "correlation": 0.9819805060619659, "rSquared": 0.9642857142857145, "equation": "y = 1.5x + 0.6666666666666665" }

Limits and verification

Parameter domains and units: n ≥ 2; (x,y) ∈ ℝ²; Σ(x−x̄)² > 0; Σ(y−ȳ)² = 0 ⇒ correlation = rSquared = null. Results use binary64 floating-point numbers unless BigInt is stated. Result cards show up to 10 significant digits; raw output retains the serialized value. A null ratio means the model has no meaningful finite value for that ratio; it is not zero.

Examples demonstrate an expected workflow; they do not prove every input or every branch of an external specification. Check important results with an independent source before using them for money, security, compliance, safety, or irreversible file changes.

Browser processing boundary

Tool input is processed by code running in the browser and is not intentionally sent to a CZOA processing API. The page can still request ordinary site assets, analytics, or advertising when those services are enabled. Browser extensions and managed-device software remain outside this tool's control.

Relevant references

These references govern or help explain the format, protocol, or calculation used here. Listing a reference does not claim certification or complete implementation of every optional feature.

Content owner: CZOA Tools · Last reviewed: 2026-09-15 · Review methodology

How to use it

  1. Paste the sample input into “Input”.
  2. Click “Run locally”.
  3. Compare “Raw Output Data” with the example; revise inputs when an error is shown.

Frequently asked questions

How does this linear-regression calculator work?+

It reads two finite numbers per nonempty line as x,y pairs, needs at least two points and non-identical x values, then computes least-squares slope, intercept, Pearson correlation, rSquared, and a displayed equation.

What input format does the page accept?+

Use one x,y pair on each line, separated by a comma or whitespace. For example, 1,2 2,4 3,5. The workspace runs this text locally.

What do the results and precision limits mean?+

All arithmetic uses JavaScript binary64. rSquared is the square of the returned correlation; it is not evidence of causation or a forecast. A zero y spread returns correlation and rSquared as null.

What result does the worked example produce?+

For 1,2 2,4 3,5, The tool returned slope 1.5, intercept 0.6666666666666665, correlation 0.9819805060619659 and rSquared 0.9642857142857145. This covers that local input vector only.