www.gusucode.com > stats 源码程序 matlab案例代码 > stats/PlotEmpiricalCdfAndCompareWithSamplingDistributionExample.m

    %% Compare Empirical cdf with Sampling Distribution
% 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.

% Copyright 2015 The MathWorks, Inc.


%%
% 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')