This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Empirical cumulative distribution function plot


h = cdfplot(X)
[h,stats] = cdfplot(X)


cdfplot(X) displays a plot of the empirical cumulative distribution function (cdf) for the data in the vector X. The empirical cdf F(x) is defined as the proportion of X values less than or equal to x.

This plot is useful for examining the distribution of a sample of data. You can overlay a theoretical cdf on the same plot to compare the empirical distribution of the sample to the theoretical distribution.

The kstest, kstest2, and lillietest functions compute test statistics that are derived from the empirical cdf. You may find the empirical cdf plot produced by cdfplot useful in helping you to understand the output from those functions.

h = cdfplot(X) returns a handle to the cdf curve.

[h,stats] = cdfplot(X) also returns a stats structure with the following fields.



Minimum value


Maximum value


Sample mean


Sample median (50th percentile)


Sample standard deviation


collapse all

This example shows how to plot the empirical cdf of sample data and compare it with a plot of the cdf for the sampling distribution. In practice, the sampling distribution would be unknown, and would be chosen to match the empirical cdf.

Generate random sample data from an extreme value distribution with a location parameter mu = 0 and scale parameter sigma = 3.

rng default;  % For reproducibility
y = evrnd(0,3,100,1);

Plot the empirical cdf of the sample data on the same figure as the cdf of the sampling distribution.

hold on
x = -20:0.1:10;
f = evcdf(x,0,3);

See Also

Introduced before R2006a

Was this topic helpful?