What Is the Empirical Cumulative Distribution Function (ECDF) and How Do You Use It?
If you have a sample of data and want to see how it is distributed without assuming any theoretical shape, the Empirical Cumulative Distribution Function (ECDF) is one of the simplest and most powerful tools you can use. It plots your data points directly, showing the proportion of observations that fall at or below each value. Unlike histograms, which depend on bin width, the ECDF is a step function that preserves every data point, making it ideal for comparing samples, checking normality, or estimating percentiles.
What It Is
The ECDF is a non‑parametric estimator of the true cumulative distribution function (CDF) of a population. For a sample of \(n\) independent observations \(x_1, x_2, \dots, x_n\), the ECDF is defined at any real value \(x\) as:
\[
\hat{F}(x) = \frac{\text{number of observations} \le x}{n}
\]
In words, \(\hat{F}(x)\) is the cumulative proportion of data points that are less than or equal to \(x\). Because it is computed directly from the sample, no assumption about the underlying probability distribution (normal, exponential, etc.) is required. The ECDF is a step function that jumps by \(1/n\) at each observed data point, and it always ranges from 0 to 1.
How It Works / Steps
\[
\hat{F}(x_{(i)}) = \frac{i}{n}
\]
(Some conventions use \(\frac{i}{n+1}\) or \(\frac{i-0.5}{n}\), but \(\frac{i}{n}\) is the standard definition.)
Key properties:
A Worked Illustrative Example
Example data (illustrative only): Suppose you have 5 measured lengths (in cm): \(2, 5, 3, 4, 5\).
- \(x=2\): \(1/5 = 0.20\)
- \(x=3\): \(2/5 = 0.40\)
- \(x=4\): \(3/5 = 0.60\)
- \(x=5\): \(5/5 = 1.00\) (both 5s count, so 4th and 5th observations give \(4/5=0.80\) and \(5/5=1.00\))
So the ECDF says: 20% of the data are ≤ 2, 40% are ≤ 3, 60% are ≤ 4, and 100% are ≤ 5. If you want the median (50th percentile), you can read it from the ECDF: the first value where \(\hat{F} \ge 0.5\) is 4, so the median is 4 cm. This direct reading of percentiles is a major advantage of the ECDF.
Common Pitfalls
Closing
The ECDF is a fundamental, assumption‑free way to visualize and analyze your data’s distribution. To generate an ECDF plot instantly from your own numbers, try the free tool at https://www.6sq.com/tools/ecdf/ — no installation needed.
What It Is
The ECDF is a non‑parametric estimator of the true cumulative distribution function (CDF) of a population. For a sample of \(n\) independent observations \(x_1, x_2, \dots, x_n\), the ECDF is defined at any real value \(x\) as:
\[
\hat{F}(x) = \frac{\text{number of observations} \le x}{n}
\]
In words, \(\hat{F}(x)\) is the cumulative proportion of data points that are less than or equal to \(x\). Because it is computed directly from the sample, no assumption about the underlying probability distribution (normal, exponential, etc.) is required. The ECDF is a step function that jumps by \(1/n\) at each observed data point, and it always ranges from 0 to 1.
How It Works / Steps
- Sort the data in ascending order: \(x_{(1)} \le x_{(2)} \le \dots \le x_{(n)}\).
- For each sorted value \(x_{(i)}\), compute the cumulative proportion:
\[
\hat{F}(x_{(i)}) = \frac{i}{n}
\]
(Some conventions use \(\frac{i}{n+1}\) or \(\frac{i-0.5}{n}\), but \(\frac{i}{n}\) is the standard definition.)
- Plot the step function: at each \(x_{(i)}\), the value of \(\hat{F}\) jumps from \((i-1)/n\) to \(i/n\). The function is flat between data points.
Key properties:
- \(\hat{F}(x) = 0\) for \(x < x_{(1)}\), and \(\hat{F}(x) = 1\) for \(x \ge x_{(n)}\).
- The ECDF is a consistent estimator: as \(n\) grows, \(\hat{F}(x)\) converges to the true CDF \(F(x)\).
- The Glivenko–Cantelli theorem guarantees that the maximum difference between \(\hat{F}\) and \(F\) goes to 0 almost surely as \(n \to \infty\).
A Worked Illustrative Example
Example data (illustrative only): Suppose you have 5 measured lengths (in cm): \(2, 5, 3, 4, 5\).
- Sort: \(2, 3, 4, 5, 5\).
- Compute \(\hat{F}\) at each sorted value:
- \(x=2\): \(1/5 = 0.20\)
- \(x=3\): \(2/5 = 0.40\)
- \(x=4\): \(3/5 = 0.60\)
- \(x=5\): \(5/5 = 1.00\) (both 5s count, so 4th and 5th observations give \(4/5=0.80\) and \(5/5=1.00\))
So the ECDF says: 20% of the data are ≤ 2, 40% are ≤ 3, 60% are ≤ 4, and 100% are ≤ 5. If you want the median (50th percentile), you can read it from the ECDF: the first value where \(\hat{F} \ge 0.5\) is 4, so the median is 4 cm. This direct reading of percentiles is a major advantage of the ECDF.
Common Pitfalls
- Small samples: With few data points, the ECDF is a coarse step function; interpret percentiles with caution.
- Ties: When multiple observations share the same value, the jump at that value is \(k/n\), where \(k\) is the frequency of the tie — do not forget to count all of them.
- Confusing ECDF with a histogram: A histogram estimates density (area = 1), while the ECDF estimates cumulative probability (always between 0 and 1). They are not interchangeable.
- Ignoring the step nature: Do not connect the points with straight lines unless you are interpolating for a specific percentile — the true ECDF is flat between observations.
Closing
The ECDF is a fundamental, assumption‑free way to visualize and analyze your data’s distribution. To generate an ECDF plot instantly from your own numbers, try the free tool at https://www.6sq.com/tools/ecdf/ — no installation needed.
No related results found
Invited:
6SQ Tools
0 replies