Upper and lower fence calculator
Find the cut-offs that flag outliers in a box plot: for the numbers 1 to 9, Q1 is 2.5, Q3 is 7.5 and the fences fall at −5 and 15, so any value outside them stands out. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
The upper and lower outlier fences of a numeric sample are the two cut-points that a Tukey box plot uses to flag mild outliers. After the first quartile Q1 and the third quartile Q3 are taken from the ordered list, the interquartile range is Q3 minus Q1. The lower fence is Q1 minus one and a half times that range, and the upper fence is Q3 plus one and a half times that range. Any observation that sits strictly below the lower fence or strictly above the upper fence is a candidate outlier on the conventional 1.5-IQR rule. This calculator accepts at least four finite numbers, computes those two fences from Tukey exclusive hinges, and returns both fence values together with the quartiles and the interquartile range that produced them.
What the upper and lower fences mean and how they are computed
The upper fence and the lower fence are the two numerical boundaries that John Tukey attached to a box-and-whisker plot so that unusually far observations would stand out without forcing every tail value to be treated as an error. They are not the whiskers themselves: the whiskers stop at the most extreme inliers, while the fences are the algebraic limits that decide which points still count as inliers. Given an ordered sample of at least four finite numbers, this calculator first builds Tukey exclusive hinges.
The median of the whole list is the second quartile, but the fences only need the first and third quartiles. When the count is even, the lower half is the first n over two values and the upper half is the last n over two values. When the count is odd, the overall median is excluded from both halves so that Q1 and Q3 are not pulled toward the center twice.
Q1 is the median of the lower half, Q3 is the median of the upper half, and the interquartile range IQR is Q3 minus Q1. The lower fence is then Q1 minus 1.5 times IQR, and the upper fence is Q3 plus 1.5 times IQR. The multiplier 1.5 is the conventional Tukey constant for mild outliers; this landing does not switch to the inner 1.0 or outer 3.0 variants.
Ties, negatives, zeros, and mixed signs are first-class: only rank on the number line matters. The procedure is fully deterministic, so the same list always yields the same pair of fences, which makes the numbers safe to pin in homework keys, laboratory notebooks, and automated tests without Monte Carlo noise or hidden rounding choices.
Practical use, limits, pricing, and related tools
Use the browser tool when you want an immediate pair of outlier fences while checking a homework answer, drawing a box plot by hand, or explaining the 1.5-IQR rule before listing flagged points, without installing a statistics package. Accepted lists stay bounded: at least four values and at most one hundred thousand cover classroom tables, sensor batches, and typical analytics excerpts while still finishing quickly. Results are fully deterministic: the same values always yield the same n, quartiles, IQR, and both fence values.
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. Keep lists modest for everyday classroom and dashboard use; the hundred-thousand ceiling is a guardrail against accidental bulk dumps, not a target.
When you also need Q2, an explicit outlier list, or an arbitrary percentile in the same sitting, call the dedicated tools for those search intents; this landing stays focused on the upper fence and the lower fence so the page and the response contract stay honest about what they deliver.
What you can do with it
Homework and box-plot construction
Students and graders verify both Tukey fences for the same list, including the hard rule that a dataset with fewer than four values is invalid and cannot invent hinges.
Quality control screening
Engineers turn a finished batch of readings into stable upper and lower fences before flagging points that sit outside the 1.5-IQR band, without opening a spreadsheet.
FAQ
What happens if the dataset has fewer than four values?
At least four finite numbers are required so both hinge halves are non-empty. Validation failures are not charged.
What formulas define the lower fence and the upper fence?
After Q1 and Q3 are taken as Tukey exclusive hinges, IQR is Q3 minus Q1. The lower fence is Q1 minus 1.5 times IQR. The upper fence is Q3 plus 1.5 times IQR.
How is this different from a quartile-and-IQR calculator?
This tool returns the two Tukey fences (and the Q1, Q3, IQR that produced them). A quartile-and-IQR calculator is a broader five-number-style landing. Those are separate search intents.
Is the upper and lower fence calculator free?
The browser tool runs free on your device.
Are the fences the same as the whiskers of a box plot?
No. The whiskers stop at the most extreme values still inside the fences, while the fences are the limits that decide which points count as outliers. For the numbers 1 to 9 the fences are −5 and 15, well beyond the data.
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/upper-lower-fence \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[1,2,3,4,5,6,7,8,9]}'const res = await fetch("https://api.kit.forhosting.com/stat/upper-lower-fence", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
1,
2,
3,
4,
5,
6,
7,
8,
9
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/upper-lower-fence",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
1,
2,
3,
4,
5,
6,
7,
8,
9
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/upper-lower-fence", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[1,2,3,4,5,6,7,8,9]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[1,2,3,4,5,6,7,8,9]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/upper-lower-fence", 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": [
1,
2,
3,
4,
5,
6,
7,
8,
9
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.upper_lower_fence",
"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
Lists shorter than four values are rejected with invalid_input because a four-point sample is the smallest set that still yields two non-empty hinge halves.
Input contract, response shape, and validation rules
There is no requirement that numbers lie in a particular interval such as zero to one hundred: any finite magnitude within a published safe bound is accepted, so scores, prices, residuals, and signed sensor readings compute truthful fences without preprocessing. POST a JSON object with a required values field: an array of finite numbers with at least four entries and at most one hundred thousand. Aliases accepted for the same list include numbers, data, list, and x, so scripts that already speak in those terms do not need a rename step. Each element may be a JSON number or a numeric string; non-finite values, empty strings, booleans, and non-numeric tokens fail with invalid_input naming the bad index. You may also pass values as a single comma- or whitespace-separated string when a text form is more convenient than a JSON array. On success the body returns n, q1, q3, iqr, lower_fence, upper_fence, fence_k fixed at one point five, method set to tukey_exclusive, min, max, and a short formula string that restates the two fence identities. Missing values, an array shorter than four numbers, more than one hundred thousand entries, or a body that is not an object all raise invalid_input and are not billed. Pair this contract with a dedicated quartile-and-IQR or five-number-summary tool if you also need the median, the full hinge table, or an explicit outlier list in the same sitting; this endpoint reports the two Tukey fences and the quartiles that produced them.
Practical use, limits, pricing, and related tools
Each successful request is one billable item at $0.002; failed validation does not consume balance. Wire the endpoint into data-science tutorials, spreadsheet-migration tests, coding-interview sandboxes, or preprocessing steps where you already prefer a closed-form Tukey fence over opaque calculators that hide whether they used inclusive percentiles, exclusive hinges, or a different multiplier.
Integration use cases
Scripts and CI numeric fixtures
Pipelines and interview sandboxes call a deterministic fence contract instead of reimplementing Q1, Q3, and the 1.5-IQR rule in every language with different short-list rules.
Technical questions
How do I compute the upper and lower outlier fences of a dataset?
Send JSON with values (at least four finite numbers) to stat.upper_lower_fence. The response returns n, q1, q3, iqr, lower_fence, upper_fence, fence_k 1.5, method, min, max, and formula. Fences use Tukey exclusive hinges.