ForHosting KIT · Math

Histogram calculator

Get the frequency table behind a histogram: the values 1, 2, 2, 3, 5, 7, 8 and 9 split into four bins of width 2 give counts of 3, 1, 1 and 3. Choose a bin width or a number of bins. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Bin count
4
You get
N
8
Min
1
Max
9
Range
8

A histogram groups a numeric sample into contiguous bins and counts how many observations fall in each interval. This histogram calculator accepts a list of finite numbers together with either a positive bin width or a positive integer bin count, then returns every bin range, its raw count, and its relative frequency.

What a histogram table shows

A histogram splits a list of numbers into touching intervals of equal width, called bins, and counts how many values land in each one. Next to every count you also get the relative frequency, which is the count divided by the total number of values. You choose either the width of each bin or how many bins you want. Take the eight values 1, 2, 2, 3, 5, 7, 8 and 9 with four bins: the range from 1 to 9 is cut into steps of 2, the counts are 3, 1, 1 and 3, and so the outer bins each hold 0.375 of the data and the middle ones 0.125. The table is ready for drawing bars by hand, checking a chart or completing a frequency table for homework.

How the bins are built, and what trips people up

The first edge is always the smallest value in your list, and every following edge is one fixed width further on; nothing is shifted to a rounder starting point. Each bin includes its left edge but not its right edge, except the last one, which is closed on both sides so the largest value is never dropped. That last detail is exactly where some chart tools lose the maximum. If you give both a width and a number of bins, the width is used. Any entry that is not a number is rejected, so a stray label cannot quietly turn into a zero and distort the counts.

What the histogram returns and how equal-width bins are cut

A histogram is an equal-width partition of the observed numeric range together with the number of sample points that land in each interval. Each returned bin lists a one-based index, the left and right edges, a raw count, a relative frequency equal to count divided by n, and an interval string that uses a half-open bracket on interior bins and a closed bracket on the last bin. The response also echoes n, min, max, range, the width actually used, the bin count, and which method won.

If every observation is identical the range is zero, the engine collapses to a single bin at that value, and it does not invent empty neighboring classes. Optional fields are omitted rather than set to null.

Where a frequency table belongs in study, analysis, and product work

Students meet histograms when a lab asks for a frequency table of repeated measurements, when a textbook shows four equal classes over a small series, or when they need to check that a chart library did not drop the maximum because the last bin was left half-open. Teachers can generate answer keys that list every interval and count without trusting opaque plot defaults. Analysts bin response times, exam scores, basket sizes, or sensor readings to see shape, gaps, and outliers before they pick a model.

Product and operations teams turn the same table into a dashboard series that other services can cache because the output is deterministic for a given list and width. Pair it with a standard-deviation or five-number-summary calculator when you need spread, and with a dedicated bin-width rule when you still have to choose h. On this page the work runs entirely in your browser.

Homework frequency tables

Turn a textbook series into equal-width classes with counts and relative frequencies before drawing the bars by hand or checking a plot.

Latency, scores, and sensors

Bin response times, exam marks, or instrument readings into a stable table you can share, cache, or compare across runs.

What happens if a value is not a number?

Non-numeric tokens, Infinity, and NaN are never coerced to zero, and failed validation is not billed.

Why is the last bin closed on both sides?

Interior bins are half-open [left, right) so each interior edge belongs to exactly one class. The last bin is [left, right] so the sample maximum is counted once instead of falling outside the table.

How are the bin edges chosen?

The first edge is the smallest value in your list and every later edge is one fixed width further on. Edges are not moved to rounder numbers, so the same list and setting always give the same table.

What if I give both a bin width and a number of bins?

The width wins. The calculator uses the width you gave and works out how many bins are needed to cover the range of your values, from the smallest to the largest.

What happens when every value is the same?

There is no range to split, so you get a single bin at that value holding all the observations. The calculator does not invent empty bins on either side of it.

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.

POSThttps://api.kit.forhosting.com/stat/histogram

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.

curl -X POST https://api.kit.forhosting.com/stat/histogram \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":[1,2,2,3,5,7,8,9],"bin_width":2}'
{
  "data": [
    1,
    2,
    2,
    3,
    5,
    7,
    8,
    9
  ],
  "bin_width": 2
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.histogram",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n10000
max_abs1000000000000000
max_bins500
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

When any entry is not a finite number the task fails with invalid_input, so a stray label cannot silently become a zero. The same pure algorithm runs free in the browser and through the API at $0.002 per successful call.

What the histogram returns and how equal-width bins are cut

This calculator does not choose a pretty origin or snap edges to nice numbers: the first edge is the sample minimum and every later edge is offset by a constant width, so two people with the same list and the same width or count always get the same table. When you supply bin_count as a positive integer k, the width is the observed range divided by k, the last edge is exactly the sample maximum, and the last bin is closed on the right so the largest observation is counted once instead of falling off the end. When you supply a positive bin_width, the engine takes as many bins as the ceiling of range divided by that width, at least one, and the last edge may sit slightly past the maximum so every value is covered. There is no random jitter, no current-date seed, and no network step: either the arithmetic finishes inside the published length, magnitude, and bin-count limits, or the call is rejected with invalid_input.

Input contract, non-numeric rejection, and how assignment stays stable

Each token must be a finite decimal, with an optional sign and optional scientific exponent; empty tokens, booleans, objects, Infinity, and NaN fail. If any element is non-numeric the message names the index, for example data[2], so a stray label in a pasted column is visible instead of becoming a silent zero. The required field is data, an array of finite numbers, with aliases values, numbers, x, and series so notebooks and forms can reuse the same contract. A comma-separated, semicolon-separated, or whitespace-separated string of numbers is also accepted when a text box cannot post a JSON array. You must also send either bin_width, a positive finite number, or bin_count, a positive integer at most the published maximum. If both are present, bin_width takes precedence and bin_count is recomputed from the range. Missing data, an empty list, a non-positive width, a non-integer or non-positive count, a list longer than the maximum n, a value outside the magnitude ceiling, or a width so small that the implied bin count would exceed the published maximum all raise invalid_input and are not billed. Nothing is stored after the response returns.

Where a frequency table belongs in study, analysis, and product work

Developers lock the JSON in continuous integration so a future change to assignment rules cannot silently rewrite snapshots. This page is not Scott’s rule, Freedman–Diaconis, or a chart renderer: those tools choose a width or draw bars, while this one consumes a width or a count you already have and returns the bins. Through the API each successful lookup costs $0.002; failed validation is not charged, and the numbers are discarded after the response.

Deterministic chart and feature fixtures

Lock bin ranges and frequencies in tests so a dashboard or a binned covariate cannot drift when chart defaults change.

How does this histogram calculator choose bin edges?

The first edge is the sample minimum. With bin_count k the width is (max − min) / k and the last edge is exactly max. With bin_width h the count is ceil((max − min) / h) and the last edge is min + k·h.

What is the difference between bin_width and bin_count?

bin_width is the length of each class; the engine derives how many bins cover the range. bin_count is how many classes you want; the engine derives the width. If both are sent, bin_width wins.

What does the histogram calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →