Mercurial > hg > octave-nkf
comparison scripts/statistics/base/range.m @ 11436:e151e23f73bc
Overhaul base statistics functions and documentation of same.
Add or improve input validation.
Add input validation tests.
Add functional tests.
Improve or re-write documentation strings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 03 Jan 2011 21:23:08 -0800 |
parents | be55736a0783 |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
11435:20f53b3a558f | 11436:e151e23f73bc |
---|---|
19 ## <http://www.gnu.org/licenses/>. | 19 ## <http://www.gnu.org/licenses/>. |
20 | 20 |
21 ## -*- texinfo -*- | 21 ## -*- texinfo -*- |
22 ## @deftypefn {Function File} {} range (@var{x}) | 22 ## @deftypefn {Function File} {} range (@var{x}) |
23 ## @deftypefnx {Function File} {} range (@var{x}, @var{dim}) | 23 ## @deftypefnx {Function File} {} range (@var{x}, @var{dim}) |
24 ## If @var{x} is a vector, return the range, i.e., the difference | 24 ## Return the range, i.e., the difference between the maximum and the minimum |
25 ## between the maximum and the minimum, of the input data. | 25 ## of the input data. If @var{x} is a vector, the range is calculated over |
26 ## the elements of @var{x}. If @var{x} is a matrix, the range is calculated | |
27 ## over each column of @var{x}. | |
26 ## | 28 ## |
27 ## If @var{x} is a matrix, do the above for each column of @var{x}. | 29 ## If the optional argument @var{dim} is given, operate along this dimension. |
28 ## | 30 ## |
29 ## If the optional argument @var{dim} is supplied, work along dimension | 31 ## The range is a quickly computed measure of the dispersion of a data set, but |
30 ## @var{dim}. | 32 ## is less accurate than @code{iqr} if there are outlying data points. |
33 ## @seealso{iqr, std} | |
31 ## @end deftypefn | 34 ## @end deftypefn |
32 | 35 |
33 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> | 36 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
34 ## Description: Compute range | 37 ## Description: Compute range |
35 | 38 |
42 else | 45 else |
43 print_usage (); | 46 print_usage (); |
44 endif | 47 endif |
45 | 48 |
46 endfunction | 49 endfunction |
50 | |
51 %!assert(range (1:10), 9) | |
52 %!assert(range (magic (3)), [5, 8, 5]) | |
53 %!assert(range (magic (3), 2), [7; 4; 7]) | |
54 %!assert(range (2), 0) | |
55 | |
56 %% Test input validation | |
57 %!error range () | |
58 %!error range (1, 2, 3) |