Bartlett test calculator
Bartlett's test compares the variances of two or more independent groups and reports a chi-square test statistic with its p-value.
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
Enter each group as a separate numeric array, and the calculator returns group means, unbiased sample variances, the pooled variance, degrees of freedom, and the corrected Bartlett statistic. The method is designed for data that are reasonably consistent with normal distributions. It is especially useful before procedures whose interpretation depends on equal variances, while making the assumptions and intermediate quantities visible for review.
Prepare groups that represent independent samples
Create one group for every population, treatment, process, or condition whose variance you want to compare. Each group needs at least two finite numeric observations because a sample variance cannot be estimated from a single value. Labels are optional, but meaningful names make the returned summaries easier to audit. Do not combine repeated measurements from one subject as though they were independent observations, and do not split one sample merely to increase the number of groups. Bartlett's test addresses equality of population variances across independent groups. It does not test whether group means are equal. Before submitting data, check units and data collection rules: comparing measurements in centimeters with another group recorded in millimeters creates a variance difference that reflects scaling rather than the underlying process. The calculator uses every supplied observation, computes each arithmetic mean, and calculates each unbiased sample variance with a denominator of n minus one. Missing, textual, infinite, and nonnumeric values are rejected instead of silently removed, so the effective sample sizes always match the arrays you provided. A group in which every observation is identical is also rejected because its zero variance makes the logarithmic Bartlett formula undefined.
Understand the statistic and p-value
The calculation first pools the within-group sums of squares, weighting every sample variance by its degrees of freedom. It then compares the logarithm of that pooled variance with the weighted logarithms of the individual sample variances. A correction factor accounts for the number and sizes of the groups, producing Bartlett's statistic. Under the null hypothesis that all population variances are equal, and assuming normal observations, this statistic is approximately chi-square distributed with one fewer degree of freedom than the number of groups. The returned p-value is the upper-tail probability of obtaining a statistic at least this large under that null hypothesis. A small p-value is evidence against equal variances; it is not the probability that the null hypothesis is true, and it does not measure the practical importance of a difference. Choose a significance level before inspecting the result, commonly 0.05 when appropriate for the study, then compare the p-value with that threshold. Also examine the returned group variances and sample sizes. They explain which groups differ and help distinguish a meaningful variance contrast from a result driven by a large amount of data.
Respect normality and report the result clearly
Bartlett's test is powerful when observations within every group are normally distributed, but it is sensitive to skewness, heavy tails, and outliers. A significant result can therefore reflect nonnormal shape rather than a genuine difference in population variances. Review plots, subject-matter knowledge, and appropriate normality diagnostics before relying on the test. When normality is doubtful, consider a variance test designed to be more robust, such as Levene's test or the Brown–Forsythe variant. No automatic diagnostic can replace understanding how the sample was collected. In a report, state the number of groups, their sample sizes, Bartlett's statistic, degrees of freedom, p-value, chosen significance level, and the conclusion in context. Avoid writing that variances are proven equal when the result is not significant; the data may simply lack enough precision to detect a difference. Instead, say that the test did not find sufficient evidence of unequal variances. The API runs the same deterministic arithmetic for every request, without network access or randomness, and costs $0.002 per request. Preserve the original observations and analysis plan alongside the output so another analyst can reproduce both the calculation and the interpretation.
What you can do with it
Check an ANOVA assumption
Compare variation across treatment groups before interpreting a classical analysis of variance that assumes homogeneous variances.
Compare process consistency
Test whether measurements from several normally distributed production lines show evidence of different process variability.
Audit laboratory precision
Evaluate equality of variance across instruments, sites, or controlled conditions while retaining group-level summaries.
FAQ
What is the null hypothesis?
The null hypothesis is that every represented population has the same variance; the alternative is that at least one variance differs.
How many observations does each group need?
Every group needs at least two finite numeric observations. More observations generally provide a more reliable variance estimate.
Why are constant groups rejected?
A constant group has zero sample variance, and Bartlett's formula contains the logarithm of each variance, so the statistic is undefined.
Does a large p-value prove equal variances?
No. It means the test did not find sufficient evidence against equality at the chosen threshold; limited sample sizes may hide real differences.
When should I avoid Bartlett's test?
Use caution when groups are notably skewed, heavy-tailed, or affected by outliers. A robust test such as Levene's or Brown–Forsythe may be preferable.
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/bartlett-test \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"groups":[{"name":"Control","values":[10,12,9,11,13]},{"name":"Treatment A","values":[8,14,10,12,11]},{"name":"Treatment B","values":[9,15,7,13,10]}]}'const res = await fetch("https://api.kit.forhosting.com/stat/bartlett-test", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"groups": [
{
"name": "Control",
"values": [
10,
12,
9,
11,
13
]
},
{
"name": "Treatment A",
"values": [
8,
14,
10,
12,
11
]
},
{
"name": "Treatment B",
"values": [
9,
15,
7,
13,
10
]
}
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/bartlett-test",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"groups": [
{
"name": "Control",
"values": [
10,
12,
9,
11,
13
]
},
{
"name": "Treatment A",
"values": [
8,
14,
10,
12,
11
]
},
{
"name": "Treatment B",
"values": [
9,
15,
7,
13,
10
]
}
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/bartlett-test", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"groups":[{"name":"Control","values":[10,12,9,11,13]},{"name":"Treatment A","values":[8,14,10,12,11]},{"name":"Treatment B","values":[9,15,7,13,10]}]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"groups":[{"name":"Control","values":[10,12,9,11,13]},{"name":"Treatment A","values":[8,14,10,12,11]},{"name":"Treatment B","values":[9,15,7,13,10]}]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/bartlett-test", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"groups": [
{
"name": "Control",
"values": [
10,
12,
9,
11,
13
]
},
{
"name": "Treatment A",
"values": [
8,
14,
10,
12,
11
]
},
{
"name": "Treatment B",
"values": [
9,
15,
7,
13,
10
]
}
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.bartlett_test",
"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_groups | 100 |
max_values_per_group | 10000 |
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. |