Computes the median value from a dataset with mathematical precision. Use via MCP in Cursor or Claude Code, or call GET /v1/stats/median directly. Pass an array like [1,3,5,2,4] and get back 3. Handles both odd and even-length datasets correctly, returning the middle value or average of two middle values.
curl "https://tinyfn.io/v1/stats/median" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/stats/median', {
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/median',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
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"
}
}
}
}
For odd-length arrays, returns the middle value after sorting. For even-length arrays, returns the average of the two middle values.
Accepts numeric arrays in JSON format. Empty arrays or non-numeric values will return an error.
Yes, it's available as an MCP tool in Cursor, Claude Code, GitHub Copilot, Windsurf, Cline, and other MCP-compatible editors for reliable statistical calculations.
Median is less affected by outliers than mean. For dataset [1,2,3,100], median is 2.5 while mean is 26.5.
Yes, it processes floating-point numbers with full precision and returns exact median values, not approximations.
Get your free API key and start using Calculate Median in seconds.
Get Free API Key