Correlation calculator

Spearman's rank correlation calculator

Calculate Spearman's rank correlation coefficient ρ (rho), t-statistic, and p-value for monotonic relationships between continuous or ordinal variables.

Run this test live in StatLab npm i @statlab/core

When to use it

Use when variables have monotonic relationships or non-normal ordinal distributions.

Required Inputs

  • X numeric/ordinal array
  • Y numeric/ordinal array

Mathematical Formula

ρ = 1 - [ 6 Σ d_i² / (n(n² - 1)) ]

Reporting Cautions

  • Measures monotonic trends, not strictly linear relationships.
  • Tied ranks require tie-corrected correlation formula.

Code Snippets (Python, R, TypeScript)

Python (SciPy / Statsmodels)
from scipy import stats
rho, p = stats.spearmanr(x_vals, y_vals)
print(f"rho={rho:.4f}, p={p:.4f}")
R Language
cor.test(x_vals, y_vals, method = "spearman")
TypeScript (@statlab/core)
import { spearmanRho } from '@statlab/core';
const res = spearmanRho(xVals, yVals);

Developer Use Cases & Production Integrations

  • Measuring monotonic correlation between system queue depth and p99 latency.
  • Evaluating monotonic alignment between model size and eval benchmarks.

VoxelPulse Telemetry Control Plane

Continuous A/B testing, statistical telemetry analysis, and automated feedback loops for live backend services.

Explore VoxelPulse →

VoxelAssurance Release Readiness

Fixed-price AI release-readiness sprints, automated regression testing, and reliability statistical benchmarks.

Explore VoxelAssurance →

Related Statistical Test Calculators

Explore static calculators across the StatLab inference engine suite.