cdfplot - Empirical cumulative distribution function plot

Syntax

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

Description

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

This plot, like those produced by hist and normplot, 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.

FieldDescription

stats.min

Minimum value

stats.max

Maximum value

stats.mean

Sample mean

stats.median

Sample median (50th percentile)

stats.std

Sample standard deviation

Example

The following example compares the empirical cdf for a sample from an extreme value distribution 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.

y = evrnd(0,3,100,1);
cdfplot(y)
hold on
x = -20:0.1:10;
f = evcdf(x,0,3);
plot(x,f,'m')
legend('Empirical','Theoretical','Location','NW')

See Also

ecdf

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS