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.
| Histogram | Bar chart | |
|---|---|---|
| Horizontal axis | A numeric scale cut into bins | Separate categories |
| Example | Page load time: 0–1 s, 1–2 s, 2–3 s | Browser: Chrome, Safari, Firefox |
| Order of bars | Fixed by the number line | Free: sort by size or name |
| Gaps between bars | None, unless a bin is empty | Usual |
| Choice you must make | Bin width and starting point | Which categories to show |
| Reading | Shape of a distribution | Comparison 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–2 | 2–4 | 4–6 | 6–8 | 8–10 |
|---|---|---|---|---|---|
| Loads | 32 | 22 | 6 | 2 | 2 |
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–1 | 1–2 | 2–3 | 3–4 | 4–5 | 5–6 | 6–7 | 7–8 | 8–9 | 9–10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Loads | 4 | 28 | 4 | 18 | 4 | 2 | 1 | 1 | 1 | 1 |
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.
| Rule | Uses | Bins here | Counts from the smallest value |
|---|---|---|---|
| Sturges | Sample size only | 7 of 1.3 s | 32, 8, 17, 3, 2, 1, 1 |
| Freedman–Diaconis | Sample size and IQR | 9 of about 1.01 s | 29, 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:
- Compute the Freedman–Diaconis width.
- Round it to a readable number with the same order of magnitude, such as 1 second instead of 1.11.
- Redraw with half and double that width.
- 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
| Shape | What it often means in web data | What to do next |
|---|---|---|
| One symmetric peak | One process with random variation | The mean and median agree; report either |
| Long right tail | Durations, order values, load times | Report the median and a high percentile |
| Two peaks | Two populations or two code paths mixed | Split by device, country, page or cache status |
| Spike at one value | A default, a cap, a timeout or a missing value stored as 0 | Inspect the raw rows |
| Isolated bar far away | Errors, bots or rare real cases | Check 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:
- 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.
- 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.
- 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.
- 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
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.3.14 Histogram.
- NumPy documentation, numpy.histogram_bin_edges (Sturges and Freedman–Diaconis estimators and their limits).
- Sturges, H. A. (1926). The Choice of a Class Interval. Journal of the American Statistical Association, 21(153), 65–66. Listed for attribution; the formula and limits above follow the NumPy documentation.
- Freedman, D. and Diaconis, P. (1981). On the histogram as a density estimator: L2 theory. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete (now Probability Theory and Related Fields), 57, 453–476.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

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