Histogram Calculator

Histogram Calculator

Draw a histogram from raw data, choose the number of bins by a standard rule or by hand, and read the shape from the mean, median and skewness.

bins = ⌈log₂ n + 1⌉ · width = range ÷ bins

Paste or type your data to draw the histogram

What Is a Histogram?

A histogram is a bar chart of numerical data in which each bar covers a range of values and its height shows how many observations fall in that range. The bars touch, because the ranges run on from one another without gaps.

It's the quickest way to see a distribution's shape. You can spot where values cluster, whether there's one peak or two, and whether a long tail stretches out on one side.

The number of bins changes the picture. Too few hide the detail; too many turn the chart into noise. Rules like Sturges' and Freedman–Diaconis give a sensible starting point, but it's worth trying more than one.

Histogram Bin Formulas

As given in Sturges (1926) and Freedman & Diaconis (1981). See Sources.

1. Sturges' rule

k = ⌈log₂ n + 1⌉

2. Square-root rule

k = ⌈√n⌉

3. Freedman–Diaconis rule

width = 2 × IQR ÷ ∛n, then k = ⌈range ÷ width⌉

Because it uses the IQR, a few extreme values don't make the bins too wide. It suits skewed data and large samples.

Worked Example: 24 Delivery Times

Given:
A takeaway logs 24 delivery times, from 18 to 58 minutes.
Step 1:
Bins by Sturges' rule:
⌈log₂ 24 + 1⌉ = 6 · width = (58 − 18) ÷ 6 = 6.667 min
Step 2:
Bar heights, left to right:
11, 9, 1, 1, 1, 1
Step 3:
Read the shape:
mean 27.58 · median 25 · skewness 2.03
Result:
Right-skewed, with 20 of 24 deliveries in 18–31 minutes

A few slow deliveries (40, 45, 58) stretch the right tail and drag the mean above the median. For a "typical" delivery time, quote the median.

Histogram Bin Rules Compared

The three rules applied to the delivery-time data.

Bins and bar heights suggested by each rule for the delivery example
RuleBinsWidthBar heightsBest for
Sturges66.6711 9 1 1 1 1Bell-shaped data, n under ~200
Square root5813 7 2 1 1Quick default (Excel uses it)
Freedman–Diaconis857 9 4 1 1 1 0 1Skewed data, outliers, large n

Common Histogram Mistakes

  • Leaving gaps between bars. Gaps suggest separate categories. A histogram's bars should touch because the number line is continuous.
  • Using a histogram for categories. Colours or brands have no order or width, so they need a bar chart, not a histogram.
  • Trusting one choice of bins. Shifting or resizing bins can make a second peak appear or vanish. Check two or three settings before describing the shape.
  • Unequal bins drawn by count. A double-width bin should be drawn half as tall per unit (frequency density), or it overstates that range.

Histogram FAQs

How many bins should a histogram have?

Usually 5 to 20. Sturges’ rule gives 6 for 24 values and 11 for 1,000; Freedman–Diaconis adapts to the spread.

What is the difference between a histogram and a bar chart?

A histogram shows numerical ranges with touching bars; a bar chart shows separate categories with gaps between bars.

Which bin does a value on an edge go in?

The higher bin, except the maximum, which goes in the last bin so nothing falls off the end.

What does the skewness number mean?

Above about +0.5 is right-skewed, below −0.5 left-skewed, and in between roughly symmetric. It’s the sample-adjusted value Excel’s SKEW gives.

Why are the mean and median marked?

Their positions show skew at a glance: in a right-skewed histogram the mean sits to the right of the median.

Can I set my own bin edges?

This page uses equal bins from the minimum to the maximum. For tidy edges like 10, 20, 30, use the frequency distribution calculator.

How do I compare two groups?

Use relative frequencies on the same bins, or a frequency polygon or box plot, which overlay more cleanly.

What if all my values are the same?

Then there is one bar holding everything; there is no spread to show.

Sources

Related Tools