]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/cdfplot.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / cdfplot.m
1 function [h,stats] = cdfplot(X, varargin)
2 % CDFPLOT plots empirical commulative distribution function
3 %
4 %   cdfplot(X)
5 %   cdfplot(X, FMT)
6 %   cdfplot(X, PROPERTY, VALUE,...)
7 %   h = cdfplot(...)
8 %   [h,stats] = cdfplot(X)
9 %
10 %  X contains the data vector
11 %       (matrix data is currently changed to a vector, this might change in future) 
12 %  FMT,PROPERTY,VALUE 
13 %       are used for formating; see HELP PLOT for more details 
14 %  h    graphics handle to the cdf curve
15 %  stats 
16 %       a struct containing various summary statistics including
17 %       mean, std, median, min, max.
18 %
19 % see also: ecdf, median, statistics, hist2res, plot
20 %
21 % References: 
22
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/
27
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.
32
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.
37
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.
41
42
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{:});
48
49 if nargout>0,
50         h = hh; 
51 end;
52 if nargout>1,
53         stats = hist2res(his);
54         stats.median = quantile(his,.5); 
55 end;
56
57