]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/percentile.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / percentile.m
1 function Q=percentile(Y,q,DIM)
2 % PERCENTILE calculates the percentiles of histograms and sample arrays.  
3 %
4 %  Q = percentile(Y,q)      
5 %  Q = percentile(Y,q,DIM)      
6 %     returns the q-th percentile along dimension DIM of sample array Y.
7 %     size(Q) is equal size(Y) except for dimension DIM which is size(Q,DIM)=length(Q)
8 %
9 %  Q = percentile(HIS,q)
10 %     returns the q-th percentile from the histogram HIS. 
11 %     HIS must be a HISTOGRAM struct as defined in HISTO2 or HISTO3.
12 %     If q is a vector, the each row of Q returns the q(i)-th percentile 
13 %
14 % see also: HISTO2, HISTO3, QUANTILE
15
16 %       $Id: percentile.m 8223 2011-04-20 09:16:06Z schloegl $
17 %       Copyright (C) 1996-2003,2005,2006,2007 by Alois Schloegl <alois.schloegl@gmail.com>     
18 %       This function is part of the NaN-toolbox
19 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
20
21 %    This program is free software; you can redistribute it and/or modify
22 %    it under the terms of the GNU General Public License as published by
23 %    the Free Software Foundation; either version 2 of the License, or
24 %    (at your option) any later version.
25 %
26 %    This program is distributed in the hope that it will be useful,
27 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
28 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 %    GNU General Public License for more details.
30 %
31 %    You should have received a copy of the GNU General Public License
32 %    along with this program; If not, see <http://www.gnu.org/licenses/>.
33
34
35 if nargin==2,
36         Q = quantile(Y,q/100); 
37
38 elseif nargin==3,
39         Q = quantile(Y,q/100,DIM); 
40
41 else
42         help percentile
43
44 end;
45
46
47