TapCub is live — analytics, insights and live chat, free on one platform
Glossary

Histogram: definition and how bin width changes the story

A histogram shows how numeric values are distributed across bins. See how it differs from a bar chart, how bin width changes the reading of 64 page load times, and two rules for choosing it.

Chen Yu Reviewed by Sophia Bennett Also called frequency histogram Last updated Dec 3, 2026 Glossary

Quick answer

A histogram is a chart of how numeric values are distributed: the range is cut into consecutive bins and each bar shows how many observations fall in that bin. It reveals peaks, spread, skew and outliers that an average hides, and its reading depends on bin width.

Formula: Sturges: k = ⌈log2 n⌉ + 1 bins; Freedman–Diaconis: bin width h = 2 × IQR × n^(−1/3)

What is a histogram?

A histogram is a chart that shows how a set of numeric values is distributed. The value range is cut into consecutive intervals, called bins or classes, and a bar is drawn over each bin with a height equal to the number of observations that fall inside it. The NIST handbook describes the most common form in exactly these steps: split the range of the data into equal-sized bins, then count the points in each.

A histogram answers questions that a single average cannot. Where do most values sit? How far do they spread? Is there one peak or two? Is there a long tail on one side, or a few values far away from everything else? For web data such as page load time, session duration or order value, those questions usually matter more than the mean.

Two variations are common. A relative histogram shows each bin's share of the total instead of a count, which makes groups of different sizes comparable. A cumulative histogram shows, for each bin, the count of that bin plus all bins below it, so you can read statements such as "how many loads finished within 3 seconds".

Histogram vs bar chart: what is the difference?

Both draw bars, and they are often confused. The difference lies in what the horizontal axis means.

HistogramBar chart
Horizontal axisA numeric scale cut into binsSeparate categories
ExamplePage load time: 0–1 s, 1–2 s, 2–3 sBrowser: Chrome, Safari, Firefox
Order of barsFixed by the number lineFree: sort by size or name
Gaps between barsNone, unless a bin is emptyUsual
Choice you must makeBin width and starting pointWhich categories to show
ReadingShape of a distributionComparison between categories

A quick test: if you can reorder the bars without changing the meaning, it is a bar chart. If you cannot, because 1–2 seconds must sit before 2–3 seconds, it is a histogram. Drawing categories is covered in how to create a bar graph; load times are continuous data, the natural input for a histogram.

Worked example: how bin width changes the story

Here are 64 page load times in seconds, sorted (sample data):

0.7 0.8 0.9 0.9 1.0 1.0 1.1 1.1
1.1 1.2 1.2 1.2 1.2 1.3 1.3 1.3
1.3 1.3 1.4 1.4 1.4 1.4 1.5 1.5
1.5 1.6 1.6 1.7 1.7 1.8 1.9 1.9
2.1 2.3 2.6 2.8 3.0 3.1 3.2 3.2
3.3 3.3 3.4 3.4 3.4 3.5 3.5 3.5
3.6 3.6 3.7 3.7 3.8 3.9 4.0 4.1
4.3 4.6 5.2 5.8 6.4 7.1 8.3 9.8

The mean is 173.7 ÷ 64 = 2.71 seconds and the median is 2.0 seconds. Now count the same data three ways. Each bin includes its lower edge and excludes its upper edge.

Bins of 2 seconds:

Bin (s)0–22–44–66–88–10
Loads3222622

The chart falls steadily from left to right. It looks like ordinary right-skewed load times: most are fast, some are slow.

Bins of 1 second:

Bin (s)0–11–22–33–44–55–66–77–88–99–10
Loads428418421111

Now there are two peaks: 28 loads between 1 and 2 seconds and 18 between 3 and 4 seconds, with only 4 in between. This is a different story. Something splits visitors into a fast group and a slow group, for instance cached against uncached pages, two server regions, or desktop against mobile networks.

Note what happens to the two summary numbers. The median of 2.0 seconds and the mean of 2.71 seconds both sit in the valley, where very few loads actually happen. Neither describes a typical visit.

Bins of 0.1 seconds: the 64 values now scatter over 92 narrow bins between the smallest and largest value. Only 37 of them contain anything, and the tallest holds 5 loads. The chart turns into a comb of spikes, and the shape disappears into noise.

How to choose bin width: Sturges and Freedman–Diaconis

No width is correct for every data set, but two widely implemented rules give a defensible starting point.

Sturges' rule, named after a 1926 note, sets the number of bins from the sample size alone. In the form software commonly uses, k = ⌈log₂ n⌉ + 1. For n = 64, log₂ 64 = 6, so k = 7. The range is 9.8 − 0.7 = 9.1 seconds, giving a width of 9.1 ÷ 7 = 1.3 seconds.

The Freedman–Diaconis rule (1981) sets the width from the spread of the middle half: h = 2 × IQR × n^(−1/3). Here Q1 = 1.3 and Q3 = 3.525 (linear interpolation), so the IQR is 2.225. The cube root of 64 is 4, so h = 2 × 2.225 ÷ 4 = 1.11 seconds. NumPy turns that into a whole number of bins covering the range: ⌈9.1 ÷ 1.11⌉ = 9 bins.

RuleUsesBins hereCounts from the smallest value
SturgesSample size only7 of 1.3 s32, 8, 17, 3, 2, 1, 1
Freedman–DiaconisSample size and IQR9 of about 1.01 s29, 6, 17, 6, 1, 2, 1, 1, 1

Both rules reveal the second peak. They are starting points, not verdicts. The NumPy documentation notes that Sturges assumes roughly normal data and tends to give too few bins for large non-normal samples, while Freedman–Diaconis resists outliers but can be conservative on small data sets.

A practical procedure:

  1. Compute the Freedman–Diaconis width.
  2. Round it to a readable number with the same order of magnitude, such as 1 second instead of 1.11.
  3. Redraw with half and double that width.
  4. Trust features that survive at least two of the three views. Be suspicious of a peak that exists at only one width or one starting point.

Reading the shape of a histogram

ShapeWhat it often means in web dataWhat to do next
One symmetric peakOne process with random variationThe mean and median agree; report either
Long right tailDurations, order values, load timesReport the median and a high percentile
Two peaksTwo populations or two code paths mixedSplit by device, country, page or cache status
Spike at one valueA default, a cap, a timeout or a missing value stored as 0Inspect the raw rows
Isolated bar far awayErrors, bots or rare real casesCheck each before deleting

Shape is a prompt for a question, not an answer. In the example, the next step is to color or split the same 64 loads by device and by cache status and see which one separates the two groups.

Common histogram mistakes

  • Trusting the default width. Always try at least one narrower and one wider setting.
  • Unequal bins drawn as counts. If one bin is four times wider than its neighbors, its bar gets a head start. Either use equal widths or plot density, so that area represents share.
  • A hidden overflow bin. A last bar labeled "over 10 s" can hold a very long tail. Say where it starts and what the maximum is.
  • Comparing counts between groups of different size. Use shares, with the same bin edges for both groups.
  • Cutting the vertical axis. Bar height stands for frequency, so the axis should start at zero.
  • Reading a few observations as shape. With a dozen values, any peak may be chance. Show the points instead.

Histograms in TapCub

To repeat the exercise on your own data:

  1. Open the distribution view. All-platform analytics › Behavior › Distribution draws a histogram with the count and share in each bucket, plus total, mean and median cards. The subject can be event counts per person, active days, a numeric property, pages per session or session duration.
  2. Set your own edges. If your pages send load time as a numeric event property, choose that property and type ascending Custom edges (up to 50), for example every 0.5 seconds up to 6, then larger steps. Without custom edges, a numeric property is split into equal widths from the minimum to the 99th percentile, with 10 automatic bins by default and 2 to 50 allowed; larger values fall into the last bucket. Run it twice with different widths.
  3. Know the fixed buckets. In Monitoring › Performance, load time distribution places largest contentful paint into four buckets: 0–1 s, 1–2 s, 2–4 s and over 4 s. If our 64 values were such samples, counting a boundary value upward, the buckets would hold 4, 28, 22 and 10, and the valley between 2 and 3 seconds would be invisible. Use the P50, P75, P90 and P99 switch and the breakdown by page, device or country next to it.
  4. Split the two peaks. Add a filter for one device type or country in the distribution view, run it again, and compare. If one peak vanishes, you have found what divides the visitors.

More on setting up the buckets is in how to analyze event distribution, and targets for load time are discussed in good page load time.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Chen Yu

Technical Engineer

Focuses on tracking code, SDKs, and API integrations, with practical guidance on implementation checks and troubleshooting.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

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

A histogram puts a numeric scale on the horizontal axis and cuts it into adjacent bins, so bar order is fixed. A bar graph compares separate categories, such as browsers or countries, whose bars can be sorted any way. Histograms describe a distribution; bar graphs compare categories.

How many bins should a histogram have?

Start with a rule, then compare. Sturges uses the sample size, giving 7 bins for 64 values. Freedman–Diaconis uses the interquartile range, giving a width of about 1.11 seconds in the sample here. Redraw with half and double the width and trust features that persist.

What does a histogram with two peaks mean?

Two peaks usually mean two different populations or processes are mixed together, such as cached and uncached page loads. Averages can fall in the valley between them and describe nobody. Split the data by a likely cause, such as device or page, and draw each group again.

Can a histogram be used for categorical data?

No. Categories such as country or plan name have no numeric scale to cut into bins. Use a bar chart of counts or shares instead. Histograms fit continuous values such as time, amount or size, and counts with many distinct values.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics