1 function [h,stats] = cdfplot(X, varargin)
2 % CDFPLOT plots empirical commulative distribution function
6 % cdfplot(X, PROPERTY, VALUE,...)
8 % [h,stats] = cdfplot(X)
10 % X contains the data vector
11 % (matrix data is currently changed to a vector, this might change in future)
13 % are used for formating; see HELP PLOT for more details
14 % h graphics handle to the cdf curve
16 % a struct containing various summary statistics including
17 % mean, std, median, min, max.
19 % see also: ecdf, median, statistics, hist2res, plot
23 % $Id: cdfplot.m 8351 2011-06-24 17:35:07Z carandraug $
24 % Copyright (C) 2009,2010 by Alois Schloegl <alois.schloegl@gmail.com>
25 % This function is part of the NaN-toolbox
26 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
28 % This program is free software; you can redistribute it and/or
29 % modify it under the terms of the GNU General Public License
30 % as published by the Free Software Foundation; either version 3
31 % of the License, or (at your option) any later version.
33 % This program is distributed in the hope that it will be useful,
34 % but WITHOUT ANY WARRANTY; without even the implied warranty of
35 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 % GNU General Public License for more details.
38 % You should have received a copy of the GNU General Public License
39 % along with this program; if not, write to the Free Software
40 % Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
43 his = histo_mex(X(:));
44 cdf = cumsum(his.H,1) ./ sum(his.H,1);
45 ix1 = ceil ([1:2*size(his.X,1)]'/2);
46 ix2 = floor([2:2*size(his.X,1)]'/2);
47 hh = plot (his.X(ix1), [0; cdf(ix2)], varargin{:});
53 stats = hist2res(his);
54 stats.median = quantile(his,.5);