MathsStatistics & Probability

Frequency Distribution
calculator.

A frequency table sorts raw data into counts, so you can see its shape at a glance.

How it's worked out

OpenStax defines a frequency as the number of times a value occurs, and a relative frequency as that count over the total. Cumulative columns add each row to the ones before it, so the last row is always the whole data set.

For measurements with many different values, you sort them into equal classes first. If you leave the boxes blank, the tool picks the count with Sturges' rule, where n is the number of values. Rounding up matches the form used in teaching materials.

k\displaystyle k=⌈log2⁡n+1⌉\displaystyle {}= \lceil \log_2 n + 1 \rceil

Then it divides the span of the data by k and rounds the width up to two significant figures, so that k classes reach the largest value.

w\displaystyle w=max−mink\displaystyle {}= \frac{\text{max} - \text{min}}{k}

Each class holds its lower limit and leaves out its upper limit, except the last, which also holds the largest value. So every value counts once. The square-root rule and the Rice rule sit beside Sturges for comparison, and no rule is right for all data.

Classes each rule suggests
ValuesSturgesSquare rootRice
20656
50788
10081010
500102316
1,000113220
5,000147135

The grouped mean stands every value on its class midpoint m, weights it by the frequency f and divides by the total.

x‾\displaystyle \bar{x}=∑fm∑f\displaystyle {}= \frac{\sum f m}{\sum f}

The grouped median finds the class that holds the middle value, then reads how far in it sits. L is that class’s lower limit, B the count below it, G its frequency and w its width.

median\displaystyle \text{median}=L+n2−BG×w\displaystyle {}= L + \frac{\frac{n}{2} - B}{G} \times w

Worked examples

Twenty test scores from 65 to 95

The range is 30. With 20 scores, Sturges gives 5.32, which rounds up to 6 classes, and the range over 6 is a width of 5. The classes run from 65 to 95, and they hold 3, 2, 4, 3, 4, 4 scores.

Midpoints times frequencies add to 1,625, so the grouped mean is 81.25. The exact mean of the raw scores is 81, so grouping cost 0.25 of a mark.

The median is the 10th of 20 values. 9 scores sit below 80 and that class holds 3, so the grouped median is 81.667.

Open this example in the tool

Grouping twenty heights by round numbers

Left alone, the rule gives classes of 3.7 cm from 153 cm, which is hard to read out. Set a width of 5 and a start of 150, and you get 5 classes on round limits, holding 1, 4, 5, 5, 5 people.

The grouped mean shifts a little, to 164.75 cm, against an exact 164.5 cm. The classes from 160 to 175 cm tie as the tallest, with 5 people each. The start of the first class can change the look of a histogram, so try one or two before you settle on one.

Open this example in the tool

Twenty letter grades

Categories need no classes, only a tally: A 8, B 6, C 4, D 2. A is the mode, with 40% of the grades.

By the second row the cumulative column reaches 70%, so that share of the class has a B or better. This reading only works because the rows have a natural order, and it would mean nothing for favorite colors.

Open this example in the tool

Reading your result

Relative frequency lets you compare groups of different sizes. The column adds to 100%, so a class of 30 and a class of 300 can sit side by side. NIST also notes that dividing by the count and the class width gives a histogram whose total area is 1.

Cumulative frequency answers "how many are below this?" Plotted, it gives a curve from which you can read quartiles and percentiles. The reading assumes the values spread evenly through each class, so treat it as an estimate.

A histogram shows five things. NIST lists center, spread, skewness, outliers and more than one peak. Two separate peaks can mean two groups got mixed together.

Skew shows up in the mean and median. A long tail to the right pulls the mean above the median. NIST’s Pearson 2 coefficient puts a number on that: 3 times the gap between them, over the standard deviation. A positive value points to a longer right tail.

Common mistakes

  • Letting a boundary value land twice. The value on a limit belongs to one class. With limits of 0, 10, 20, 30 and 40, the classes here hold 1, 1, 1, 2 of the values 0, 10, 20, 30 and 40, with 40 in the last class.
  • Quoting the grouped mean when you have the raw data. It is an estimate. Use the exact figure if you can, and keep the grouped formula for tables that have no raw data behind them.
  • Too few or too many classes. Too few hide the shape, and too many leave a ragged chart with gaps. Lane’s advice is to try several widths and keep what best shows the data.
  • Mixing cases in text. Text is compared exactly, so Yes and yes make two rows. Numbers are different: 2 and 2.0 count as one value.
  • Using classes of unequal width with this tool. It only builds equal classes, so a table from a report with open-ended or uneven classes will not match.

Questions people ask

There is no single answer, and rules only give a start. For 20 values, Sturges says 6, the square-root rule 5 and Rice 6. By 1,000 values, Rice says 20 while Sturges stays at 11. Lane prefers Rice, and warns that neither rule is perfect.

Sources