comparison scripts/statistics/base/prctile.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents fd0a3ac60b0e
children 6ef23b4a3402
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
20 ## @deftypefn {Function File} {@var{y} =} prctile (@var{x}, @var{p}) 20 ## @deftypefn {Function File} {@var{y} =} prctile (@var{x}, @var{p})
21 ## @deftypefnx {Function File} {@var{q} =} prctile (@var{x}, @var{p}, @var{dim}) 21 ## @deftypefnx {Function File} {@var{q} =} prctile (@var{x}, @var{p}, @var{dim})
22 ## For a sample @var{x}, compute the quantiles, @var{y}, corresponding 22 ## For a sample @var{x}, compute the quantiles, @var{y}, corresponding
23 ## to the cumulative probability values, @var{p}, in percent. All non-numeric 23 ## to the cumulative probability values, @var{p}, in percent. All non-numeric
24 ## values (NaNs) of @var{x} are ignored. 24 ## values (NaNs) of @var{x} are ignored.
25 ## 25 ##
26 ## If @var{x} is a matrix, compute the percentiles for each column and 26 ## If @var{x} is a matrix, compute the percentiles for each column and
27 ## return them in a matrix, such that the i-th row of @var{y} contains the 27 ## return them in a matrix, such that the i-th row of @var{y} contains the
28 ## @var{p}(i)th percentiles of each column of @var{x}. 28 ## @var{p}(i)th percentiles of each column of @var{x}.
29 ## 29 ##
30 ## The optional argument @var{dim} determines the dimension along which 30 ## The optional argument @var{dim} determines the dimension along which
31 ## the percentiles are calculated. If @var{dim} is omitted, and @var{x} is 31 ## the percentiles are calculated. If @var{dim} is omitted, and @var{x} is
32 ## a vector or matrix, it defaults to 1 (column-wise quantiles). When 32 ## a vector or matrix, it defaults to 1 (column-wise quantiles). When
33 ## @var{x} is an N-d array, @var{dim} defaults to the first non-singleton 33 ## @var{x} is an N-d array, @var{dim} defaults to the first non-singleton
34 ## dimension. 34 ## dimension.
35 ## @seealso{quantile} 35 ## @seealso{quantile}
36 ## @end deftypefn 36 ## @end deftypefn
37 37
38 ## Author: Ben Abbott <bpabbott@mac.com> 38 ## Author: Ben Abbott <bpabbott@mac.com>
58 nd = ndims (x); 58 nd = ndims (x);
59 if (nargin == 2) 59 if (nargin == 2)
60 if (nd == 2) 60 if (nd == 2)
61 ## If a matrix or vector, use the 1st dimension. 61 ## If a matrix or vector, use the 1st dimension.
62 dim = 1; 62 dim = 1;
63 else 63 else
64 ## If an N-d array, find the first non-singleton dimension. 64 ## If an N-d array, find the first non-singleton dimension.
65 dim = find (size(v) > 1, 1); 65 dim = find (size(v) > 1, 1);
66 if (isempty (dim)) 66 if (isempty (dim))
67 dim = 1; 67 dim = 1;
68 endif 68 endif
69 endif 69 endif
70 else 70 else
71 if (!(isscalar (dim) && dim == fix (dim)) || 71 if (!(isscalar (dim) && dim == fix (dim)) ||
72 !(1 <= dim && dim <= nd)) 72 !(1 <= dim && dim <= nd))
73 error ("prctile: DIM must be an integer and a valid dimension"); 73 error ("prctile: DIM must be an integer and a valid dimension");
74 endif 74 endif
75 endif 75 endif
76 76