Statistics Utilities

Calculate Variance

Computes variance from a dataset using GET /v1/stats/variance, measuring how spread out values are from the mean. Pass an array of numbers and get back the variance value — essential for statistical analysis in data science workflows. Works seamlessly with MCP in Cursor and other AI coding assistants for instant statistical calculations.

API Endpoint

GET /v1/stats/variance

Code Examples

curl "https://tinyfn.io/v1/stats/variance" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/stats/variance', {
  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/variance',
    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 variance using the MCP tool?

Send a dataset array to the variance tool through MCP. Your AI assistant will call the endpoint and return the variance value immediately.

What's the difference between population and sample variance?

Population variance divides by N (total count), sample variance divides by N-1. Check the tool's documentation for which method it implements.

Can I calculate variance for empty or single-value datasets?

Empty datasets typically return undefined/null. Single values return 0 since there's no variation from the mean.

What input format does the variance endpoint expect?

Send a JSON array of numeric values via GET request. The endpoint processes the numbers and returns the calculated variance.

How does variance help in data analysis compared to standard deviation?

Variance shows raw spread in squared units, while standard deviation (square root of variance) matches original data units for easier interpretation.

Try Calculate Variance Now

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

Get Free API Key