Histogram Bin Calculator

Paste a column of numbers and see how many bins each classic rule recommends — Sturges, Scott, Freedman-Diaconis, Rice and the square-root rule — side by side with the bin width each one implies. Pick a rule (or set your own bin count) and the page builds the histogram: bin edges, counts, percentages, optional cumulative and density columns, and an ASCII bar per bin. Everything is computed on your device.

Try:
Result

About this tool

A histogram turns numeric data into ranges and counts, but the result changes a lot depending on the bin width. This calculator compares several common rules side by side — Sturges, Scott, Freedman-Diaconis, Rice, and square-root — then applies the rule you choose and prints the resulting bin edges, counts, percentages, and optional cumulative or density columns.

Use it when you have a pasted column from a spreadsheet, experiment, log, or small dataset and want a principled starting point before drawing a histogram. Sturges is simple and often smooth for small samples, Scott uses the sample standard deviation, and Freedman-Diaconis uses the IQR so it is less sensitive to outliers.

Worked example

Paste this dataset:

1,2,2,3,3,3,4,5,7,9,12

With the default auto rule, the output first shows the sample summary and every rule's recommended bin count and width. It then builds a histogram table for the selected rule, with interval labels, counts, percentages, and ASCII bars so you can see the distribution shape immediately.

Input notes and limits

Numbers can be separated by newlines, commas, spaces, tabs, semicolons, or pipes. Use plain decimals or scientific notation such as 12, -3.5, or 1.2e3; strip currency symbols and thousands separators first. The tool accepts 2 to 100,000 finite values and caps manual/rule-generated bins at 1,000 rows.

FAQ

Which bin rule should I use?

Start with auto, then compare the rule table. Sturges is often reasonable for small, roughly normal samples. Scott can work well for normal-ish data but is pulled by outliers. Freedman-Diaconis uses the IQR and is usually more robust for skewed data.

What does the auto rule do?

auto chooses the finer of Sturges and Freedman-Diaconis, similar to NumPy's default. It keeps Sturges from being too coarse while still falling back when the IQR rule is not informative.

Why do my bin edges look awkward?

Rule-derived widths are mathematical, so edges can land on values like 1.4286. Turn on nice_edges to round the width up to a 1/2/2.5/5 × power-of-ten step and snap the first edge down when the range start is automatic.

What is density?

Density is count / (n × bin_width), the bar height for a unit-area histogram. It is useful when comparing histograms with different bin widths or sample sizes.

How are edge values assigned?

By default bins are left-closed ([a, b)) and the final bin includes the maximum. Enable right_closed to use (a, b], where values exactly on an edge fall into the lower bin.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool histogram-bin-calculator "1
2
2
3
4
7
8
9
12
15
22
40"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/histogram-bin-calculator/?numbers=1%0A2%0A2%0A3%0A4%0A7%0A8%0A9%0A12%0A15%0A22%0A40&rule=auto&bins=10&range_min=0&range_max=40&nice_edges=true&right_closed=true&precision=4&output=report&cumulative=true&density=true&chart=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.