Statistics Utilities

Calculate Correlation

Computes the Pearson correlation coefficient between two datasets, measuring linear relationship strength from -1 to 1. Access via MCP in Cursor or Windsurf for data analysis workflows, or call GET /v1/stats/correlation with your arrays. Returns precise correlation values plus significance testing — essential for validating feature relationships in ML pipelines.

API Endpoint

GET /v1/stats/correlation

Code Examples

curl "https://tinyfn.io/v1/stats/correlation" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/stats/correlation', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/stats/correlation',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's statistics tools:

{
  "mcpServers": {
    "tinyfn-stats": {
      "url": "https://tinyfn.io/mcp/stats",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate correlation between two datasets using MCP?

Pass two arrays of equal length to the correlation tool. It returns the Pearson coefficient (-1 to 1), p-value, and sample size for statistical significance testing.

What does a correlation coefficient of -0.8 mean?

Strong negative linear relationship — as one variable increases, the other decreases predictably. Values closer to ±1 indicate stronger relationships, 0 means no linear correlation.

Can I calculate correlation with missing data points?

The tool requires complete data pairs. Remove or interpolate missing values before calling the correlation function to avoid calculation errors.

What's the difference between Pearson and Spearman correlation?

This tool calculates Pearson correlation for linear relationships. Pearson assumes normal distribution and measures linear correlation, while Spearman handles non-linear monotonic relationships.

How can AI agents use correlation in data analysis workflows?

Agents can validate feature relationships, identify redundant variables for dimensionality reduction, or assess model assumptions by correlating predictions with actual values in real-time.

Try Calculate Correlation Now

Get your free API key and start using Calculate Correlation in seconds.

Get Free API Key