🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Cumulative Frequency — Ogives and Percentile Estimation

Foundations of StatisticsDescriptive Statistics🟢 Free Lesson

Cumulative Frequency

Descriptive Statistics

Running Totals That Unlock Percentiles

Cumulative frequency is the running total of frequencies up to a given value, showing how many observations fall at or below each point.

  • Percentile estimation — Read off any percentile directly from the cumulative curve
  • Ogive plots — The cumulative frequency polygon visualizes the entire distribution
  • ECDF — The empirical cumulative distribution function is the non-parametric version
  • Median and quartiles — Find the 50th percentile (median) by reading the ogive at 50%

The cumulative frequency curve is the most direct path from raw data to percentiles.


What You'll Learn

  • 1Build a grouped cumulative frequency table from raw observations
  • 2Interpolate the median, quartiles, and any percentile from class boundaries
  • 3Explain the difference between an ogive and an ECDF and when each is appropriate
  • 4Connect cumulative curves to ROC, calibration, and survival plots in machine learning

What Is Cumulative Frequency?

Definition

Cumulative frequency is the running total of frequencies up to a given value, showing how many observations fall at or below each point. It is used to determine how many observations fall below or at a particular value.

Where an ordinary frequency table answers "how many values sit in this interval", the cumulative version answers "how many values sit at or below this point", and that second question is the one percentile and quantile questions actually ask. The transformation from one to the other is a running sum, which is why the cumulative column is non-decreasing by construction: it can stay flat across a class nobody occupied, but it can never fall.

Three related quantities are easy to confuse. Cumulative frequency counts observations and ends at . Cumulative relative frequency divides each entry by and ends at 1, so it estimates the distribution function directly. Cumulative frequency density divides by the class width as well, which is the form needed when class widths differ, because otherwise wide classes appear to accumulate faster for reasons of bookkeeping rather than of data. Pick the column that matches the question you intend to answer.

python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

np.random.seed(42)

# Generate test scores
scores = np.random.normal(75, 12, 200).clip(0, 100).astype(int)

# Compute frequency distribution
bins = np.arange(0, 105, 5)
freq, edges = np.histogram(scores, bins=bins)
cum_freq = np.cumsum(freq)

df = pd.DataFrame({
    'Class Interval': [f'{edges[i]}-{edges[i+1]}' for i in range(len(freq))],
    'Frequency': freq,
    'Cumulative Frequency': cum_freq,
    'Cumulative Relative Frequency': (cum_freq / cum_freq[-1]).round(4)
})
print(df.head(10))

Grouped Data and the Interpolation Formula

When only grouped frequencies survive, percentiles must be interpolated inside the class that contains the target position. For the -th percentile with class lower boundary , class frequency , cumulative frequency below that class , class width , and total :

The assumption of uniform spread inside a class is the only modelling step in the whole procedure, and it is exactly where grouping loses information. A class of width 10 containing 13 observations can hold them anywhere from all at one end to evenly spread, and the interpolated median differs accordingly. This is why computing percentiles from raw values is always preferable and grouping is reserved for situations where the raw data are unavailable.

The Ogive and the Empirical CDF

The ogive is a polygon drawn through the cumulative frequencies plotted against the upper class boundaries, conventionally anchored at the lower boundary of the first class with a cumulative frequency of zero so the curve starts honestly at the bottom. Its S-shape carries information: a steep middle section means observations crowd the centre, long flat wings mean the tails are sparse, and an asymmetric S indicates the same skewness you would read from a histogram.

The empirical cumulative distribution function does the same job without binning. It plots the ordered observations themselves, jumping by at each data value, so no class boundaries and no interpolation assumption are involved.

python
fig, axes = plt.subplots(1, 2, figsize=(12, 5))

# Ogive
axes[0].plot(edges[1:], cum_freq, marker='o', linewidth=2)
axes[0].fill_between(edges[1:], cum_freq, alpha=0.3)
axes[0].set_title('Ogive (Cumulative Frequency Graph)')
axes[0].set_xlabel('Score')
axes[0].set_ylabel('Cumulative Frequency')
axes[0].grid(True, alpha=0.3)

# ECDF (Empirical CDF)
sorted_scores = np.sort(scores)
ecdf = np.arange(1, len(sorted_scores) + 1) / len(sorted_scores)
axes[1].step(sorted_scores, ecdf, linewidth=2)
axes[1].set_title('Empirical CDF (ECDF)')
axes[1].set_xlabel('Score')
axes[1].set_ylabel('Cumulative Probability')
axes[1].grid(True, alpha=0.3)

plt.tight_layout()
plt.savefig('cumulative-frequency.png', dpi=150)
plt.show()
PropertyOgiveECDF
Built fromGrouped classesRaw ordered values
ShapePiecewise linearRight-continuous step
Bin sensitivityYesNone
Ends atn or 11
Typical useTextbook grouped dataModern statistical software

The ECDF is also the object behind the Kolmogorov-Smirnov test: the statistic is the largest vertical gap between the empirical curve and a hypothesised distribution function, so a single number measures how far the whole distribution sits from its claim. Comparing two samples works the same way, using the largest gap between their two ECDFs.

Percentile Estimation From an Ogive

python
# Estimate median (50th percentile) from cumulative frequency
target_freq = 0.5 * cum_freq[-1]
median_idx = np.searchsorted(cum_freq, target_freq)
estimated_median = edges[1:][median_idx]
print(f"Estimated median from ogive: {estimated_median}")
print(f"Actual median: {np.median(scores)}")

# Estimate quartiles
for q, name in [(0.25, 'Q1'), (0.50, 'Median'), (0.75, 'Q3')]:
    target = q * cum_freq[-1]
    idx = np.searchsorted(cum_freq, target)
    est = edges[1:][idx]
    print(f"{name}: Estimated = {est}, Actual = {np.percentile(scores, q*100):.1f}")

The code reads the step rather than interpolating, which is why its estimates jump to class boundaries and can sit a few points away from np.percentile, which interpolates between ordered values. For reporting quantiles, prefer the interpolating version; for grading against a cumulative curve drawn by hand, the step-reading version reproduces what the picture shows.

The reverse reading is equally useful. Draw a vertical line up from a score of 75, cross the curve, and read the percentage on the left axis: that is the percentile rank of a score of 75. The same curve answers both "what score is at the 90th percentile" and "what percent scored below 75", and switching between them costs nothing.

Cumulative Frequency in Machine Learning

ML ApplicationCumulative Freq UsageWhy
ROC curvesCumulative TPR vs FPRModel threshold selection
CalibrationPredicted vs observed cumulativeReliability diagrams
Survival analysisKaplan-Meier curvesTime-to-event prediction
Ranking evaluationCumulative gains and liftTargeting the top decile
python
import numpy as np
from sklearn.metrics import roc_curve, auc
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression

X, y = make_classification(n_samples=500, random_state=42)
model = LogisticRegression(random_state=42).fit(X, y)
y_proba = model.predict_proba(X)[:, 1]

fpr, tpr, thresholds = roc_curve(y, y_proba)
roc_auc = auc(fpr, tpr)
print(f"AUC-ROC: {roc_auc:.3f}")
print(f"TPR at FPR=0.1: {tpr[np.searchsorted(fpr, 0.1)]:.3f}")
print("ROC curve is a cumulative frequency diagram of TPR vs FPR")

Every threshold on a classifier partitions the ranked predictions into "predicted positive" and "predicted negative", and sweeping that threshold traces the cumulative true positive rate against the cumulative false positive rate — an ROC curve is an ogive of outcomes read in rank order. The area under it is the probability that a randomly chosen positive outranks a randomly chosen negative. Calibration plots compare the cumulative observed rate against the cumulative predicted rate in bins, and a Kaplan-Meier curve is simply the ogive of survival times with censored observations handled instead of counted as failures.

Common Mistakes

Reading the ogive against the lower class boundary

Fix: Cumulative frequencies are conventionally plotted at the upper boundary. Using lower boundaries shifts every quantile by one class width.

Comparing ogives built with different class widths or boundaries

Fix: Grouping choices change the curve. Compare ECDFs instead, or re-bin both datasets identically before plotting.

Treating a grouped percentile estimate as exact

Fix: Interpolation assumes values are uniform inside the class. Report it as an estimate and compute percentiles from raw data whenever those data are available.

Best Practices

  • Plot the ECDF alongside the histogram; the cumulative view exposes gaps and clusters the histogram hides
  • Anchor the ogive at zero on the lower boundary of the first class so the curve covers the full range
  • State the interpolation method when reporting grouped quantiles so the numbers can be reproduced

Key Takeaways

  • Cumulative frequency is the running total of frequencies, so the curve never decreases
  • Grouped percentiles use L + ((k/100·n − c)/f) × h, which assumes uniform spread inside the class
  • An ECDF is the unbinned version: a right-continuous step rising by 1/n at every observation
  • The ogive is the visual form of the same object, and the ROC curve is its cousin in model evaluation

Frequently Asked Questions

Why is the ogive plotted at upper class boundaries?

Because a cumulative frequency of 24 for the class ending at 69 means 24 observations are at or below 69, so the point belongs at 69 on the horizontal axis. Plotting it at 60 would assert that all 24 fell at or below 60, shifting every reading leftward by the class width.

How is an ogive different from an ECDF?

The ogive is drawn from grouped class frequencies and is only as accurate as the binning; the ECDF is drawn from the raw ordered values, jumps by 1/n at each one, and involves no grouping assumption. The ECDF is what modern software computes and what the Kolmogorov-Smirnov statistic measures against.

Does the cumulative frequency curve tell me about shape?

Yes. Steep sections mark where observations are dense and flat sections where they are sparse, and an asymmetric S mirrors the skewness of the histogram. A curve that rises quickly and then crawls describes right-skewed data, which is the common shape for incomes, prices, and durations.

Interview Questions

Q1: How do you estimate the median from grouped data?

Locate position n/2, identify the class containing it, then apply L + ((n/2 − c)/f) × h with L the lower boundary, c the cumulative frequency below the class, f its frequency, and h its width. For n = 50 with c = 24, f = 12, h = 10, L = 69.5 the answer is 70.33.

Q2: What is the relationship between cumulative frequency and percentiles?

A percentile is the value where the cumulative relative frequency reaches k/100. Reading horizontally from that level to the curve and down to the axis gives the k-th percentile directly.

Q3: Why must a cumulative frequency curve be non-decreasing?

Each entry adds a non-negative frequency to the previous total, so the sequence can never drop. A curve that falls indicates a computation error rather than a data property.

Q4: Where do cumulative curves appear in machine learning?

ROC curves plot cumulative true positive rate against cumulative false positive rate across thresholds, calibration plots compare cumulative observed against predicted rates, and Kaplan-Meier curves are cumulative survival functions with censoring handled.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Statistics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement