Scott's rule bin width calculator
For the eight values 2, 4, 4, 4, 5, 5, 7, 9, Scott's rule gives a bin width that covers their range of 7 in 2 bins. Paste a list of numbers and get a reproducible width instead of whatever your chart software picks. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Scott's rule is the classic normal-reference formula for choosing histogram bin width from a sample: multiply a constant near three point four nine by the sample standard deviation and by the cube root of one over the sample size. Analysts, students, and dashboard builders need a deterministic answer that does not depend on chart software defaults or on hand-waving Sturges counts. This Scott rule bin width calculator accepts an array of finite numbers, estimates the sample mean and Bessel-corrected standard deviation in two passes, then returns the optimal bin width h together with n, min, max, range, and a suggested bin count when the range is positive. Use it whenever you need a reproducible histogram bin width before plotting, before binning features for models, or before teaching how density estimation depends on sample size.
Where Scott bin width fits in study, science, and product work
Students meet Scott's rule when a textbook contrasts bin-selection heuristics, when a lab report asks for a justified histogram of repeated measurements, or when they need a clean check against software that only exposes Sturges or a fixed bin count. Teachers can pre-generate answer keys for modest series without trusting opaque chart libraries that round intermediate squares differently or hide which standard deviation they used.
Developers call the same contract from scripts to seed deterministic plot tests, to choose feature bins before encoding continuous covariates, or to satisfy data-quality gates that flag collapsed spreads. Analysts use Scott width when the sample is large enough for asymptotic arguments and roughly unimodal, and they fall back to other rules when heavy tails or multimodality dominate. Product and operations teams bin latency, basket size, or error counts with a width that shrinks as traffic grows rather than a static bucket grid that hides new modes.
Pair it with standard-deviation and five-number-summary tools when you need full descriptive context, and with quartile or percentile calculators when you need robust scale measures rather than a Gaussian-oriented bin width.
What you can do with it
Homework and lab histograms
Compute Scott's optimal bin width for textbook series and repeated measurement labs before drawing equal-width histograms by hand or in a notebook.
Feature binning and dashboards
Choose a data-driven histogram width for latency, revenue, or sensor columns that scales with sample size and sample standard deviation.
FAQ
Why does the tool require at least two values?
Sample standard deviation uses the n − 1 denominator and is undefined for a single observation.
Which standard deviation does Scott's rule use?
This implementation uses the sample standard deviation s with Bessel's correction (divide sum of squared deviations by n − 1), which is the usual choice for Scott's formula on finite samples.
What is Scott's rule for histogram bin width?
It multiplies 3.49 by the sample standard deviation and by the cube root of one over the number of values. More spread means wider bins, while a larger sample allows narrower bins that still keep the noise under control.
How is the suggested number of bins worked out?
The range of your data, from the smallest to the largest value, is divided by the bin width and rounded up, with at least one bin. For 2, 4, 4, 4, 5, 5, 7, 9 the range is 7, which fits in 2 bins.
When is Scott's rule a poor choice?
It assumes data that are roughly bell-shaped with a single peak and a reasonably large sample. When heavy tails or several peaks dominate, analysts usually switch to another bin-width rule.
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/scott-rule \
-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/scott-rule", {
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/scott-rule",
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/scott-rule", 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/scott-rule", 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.scott_rule",
"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_n | 10000 |
max_abs | 1000000000000000 |
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
When the list has fewer than two values the task fails with invalid_input, because sample standard deviation is undefined for a single observation.
What Scott's rule computes and what the response contains
David Scott's normal reference rule chooses a histogram bin width that minimizes an asymptotic mean integrated squared error criterion when the underlying density is roughly Gaussian. The closed form is h equals three point four nine times the sample standard deviation times n to the power of negative one third. Intuitively, wider spread needs wider bins, and larger samples can afford narrower bins that still keep noise under control. This calculator always returns the building blocks beside the final width: sample size n, arithmetic mean, sample variance and sample standard deviation with Bessel's correction, observed minimum and maximum, range, the Scott constant three point four nine, the formula string, and bin_width itself. When bin_width is strictly positive it also includes bins_estimate as the ceiling of range divided by bin_width, clamped to at least one, so you can sketch how many equal-width bins would cover the observed support. When every observation is identical the standard deviation is zero, bin_width is zero, and bins_estimate is omitted rather than fabricated as null. There is no Monte Carlo path, no random jitter, and no date-dependent shortcut: the engine either finishes the two-pass arithmetic inside the supported length and magnitude limits or rejects the input with invalid_input. Rejected cases include a missing values field, an empty list, a single observation, non-finite entries such as Infinity or NaN, non-numeric tokens, and arrays longer than the published maximum.
Input contract, parsing rules, and how the algorithm stays stable
Each element is parsed as a finite decimal; optional leading signs and scientific notation are allowed, while empty tokens, bare letters, and non-numeric objects fail with a field index in the message so a bad cell does not become a silent zero. Returning the intermediate statistics next to h avoids the common mistake of mixing population and sample denominators or of applying Scott's formula to n equals one. The preferred field is values, an array of finite numbers with at least two entries, but aliases data, numbers, x, and series are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. A single comma-separated or whitespace-separated string of numbers is also accepted when a form posts plain text instead of JSON arrays. The engine enforces a hard maximum of ten thousand points and a per-value magnitude ceiling so memory and latency stay inside a predictable budget on the free browser path and on the edge Worker. Computation is the classic two-pass method: first sum and mean, then sum of squared deviations from that mean, then sample variance as SSD over n minus one, sample standard deviation as the positive square root, and finally bin_width as three point four nine times s times n to the power of negative one third. Pair the free browser run on this page with the priced API when you need the identical Scott width inside an automated pipeline without re-implementing cube-root scaling yourself.
Where Scott bin width fits in study, science, and product work
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic plot and CI fixtures
Generate reproducible bin_width and bins_estimate values for unit tests and chart snapshots without hand-maintaining tables.
Technical questions
What is Scott's rule for histogram bin width?
Scott's normal reference rule sets h = 3.49 · s · n^(-1/3), where s is the sample standard deviation and n is the sample size. This calculator returns that h plus supporting statistics from your numeric array.
What is bins_estimate?
When bin_width is positive, bins_estimate is ceil((max − min) / bin_width), at least one. It is a convenient equal-width bin count over the observed range; it is omitted when all values are identical (h = 0).
What does the Scott rule bin width calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.