Variance calculator
Calculate both kinds of variance at once: for 2, 4, 4, 4, 5, 5, 7 and 9 the mean is 5, the population variance is 4 and the sample variance divides the same 32 by 7. No more guessing which divisor a formula uses. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Variance measures how far the numbers in a list sit from their arithmetic mean, and it is the first quantity most analysts reach for when a simple average is not enough. Population variance divides the sum of squared deviations by n and describes an entire finite set you already hold; sample variance divides by n minus one (Bessel's correction) when the list is a sample used to estimate the spread of a larger population.
Population variance versus sample variance, and why both appear together
Each point then contributes a squared distance from that mean; adding those squared distances gives the total sum of squared deviations. Population variance divides that total by n and treats the list as the complete set of interest — every exam score in a closed class, every reading on a finished batch, every pixel intensity in a fixed window. Sample variance divides the same total by n minus one so that, under standard sampling assumptions, the estimator of the unknown population spread is unbiased.
Textbooks and spreadsheet packages disagree about which divisor is the default, which is why tools that only print one number force you to reverse-engineer the formula from documentation. Returning mean, population variance, sample variance, and the shared numerator side by side removes that ambiguity: you can match a homework key that uses n, a lab protocol that uses n minus one, or a report that needs both for comparison.
When the list has only one value, population variance is zero and sample variance is undefined, so the sample field is returned as null rather than inventing a divisor of zero. Empty lists never produce a mean or a variance; they fail validation immediately.
Because every step is a finite sum of products of known numbers, the procedure is classical and fully deterministic: the same list always yields the same mean and the same pair of variances, which makes the numbers safe to pin in automated tests, lesson answer keys, and reproducible notebooks without Monte Carlo noise.
What you can do with it
Homework and introductory statistics labs
Students and graders verify mean, population variance, and sample variance for the same list, including the hard rule that an empty list is invalid.
Quality control and sensor batches
Engineers turn a finished batch of readings into a stable mean and both variance formulas for reports and automated oracles without choosing a divisor by hand.
FAQ
What is the difference between population and sample variance?
Population variance divides the sum of squared deviations by n. Sample variance divides by n minus one (Bessel's correction) when the list estimates a larger population. Both use the same mean.
What happens if the list is empty?
At least one finite number is required. Validation failures are not charged.
Is the variance calculator free?
The browser tool runs free on your device.
How do I work out the variance of 2, 4, 4, 4, 5, 5, 7 and 9?
The mean is 5 and the squared distances from it add up to 32. Dividing by the 8 values gives a population variance of 4; dividing by 7 gives the sample variance, which is slightly larger.
Why is there no sample variance for a single number?
Because the sample formula divides by n minus one, which is zero for one value. The population variance is simply 0, while the sample variance is left undefined instead of inventing a result.
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/variance \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[2,4,4,4,5,5,7,9]}'const res = await fetch("https://api.kit.forhosting.com/stat/variance", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
2,
4,
4,
4,
5,
5,
7,
9
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/variance",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
2,
4,
4,
4,
5,
5,
7,
9
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/variance", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[2,4,4,4,5,5,7,9]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[2,4,4,4,5,5,7,9]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/variance", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"values": [
2,
4,
4,
4,
5,
5,
7,
9
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.variance",
"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.
Limits
max_values | 100000 |
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
This calculator takes a non-empty array of finite numbers, returns the mean, both variance formulas, the count, and the shared sum of squared deviations, and rejects empty lists with a clear invalid_input error so broken pipelines never invent a silent zero. The arithmetic is fully deterministic, runs free in your browser, and is available over the API at $0.002 per successful request with no language model and no external statistics service on the hot path.
Population variance versus sample variance, and why both appear together
Start with the arithmetic mean of the list: add every value and divide by how many values you have.
How this calculator validates the list and computes the moments
After validation the core walks the list once to accumulate the sum and form the mean, then walks again to accumulate the sum of squared deviations from that mean. Population variance is that sum divided by n; sample variance is the same sum divided by n minus one when n is at least two, and null when n equals one. A microscopic clamp prevents floating round-off on a zero-spread list from inventing a negative sum of squares. Call the capability with a required array field named values: a non-empty list of finite numbers. The engine also accepts the aliases numbers, data, list, and x, so scripts that already speak in those terms do not need a rename step. Validation rejects a missing field, a non-array, an empty array, lists longer than the published maximum, and any entry that is not a finite number, all with invalid_input and without charging balance.
Practical use, limits, pricing, and delivery
Use the browser tool when you want an immediate mean and both variances while checking a homework answer, profiling a small dataset, or explaining the n versus n-minus-one distinction without installing a statistics package. Results are fully deterministic: the same values always yield the same mean, population variance, sample variance, and sum of squared deviations. There is no language model, no external statistics service, and no randomness, so the capability is safe to pin in continuous-integration checks and reproducible lesson materials. Each successful request is one billable item at $0.002; failed validation does not consume balance. Accepted lists stay bounded for Worker isolates: up to one hundred thousand values cover classroom tables, sensor batches, and typical analytics excerpts while still finishing quickly. Wire the endpoint into data-science tutorials, spreadsheet-migration tests, coding-interview sandboxes, or preprocessing steps where you already prefer closed-form two-pass variance over approximate streaming sketches or opaque black-box calculators that hide whether they divide by n or by n minus one when they print a single variance field.
Integration use cases
Scripts and CI numeric fixtures
Pipelines and interview sandboxes call a deterministic variance contract instead of reimplementing Bessel versus population formulas in every language.
Technical questions
How do I compute variance with this calculator?
Send JSON with values (a non-empty array of numbers) to stat.variance. The response returns mean, population_variance, sample_variance, n, and sum_squared_deviations.
What is sample_variance when the list has only one number?
sample_variance is null because dividing by n minus one would be division by zero. population_variance is zero and mean equals that single value.