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.
compute test statistics that are derived from the empirical cdf. You
may find the empirical cdf plot produced by
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
stats structure with the following fields.
Sample median (50th percentile)
Sample standard deviation
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.
cdfplot(y) hold on x = -20:0.1:10; f = evcdf(x,0,3); plot(x,f,'m') legend('Empirical','Theoretical','Location','NW')