Statistics Utilities

Calculate Range

Calculates the statistical range (maximum minus minimum value) from a dataset. Use via MCP in Cursor or Windsurf, or call GET /v1/stats/range directly. Pass an array of numbers like [1, 5, 3, 9, 2] and get back 8 (9-1). Returns precise numerical results without AI hallucination.

API Endpoint

GET /v1/stats/range

Code Examples

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

Pass your dataset as an array parameter to the calculate_range MCP function. It returns the difference between max and min values as a number.

What happens if I pass duplicate values when calculating range?

Duplicates don't affect the range calculation. [1, 3, 3, 7] still returns 6 (7-1) since range only considers the extreme values.

Can TinyFn calculate range for empty arrays or single values?

Single-element arrays return 0 range. Empty arrays typically return an error since range is undefined without data points.

What's the difference between range and standard deviation?

Range shows the spread between extremes (max-min), while standard deviation measures how values cluster around the mean. Range is simpler but less robust against outliers.

Does the range calculation work with negative numbers?

Yes, it handles negative numbers correctly. For [-5, -1, 3], the range is 8 (3 - (-5)).

Try Calculate Range Now

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

Get Free API Key