Every point is a sample (x, y) drawn from a noisy linear process: y = m·x + b + ε, where ε is random noise and a small fraction of points are deliberately corrupted into outliers. A least-squares fit recovers the best-guess line through the cloud, and the Pearson correlation coefficient r measures how tightly the points hug that line — close to ±1 means a strong, predictable trend; close to 0 means the two variables barely relate.
r = Σ(xᵢ−x̄)(yᵢ−ȳ) / √(Σ(xᵢ−x̄)² · Σ(yᵢ−ȳ)²)
m = r · (σy / σx), b = ȳ − m·x̄
zᵢ = (yᵢ − ŷᵢ) / σ_residual → |zᵢ| > 2 flagged as outlier
- Sample size — more points make the fitted line and r more stable and less sensitive to any single point.
- Noise (spread) — how far actual points scatter from the true underlying trend; higher noise weakens the correlation even when a real trend exists.
- True trend slope — the real relationship generating the data; the fitted slope should converge toward it as noise drops and sample size grows.
- Outlier rate — the share of points replaced with a random extreme value, showing how a few bad data points can drag a regression fit off course — exactly why outliers need investigation before being trusted or discarded.
Real-world relevance: this loop of fit → measure fit quality → flag anomalies is the core of exploratory data analysis — spotting trends, judging how much to trust a prediction, and deciding which data points deserve a second look before drawing conclusions. Remember: a strong correlation shows two variables move together, not that one causes the other.