Harmonic mean calculator
Average rates the right way: the harmonic mean of 1, 2 and 4 is 12/7, below their ordinary average, because it averages the reciprocals and then turns the result back over. Made for speeds over equal distances. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Numbers
- 1, 2, 4
- Quantity
- 3
- Harmonic mean
- 1.7142857143
- Arithmetic mean
- 2.3333333333
- Reciprocal sum
- 1.75
The harmonic mean is the reciprocal of the arithmetic average of the reciprocals. For a list of strictly positive numbers it is n divided by the sum of one over each value. It is the right average when you combine rates, speeds, or other quantities defined per unit of the same total: two legs of a trip at different speeds, parallel resistors in ohms, or price-to-earnings style ratios where the same denominator matters more than a simple sum. Unlike the arithmetic mean, a value near zero pulls the harmonic mean sharply downward, which is why zeros and negatives are rejected rather than silently inventing a nonsense result. This capability takes a non-empty list of positive finite numbers and returns the harmonic mean together with count, the arithmetic mean for comparison, the reciprocal sum, and min and max, in one deterministic pure-parse call with no sampling, no randomness and no network side effects.
What the harmonic mean is and when to use it
Write H equals n over the sum of the reciprocals of every observation. That is exactly the same as taking the arithmetic mean of the reciprocals and then taking the reciprocal of that average. For positive numbers the harmonic mean is always less than or equal to the geometric mean, which is less than or equal to the arithmetic mean, with equality only when every value is identical.
Classic classroom case: the list one, two, four has reciprocal sum one plus one half plus one fourth equals one point seven five, so H equals three divided by one point seven five equals twelve sevenths, about one point seven one four. Another clean case is two, three, six: reciprocals one half, one third and one sixth sum to one, so H equals three.
Use the harmonic mean when averaging rates that share a common total—miles per hour over equal distances, parallel circuit resistances, or batch throughput over the same work units. Prefer the arithmetic mean when totals of the raw values matter more than rates. Prefer the geometric mean for multiplicative growth.
Never feed zeros or negatives into a real-valued harmonic mean calculator: one over zero is undefined, and negatives break the usual ordering properties people rely on. Empty lists are also rejected; there is no harmonic mean of nothing.
What you can do with it
Average speed over equal distances
Two legs of a trip at different speeds over the same distance: the overall average speed is the harmonic mean, not the arithmetic mean.
Rate and ratio pipelines
Summarize positive rates, parallel resistances, or inverse-style metrics in services without shipping a full stats library everywhere.
FAQ
Why are zero and negative values rejected?
The real-valued harmonic mean is undefined at zero (division by zero in a reciprocal) and is not defined for negatives in the standard positive-rate use.
How is the harmonic mean computed?
H = n / sum(1/xi): the reciprocal of the arithmetic mean of the reciprocals.
How does it differ from the arithmetic mean?
The arithmetic mean is sum/n and treats every value equally in the original scale. The harmonic mean weights smaller positives more heavily and is the correct average for many rates over a shared total. For positives, H ≤ arithmetic mean.
Is the harmonic mean calculator free?
The browser tool is free and runs locally.
When should I use the harmonic mean instead of the ordinary average?
Use it when you average rates that share a common total: speeds over equal distances, resistances in parallel, or throughput over the same units of work. When the totals of the raw values matter more than rates, the ordinary average is the better choice.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/harmonic-mean \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"numbers":[1,2,4]}'const res = await fetch("https://api.kit.forhosting.com/stat/harmonic-mean", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"numbers": [
1,
2,
4
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/harmonic-mean",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"numbers": [
1,
2,
4
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/harmonic-mean", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"numbers":[1,2,4]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"numbers":[1,2,4]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/harmonic-mean", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"numbers": [
1,
2,
4
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.harmonic_mean",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How to call the API and what comes back
Numeric strings inside the array are coerced; a comma or whitespace separated string is also accepted for simple text forms. Use it from homework checkers, finance or ops rate dashboards, sensor pipelines that average inverse quantities, or any workflow that needs a harmonic mean without installing a statistics package on every machine. Send a JSON body with one required field named numbers: a non-empty array of strictly positive finite numbers. Aliases values, data and list are accepted and behave the same. On success the response includes count as n, numbers as the input values in the order they were parsed, harmonic_mean equal to n over the sum of reciprocals, arithmetic_mean equal to the ordinary average for side-by-side comparison, reciprocal_sum as the intermediate sum of one over each xi, plus min and max of the sample. Failed validation—missing numbers, an empty list, non-finite entries, zero or negative values, or a list longer than one hundred thousand values—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, limits, and related searches
When teaching, pair one two four with two three six so students see both a fractional and an integer harmonic mean, then show that inserting a near-zero positive value collapses H toward zero. If you only need arithmetic mean, median and mode, use the sibling mean median mode calculator; this page is specifically for people searching for a harmonic mean calculator on positive rates and related quantities. Keep lists within the published size cap so interactive Worker and browser paths stay fast; one hundred thousand positive numbers is ample for classroom sets and most operational samples. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap while students type zeros by mistake. Prefer sending the raw positive list once and reading harmonic_mean from one response instead of hand-rolling reciprocal loops in every client: one contract, one charge unit, identical results in browser and API.
Integration use cases
Homework and exam answer keys
Check student work on harmonic mean problems with a deterministic browser or API result that rejects zeros and negatives cleanly.
Technical questions
What does this harmonic mean calculator return?
For a non-empty list of positive numbers it returns count, numbers, harmonic_mean, arithmetic_mean, reciprocal_sum, min and max.