]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/iqr.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / iqr.m
1 function Q=iqr(Y,DIM)
2 % IQR calculates the interquartile range  
3 %  Missing values (encoded as NaN) are ignored. 
4 %
5 %  Q = iqr(Y)
6 %  Q = iqr(Y,DIM)
7 %     returns the IQR along dimension DIM of sample array Y.
8 %
9 %  Q = iqr(HIS)
10 %     returns the IQR from the histogram HIS. 
11 %     HIS must be a HISTOGRAM struct as defined in HISTO2 or HISTO3.
12 %
13 % see also: MAD, RANGE, HISTO2, HISTO3, PERCENTILE, QUANTILE
14
15
16 %       $Id$
17 %       Copyright (C) 2009 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 3 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 if nargin<2,
35         DIM = [];
36 end;
37 if isempty(DIM),
38         DIM = min(find(size(Y)>1));
39         if isempty(DIM), DIM = 1; end;
40 end;
41
42
43 if nargin<1,
44         help iqr
45         
46 else
47         Q = quantile(Y,[1,3]/4,DIM); 
48         Q = diff(Q,[],DIM); 
49 end;
50
51
52