Correlação Linear (Pearson r)
Calcula r de Pearson entre dois conjuntos de mesmo tamanho.
r
—
Pearson correlation coefficient (r)
Pearson's r tells you how strong a linear relationship between two variables is, and which way it leans: r = Σ((xᵢ−x̄)(yᵢ−ȳ)) / √(Σ(xᵢ−x̄)²·Σ(yᵢ−ȳ)²). The value always sits in [−1, 1], and its square r² tells you what fraction of the variance in Y the X variable accounts for. Take X=[1,2,3,4,5] and Y=[2,4,5,4,6]: you get r ≈ 0.83, meaning roughly 69% of Y's variance is explained linearly by X. Watch out for outliers, though. One extreme point is enough to flip the sign, as Anscombe's quartet (1973) famously demonstrated. When the data is monotonic but not linear, or sits on an ordinal scale, reach for Spearman's ρ instead.
Applications
It shows up in linear regression diagnostics, in finance (the Sharpe ratio, Markowitz portfolio diversification built on asset correlation matrices), in epidemiology for dose-response studies, in social science work on test-retest reliability, in machine learning feature selection, and on the factory floor for quality control.
FAQ
Does r = 0 mean independence? Not at all. It only rules out a linear link. Y = X² over a symmetric range gives r ≈ 0 even though the relationship is perfectly deterministic.
Minimum sample size? The math works from n ≥ 3, but you usually want n ≥ 30 before trusting any inference. Below that, r bounces around a lot.
Pearson or Spearman? Pearson expects linearity and roughly normal continuous data. Spearman makes no such assumptions, so it tends to win out when you have outliers, ranked data, or monotonic patterns that aren't straight lines.
Related Tools
Rent Adjustment Calculator
Compute annual rent adjustment by IGP-M or IPCA accumulated in the last 12 months (manually configurable).
Pregnancy Calculator
Compute estimated due date (EDD), gestational age and trimester from the last menstrual period (LMP).
Fertile Period Calculator
Compute fertile window and ovulation day from the first day of the last cycle and the average cycle length.