Skip to main content
v2026.11,858 entries · CC-BY 4.0

How to Find the Mean From a Histogram (Step by Step)

Find the mean from a histogram: multiply each class midpoint by its frequency, sum, divide by n. Worked example, Excel, R and Python.

Written and maintained by CASRAI Editorial Board

Last updated

To find the mean from a histogram, read each bar’s class interval and its height, take the midpoint of every interval, multiply each midpoint by that bar’s frequency, add the products, and divide by the total number of observations. The answer is an estimate, not the exact mean: a histogram shows how many values fall in each interval but not where inside the interval they sit. This guide shows the arithmetic on a worked example, then compares the estimate with the true mean of the raw data so you can see how large the gap is and what makes it shrink.

How to calculate the mean from a histogram: definition

The mean of a histogram is a weighted average of the class midpoints, with each bar’s frequency as the weight. A histogram consists of adjoining boxes whose vertical axis is labelled frequency or relative frequency (OpenStax Introductory Statistics 2e, section 2.2). Because the individual values are no longer visible, the standard approach is to use the midpoint of each interval in place of the unknown values (OpenStax, section 2.5). That is why the method gives an estimate: you cannot compute an exact mean from grouped data.

Formula for the mean of a histogram, with every symbol explained

x̄ ≈ Σ(f × m) / n

  • x̄ is the estimated mean.
  • f is the frequency of an interval, the height of its bar when the vertical axis shows counts.
  • m is the midpoint of that interval: (lower boundary + upper boundary) / 2.
  • Σ means add the product f × m over every bar.
  • n is the total frequency, which equals Σf, the sum of all the bar heights.

This is the frequency-table formula given by OpenStax, where f is the frequency of the interval and m is the midpoint of the interval.

How to find the mean of a histogram: worked example

This is an illustrative example with made-up data: 20 exam scores out of 100. The histogram has six bars of width 10, and the intervals include their left boundary but not their right one, so a score of exactly 60 is counted in the 60 to under 70 bar. This is the usual convention and matches the one OpenStax describes.

Interval Frequency f Midpoint m f × m
40 to under 50 2 45 90
50 to under 60 5 55 275
60 to under 70 6 65 390
70 to under 80 4 75 300
80 to under 90 2 85 170
90 to under 100 1 95 95
Total 20 1,320
  1. Read the frequencies off the bars: 2, 5, 6, 4, 2, 1. They add to n = 20.
  2. Find each midpoint, for example (40 + 50) / 2 = 45.
  3. Multiply each frequency by its midpoint: 2 × 45 = 90, 5 × 55 = 275, 6 × 65 = 390, 4 × 75 = 300, 2 × 85 = 170, 1 × 95 = 95.
  4. Add the products: 90 + 275 + 390 + 300 + 170 + 95 = 1,320.
  5. Divide by n: 1,320 / 20 = 66.0.

The estimated mean is 66.0. The 20 raw scores behind this histogram are 42, 47, 51, 53, 55, 56, 58, 61, 62, 64, 65, 67, 68, 71, 73, 74, 78, 82, 86 and 93. They add to 1,306, so the true mean is 1,306 / 20 = 65.3. The histogram estimate is off by 0.7.

How to find the mean on a histogram: what the result means

The mean you get from a histogram is a summary of the bar heights, so it changes when the bars change. Re-drawing the same 20 scores with different bar widths and repeating the calculation gives these estimates:

Bar width Number of bars Estimated mean Gap from true mean (65.3)
20 3 66.0 0.7
10 6 66.0 0.7
5 11 65.75 0.45
Raw data none 65.3 0

Narrower bars brought the estimate closer here, but nothing guarantees a smaller gap at every step: width 20 and width 10 gave the same estimate. OpenStax notes that different researchers may set up histograms for the same data in different ways, so two correct histograms of one data set can give slightly different estimated means. When you have the raw values, calculate the mean from them and use the histogram method only for data that arrive already grouped, such as a figure in a published paper.

A histogram also shows the shape of the data, its center and its spread (OpenStax section 2.2; the NIST/SEMATECH e-Handbook lists center, spread, skewness, outliers and multiple modes). If the bars trail off to one side, the mean is pulled toward the tail; see left-skewed versus right-skewed distributions.

Assumptions and common mistakes

How to find the mean from a histogram when the axis is not a count

  • Relative-frequency axis. If the vertical axis shows proportions or percentages, convert each bar to a count first (relative frequency × n), or use the relative frequencies directly as weights, Σ(relative frequency × m). Then there is no need to divide by n, because the weights already add to 1. See relative frequency and frequency distributions.
  • Density axis and unequal bar widths. When bar widths differ, the area of a bar, not its height, represents the frequency. The frequency is then height × width. Using raw heights as frequencies overweights the narrow bars.
  • Open-ended classes. A bar labelled “90 and over” has no upper boundary and so no midpoint. You must assume a boundary yourself, and the result depends on that assumption.

Other mistakes

  • Using the interval’s lower boundary instead of the midpoint. This biases the mean downward. In the example it would give (2 × 40 + 5 × 50 + 6 × 60 + 4 × 70 + 2 × 80 + 1 × 90) / 20 = 1,220 / 20 = 61.0.
  • Averaging the bar heights or the midpoints. The mean of the six frequencies is 3.33 and the mean of the six midpoints is 70. Neither is the mean of the data. The frequencies must act as weights.
  • Counting the same value in two bars. A value on a boundary belongs to exactly one bar, the one for which it is the left boundary.
  • Treating the result as exact. Say “estimated” or “approximately”.

For the cumulative picture of the same grouped data, including medians and quartiles, see the ogive guide. To overlay a normal curve on a histogram, see histograms with a normal distribution curve.

How to report the mean from a histogram (APA example)

In APA style the mean is written with an italic M. Because the value comes from grouped data, say so, and give the class width and n:

The estimated mean exam score, calculated from a frequency distribution with class width 10, was M ≈ 66.0 (n = 20).

If you also have the raw data, report the exact mean instead (M = 65.3) and mention the histogram only as a display.

How to calculate the mean from a histogram in Excel, R or Python

All three snippets use the worked example. Midpoints are 45, 55, 65, 75, 85 and 95; frequencies are 2, 5, 6, 4, 2 and 1.

Excel. Put the midpoints in A2:A7 and the frequencies in B2:B7, then enter:

=SUMPRODUCT(A2:A7, B2:B7) / SUM(B2:B7)

R.

mids   <- c(45, 55, 65, 75, 85, 95)
counts <- c(2, 5, 6, 4, 2, 1)
weighted.mean(mids, counts)   # 66

Python.

edges  = [40, 50, 60, 70, 80, 90, 100]
counts = [2, 5, 6, 4, 2, 1]
mids   = [(a + b) / 2 for a, b in zip(edges[:-1], edges[1:])]
print(sum(f * m for f, m in zip(counts, mids)) / sum(counts))   # 66.0

To draw the histogram itself in R, see histograms in R. For the mean alongside other summary statistics, see descriptive statistics.

FAQ

How do I find the mean from a histogram?

Find the midpoint of each bar’s interval, multiply it by the bar’s frequency, add the products and divide by the total frequency. In the example above this gives 1,320 / 20 = 66.0.

How do I calculate the mean from a histogram if I only have percentages?

Multiply each midpoint by the bar’s relative frequency (as a proportion) and add the results. The proportions already sum to 1, so no division is needed. If the bars are percentages, divide each by 100 first or divide the final sum by 100.

How do I find the mean on a histogram, visually?

You cannot read an exact mean off the picture. The mean is the balance point of the bars, so it lies toward the longer tail. To get a number, use the midpoint calculation.

How do I find the mean of a histogram that has unequal bar widths?

Convert each bar to a frequency first: height × width when the axis is density. Then apply the same formula, Σ(f × m) / n.

Is the mean from a histogram the same as the real mean?

No. It is an estimate based on midpoints. In the example the estimate was 66.0 and the true mean was 65.3.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about How to Find the Mean From a Histogram (Step by Step)

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.