Mercurial > octave
annotate scripts/statistics/mode.m @ 26376:00f796120a6d stable
maint: Update copyright dates in all source files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Jan 2019 16:32:43 -0500 |
parents | 6652d3823428 |
children | b442ec6dda5c |
rev | line source |
---|---|
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
1 ## Copyright (C) 2007-2019 David Bateman |
6863 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
5 ## Octave is free software: you can redistribute it and/or modify it |
6863 | 6 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
7 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
8 ## (at your option) any later version. |
6863 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## GNU General Public License for more details. |
6863 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
17 ## <https://www.gnu.org/licenses/>. |
6863 | 18 |
19 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
20 ## @deftypefn {} {} mode (@var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
21 ## @deftypefnx {} {} mode (@var{x}, @var{dim}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
22 ## @deftypefnx {} {[@var{m}, @var{f}, @var{c}] =} mode (@dots{}) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
23 ## Compute the most frequently occurring value in a dataset (mode). |
20174
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
24 ## |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10669
diff
changeset
|
25 ## @code{mode} determines the frequency of values along the first non-singleton |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
26 ## dimension and returns the value with the highest frequency. If two, or |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10669
diff
changeset
|
27 ## more, values have the same frequency @code{mode} returns the smallest. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
28 ## |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
29 ## If the optional argument @var{dim} is given, operate along this dimension. |
6863 | 30 ## |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10669
diff
changeset
|
31 ## The return variable @var{f} is the number of occurrences of the mode in |
20174
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
32 ## the dataset. |
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## |
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
34 ## The cell array @var{c} contains all of the elements with the maximum |
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
35 ## frequency. |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
36 ## @seealso{mean, median} |
6863 | 37 ## @end deftypefn |
38 | |
39 function [m, f, c] = mode (x, dim) | |
40 | |
41 if (nargin < 1 || nargin > 2) | |
42 print_usage (); | |
43 endif | |
44 | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
45 if (! (isnumeric (x) || islogical (x))) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
46 error ("mode: X must be a numeric vector or matrix"); |
10669
cab3b148d4e4
Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
47 endif |
cab3b148d4e4
Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
48 |
6863 | 49 nd = ndims (x); |
50 sz = size (x); | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
51 if (nargin < 2) |
6863 | 52 ## Find the first non-singleton dimension. |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
53 (dim = find (sz > 1, 1)) || (dim = 1); |
6863 | 54 else |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
55 if (! (isscalar (dim) && dim == fix (dim) && dim > 0)) |
10669
cab3b148d4e4
Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
56 error ("mode: DIM must be an integer and a valid dimension"); |
6863 | 57 endif |
58 endif | |
59 | |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
60 if (dim > nd) |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21364
diff
changeset
|
61 ## Special case of mode over non-existent dimension. |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
62 m = x; |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
63 f = ones (size (x)); |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21364
diff
changeset
|
64 c = num2cell (x); |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
65 return; |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
66 endif |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
67 |
6863 | 68 sz2 = sz; |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
69 sz2(dim) = 1; |
6863 | 70 sz3 = ones (1, nd); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
71 sz3(dim) = sz(dim); |
6863 | 72 |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
73 if (issparse (x)) |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
74 t2 = sparse (sz(1), sz(2)); |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
75 else |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
76 t2 = zeros (sz); |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
77 endif |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
78 |
6863 | 79 if (dim != 1) |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
80 perm = [dim, 1:dim-1, dim+1:nd]; |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
81 t2 = permute (t2, perm); |
6863 | 82 endif |
83 | |
84 xs = sort (x, dim); | |
85 t = cat (dim, true (sz2), diff (xs, 1, dim) != 0); | |
86 | |
87 if (dim != 1) | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
88 t2(permute (t != 0, perm)) = diff ([find(permute (t, perm))(:); prod(sz)+1]); |
6863 | 89 f = max (ipermute (t2, perm), [], dim); |
90 xs = permute (xs, perm); | |
91 else | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
92 t2(t) = diff ([find(t)(:); prod(sz)+1]); |
6863 | 93 f = max (t2, [], dim); |
94 endif | |
95 | |
96 c = cell (sz2); | |
7287 | 97 if (issparse (x)) |
98 m = sparse (sz2(1), sz2(2)); | |
99 else | |
12585
4e32a1bb9096
mode.m, quantile.m: Return output of same class as input.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
100 m = zeros (sz2, class (x)); |
7287 | 101 endif |
6863 | 102 for i = 1 : prod (sz2) |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
103 c{i} = xs(t2(:, i) == f(i), i); |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
104 m(i) = c{i}(1); |
6863 | 105 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21604
diff
changeset
|
106 |
6863 | 107 endfunction |
108 | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12585
diff
changeset
|
109 |
6863 | 110 %!test |
111 %! [m, f, c] = mode (toeplitz (1:5)); | |
112 %! assert (m, [1,2,2,2,1]); | |
113 %! assert (f, [1,2,2,2,1]); | |
114 %! assert (c, {[1;2;3;4;5],[2],[2;3],[2],[1;2;3;4;5]}); | |
115 %!test | |
116 %! [m, f, c] = mode (toeplitz (1:5), 2); | |
117 %! assert (m, [1;2;2;2;1]); | |
118 %! assert (f, [1;2;2;2;1]); | |
119 %! assert (c, {[1;2;3;4;5];[2];[2;3];[2];[1;2;3;4;5]}); | |
120 %!test | |
121 %! a = sprandn (32, 32, 0.05); | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20174
diff
changeset
|
122 %! sp0 = sparse (0); |
6863 | 123 %! [m, f, c] = mode (a); |
124 %! [m2, f2, c2] = mode (full (a)); | |
7287 | 125 %! assert (m, sparse (m2)); |
126 %! assert (f, sparse (f2)); | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20174
diff
changeset
|
127 %! c_exp(1:length (a)) = { sp0 }; |
12930
7bd29d875af1
mode.m: Eliminate cellfun usage in assert tests
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
128 %! assert (c ,c_exp); |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
129 %! assert (c2,c_exp); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
130 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
131 %!assert (mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4]) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
132 %!assert (mode ([2,3,1,2,3,4],2),2) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
133 %!assert (mode ([2,3,1,2,3,4]),2) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
134 %!assert (mode (single ([2,3,1,2,3,4])), single (2)) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
135 %!assert (mode (int8 ([2,3,1,2,3,4])), int8 (2)) |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
136 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
137 %!assert (mode ([2;3;1;2;3;4],1),2) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
138 %!assert (mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4]) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
139 %!assert (mode ([2;3;1;2;3;4]),2) |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
140 |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
141 %!test |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
142 %! x = magic (3); |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
143 %! [m, f, c] = mode (x, 3); |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
144 %! assert (m, x); |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
145 %! assert (f, ones (3,3)); |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
146 %! assert (c, num2cell (x)); |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
147 |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
148 %!shared x |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
149 %! x(:,:,1) = toeplitz (1:3); |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
150 %! x(:,:,2) = circshift (toeplitz (1:3), 1); |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
151 %! x(:,:,3) = circshift (toeplitz (1:3), 2); |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
152 %!test |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
153 %! [m, f, c] = mode (x, 1); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
154 %! assert (reshape (m, [3, 3]), [1 1 1; 2 2 2; 1 1 1]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
155 %! assert (reshape (f, [3, 3]), [1 1 1; 2 2 2; 1 1 1]); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
156 %! c = reshape (c, [3, 3]); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
157 %! assert (c{1}, [1; 2; 3]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
158 %! assert (c{2}, 2); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
159 %! assert (c{3}, [1; 2; 3]); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
160 %!test |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
161 %! [m, f, c] = mode (x, 2); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
162 %! assert (reshape (m, [3, 3]), [1 1 2; 2 1 1; 1 2 1]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
163 %! assert (reshape (f, [3, 3]), [1 1 2; 2 1 1; 1 2 1]); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
164 %! c = reshape (c, [3, 3]); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
165 %! assert (c{1}, [1; 2; 3]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
166 %! assert (c{2}, 2); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
167 %! assert (c{3}, [1; 2; 3]); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
168 %!test |
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
169 %! [m, f, c] = mode (x, 3); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
170 %! assert (reshape (m, [3, 3]), [1 2 1; 1 2 1; 1 2 1]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
171 %! assert (reshape (f, [3, 3]), [1 2 1; 1 2 1; 1 2 1]); |
7606
704b7a1098d0
Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
172 %! c = reshape (c, [3, 3]); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
173 %! assert (c{1}, [1; 2; 3]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
174 %! assert (c{2}, [1; 2; 3]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
175 %! assert (c{3}, [1; 2; 3]); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
176 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
177 ## Test input validation |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
178 %!error mode () |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
11191
diff
changeset
|
179 %!error mode (1, 2, 3) |
21364
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
180 %!error <X must be a numeric> mode ({1 2 3}) |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
181 %!error <DIM must be an integer> mode (1, ones (2,2)) |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
182 %!error <DIM must be an integer> mode (1, 1.5) |
03ff9371596b
mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
183 %!error <DIM must be .* a valid dimension> mode (1, 0) |