About the Histogram Maker
This histogram maker turns a list of numbers into a histogram and a frequency table in one step. Paste your data, choose how the bins are set — automatically with Sturges’ rule, the square-root rule, the Rice rule, Scott’s rule or the Freedman–Diaconis rule, or manually with a fixed number of bins or a fixed bin width and starting point — and it draws the bars and lists each bin’s frequency, relative frequency and cumulative totals.
Histograms show the shape of a distribution at a glance: where values cluster, whether the data are symmetric or skewed, whether there are several peaks and whether any values sit far from the rest. Students use this generator for statistics assignments, teachers use it to build class examples, and analysts use it to explore test scores, wait times, sales, measurements or any other numeric data before running further analysis.
The automatic rules follow the same conventions as NumPy’s histogram function: the rule fixes the number of bins and the bins are spread evenly from the minimum to the maximum. Each bin includes its left edge and excludes its right edge, except the last bin, which also includes the maximum. With a custom width, the first bin starts at the value you choose (moved down in whole widths if any data lie below it).
With the default inputs, the number of bins is 6. Change any value above to recalculate instantly.
How to use the histogram maker
- 1Paste your numbers, separated by commas, spaces or new lines.
- 2Pick an automatic bin rule, or choose a custom bin count or width.
- 3For a custom width, set where the first bin should start (e.g. 50 for 50–60, 60–70 …).
- 4Read the histogram for shape, then use the frequency table for exact counts.
- 5Try another rule if the bars look too jagged or too coarse.
Formula and method
A histogram splits the range of the data into k adjacent bins of equal width and counts how many values fall in each. Sturges’ rule suits roughly normal data of moderate size; the square-root rule is a simple default used by spreadsheets; the Rice rule gives more bins for larger samples. Scott’s rule sets the width from the standard deviation, and the Freedman–Diaconis rule from the interquartile range, which makes it robust to outliers.
For the width-based rules the number of bins is k = ⌈range ÷ h⌉, and then — as in NumPy — the k bins are spread evenly from the minimum to the maximum, so the final width is range ÷ k. Each bin is [left edge, right edge) except the last, which is closed so that the maximum is counted. The relative frequency of a bin is its count divided by n.
- n
- Number of data values
- k
- Number of bins
- h
- Bin width
- σ
- Standard deviation of the data
- IQR
- Interquartile range (Q3 − Q1)
Worked examples
30 exam scores, Sturges’ rule
Sturges gives k = ⌈log₂ 30⌉ + 1 = 6 bins. The range 55–99 is 44, so each bin is 44 ÷ 6 ≈ 7.33 points wide. The counts are 2, 3, 8, 8, 5, 4, peaking in the middle bins around the mid-70s to mid-80s.
Same scores in 10-point bins starting at 50
Bins 50–60, 60–70, 70–80, 80–90 and 90–100 hold 1, 4, 11, 9 and 5 scores. The 70s are the most common grade band, with 11 of the 30 students.
Scott’s rule on the exam scores
The population standard deviation is about 10.30, so Scott’s width is 3.49 × 10.30 ÷ 30^(1/3) ≈ 11.6. That needs ⌈44 ÷ 11.6⌉ = 4 bins, re-spread over the range as 11-point bins with counts 3, 10, 10, 7.
Commute times (minutes), Freedman–Diaconis
The IQR-based rule gives 5 bins of 3.7 minutes from 12.5 to 31. Counts of 4, 7, 3, 1, 2 show a right-skewed distribution with a long tail of slow commutes.
Frequently asked questions
How do you make a histogram?+
Choose equal-width intervals (bins) that cover the data, count how many values fall in each bin, then draw a bar for each bin with height equal to the count. The bars touch because the bins are adjacent ranges of a continuous scale.
How many bins should a histogram have?+
There is no single right answer. Sturges’ rule (⌈log₂ n⌉ + 1) works for about 30–200 roughly normal values; the square-root rule is a common default; Freedman–Diaconis is safer for skewed data or outliers. Too few bins hide detail and too many make the shape noisy.
What is the difference between a histogram and a bar chart?+
A histogram shows the distribution of one numeric variable using adjacent bins of a continuous scale, so the bars touch. A bar chart compares separate categories, such as products or countries, and its bars have gaps.
How do I calculate bin width?+
Divide the range (maximum − minimum) by the number of bins and round to a convenient number if you like. For 30 scores from 55 to 99 with 6 bins, the width is 44 ÷ 6 ≈ 7.3, or use 10 for cleaner labels.
Which bin does a value on the edge belong to?+
By the usual convention each bin includes its left edge and excludes its right edge, so 70 goes in 70–80, not 60–70. The last bin is closed on both ends so the maximum value is counted.