ThisCalculator

Everyday

Count Numbers by Range: How to Tally Data in Bins

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

This calculator counts how many numbers in your list fall into each range (bin) you define. You enter your numbers and the bin edges, and it returns the count per bin, plus the total. It is the same operation as a histogram or a frequency table.

Formula

For each bin defined by a lower bound L and an upper bound U (the next bin’s lower bound), the count is:

Count = number of values x in the data list such that L ≤ x < U

For the last bin, the upper bound is infinity, so it includes all values ≥ L.

Variables:

  • x – each value in your data list (any real number)
  • L – lower bound of a bin (included)
  • U – upper bound of a bin (excluded, except for the last bin)

Worked Example

Using the default data list: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Bin edges (lower bounds): 1, 4, 7

This creates three bins:

  • Bin 1: 1 ≤ x < 4 → values 1, 2, 3 → count = 3
  • Bin 2: 4 ≤ x < 7 → values 4, 5, 6 → count = 3
  • Bin 3: 7 ≤ x (last bin) → values 7, 8, 9, 10 → count = 4

Total count = 3 + 3 + 4 = 10, which matches the number of data points.

When to Use This

Counting by range is useful whenever you need to summarize a large set of numbers into a few groups. Common scenarios include:

  • Creating a histogram for a statistics class
  • Grouping test scores into grade ranges (e.g., 90-100, 80-89)
  • Analyzing age groups in a survey
  • Binning sensor readings for quality control
  • Understanding the distribution of prices, weights, or times

This is the first step in frequency analysis. Once you have counts per bin, you can compute relative frequencies (count / total) or cumulative frequencies.

How to Read the Result

The output shows the count for each bin in the order you entered the edges. For example, if you enter edges 0, 10, 20, you get three counts: numbers from 0 to 9.99…, numbers from 10 to 19.99…, and numbers 20 and above. The first count corresponds to the first bin, the second to the second, and so on.

If a data value is exactly equal to a bin edge, it goes into the bin where that edge is the lower bound (inclusive), not the previous bin. For example, with edges 0 and 10, the value 10 goes into the second bin (10 and above), not the first.

Common Mistakes

  • Overlapping bins: If your bin edges are not strictly increasing, some values may fall into multiple bins or none. Always list edges in ascending order.
  • Misunderstanding boundaries: A common error is thinking a value equal to an edge belongs to the lower bin. By default, it belongs to the upper bin (except for the first bin).
  • Forgetting the last bin: The last bin extends to infinity, so it includes all values greater than or equal to the last edge. If you want a finite upper limit, add one more edge.
  • Using the wrong data type: Ensure your data list contains numbers, not text. The calculator cannot count “high” or “low”.

Choosing Bin Edges

The choice of bin edges affects how informative your counts are. Here are some guidelines:

  • Use edges that are meaningful for your data, such as round numbers or natural breakpoints.
  • For small datasets (fewer than 20 values), 3-5 bins are usually enough.
  • For larger datasets, aim for 5-15 bins. A common rule of thumb is the square root of the number of data points (e.g., 100 points → 10 bins).
  • Make sure every data point falls into some bin. If your smallest value is 0, start with an edge ≤ 0.

If you are unsure, try a few different edge sets and see which gives the clearest picture of the distribution.

Limits of This Method

Counting by range loses information: you no longer know the exact values, only which bin they fall into. This is fine for summaries, but if you need precise statistics (mean, median, standard deviation), use the raw data instead. Also, the choice of bin edges can change the apparent shape of the distribution, so be consistent when comparing different datasets.

This calculator assumes your bin edges are lower bounds. If you prefer upper bounds (e.g., “0-10” meaning 0 to 10 inclusive), you can adjust by adding a small epsilon to the edges, but that is rarely necessary for counting purposes.

Frequently Asked Questions

What if a number is exactly on a bin edge?

It goes into the bin where that edge is the lower bound. For example, with edges 0 and 10, the value 10 goes into the second bin (10 and above), not the first. This is the standard convention in histograms.

Can I count numbers in ranges like “1-10” and “11-20”?

Yes, but you need to be careful with the boundary. If you want 1-10 and 11-20, use edges 1, 11, 21. Then the first bin is 1 to 10.99…, and the second is 11 to 20.99… . If you use edges 1, 10, 20, then 10 goes into the second bin, not the first.

What if I have negative numbers?

Negative numbers work fine. Just make sure your bin edges are in ascending order. For example, data -5, -2, 0, 3 with edges -5, 0, 3 gives bins: -5 ≤ x < 0 (values -5, -2), 0 ≤ x < 3 (value 0), and 3 ≤ x (value 3).

How do I count numbers greater than a certain value?

Use that value as the only bin edge. For example, to count numbers greater than or equal to 10, enter edges: 10. The calculator will count all values ≥ 10.

Can I count numbers between two values, like 5 and 10?

Yes, enter edges: 5, 10. The first bin counts numbers from 5 to 9.99…, and the second counts numbers 10 and above. To count only numbers between 5 and 10 (inclusive of 5, exclusive of 10), you would look at the first bin.

Why is the last bin different?

The last bin has no upper bound, so it includes all values ≥ the last edge. This is necessary to ensure every data point is counted. If you want a finite last bin, add an extra edge at the upper limit.

Related

Formula used
in list | Data list | - | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 | 0
in list | Bin edges (lower bounds) | - | 1, 4, 7 | 0
out count | Count per bin | - | 0 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.