Statistics Utilities

Geometric Mean

Calculates the geometric mean of positive numbers — useful for averaging rates, ratios, and percentages. Access via MCP in Cursor or Windsurf for reliable statistical calculations, or call GET /v1/stats/geometric-mean directly. For dataset [2, 8, 32], returns 8.0. Unlike arithmetic mean, geometric mean prevents outliers from skewing growth rate calculations.

API Endpoint

GET /v1/stats/geometric-mean

Code Examples

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

What is geometric mean and when should I use it?

Geometric mean multiplies all values and takes the nth root, ideal for averaging growth rates, financial returns, or any multiplicative data. Use it when values represent ratios or when you need the central tendency of exponential growth.

How do I calculate geometric mean with MCP in my AI coding assistant?

Pass your array of positive numbers to the geometric-mean tool. The MCP integration handles the calculation deterministically, preventing AI hallucination of statistical formulas.

What happens if I include zero or negative numbers?

Geometric mean is undefined for zero or negative values since it involves nth roots of products. The tool will return an error — filter your data to positive numbers first.

How does geometric mean differ from arithmetic mean?

Arithmetic mean adds values and divides by count; geometric mean multiplies values and takes the nth root. Geometric mean is always ≤ arithmetic mean and better represents central tendency for multiplicative processes.

Can I use this for calculating average percentage growth rates?

Yes, geometric mean is perfect for growth rates. Convert percentages to multipliers (110% = 1.1), calculate geometric mean, then subtract 1 to get the average growth rate.

Try Geometric Mean Now

Get your free API key and start using Geometric Mean in seconds.

Get Free API Key