Mercurial > hg > octave-nkf
annotate scripts/statistics/base/cov.m @ 20818:9d2023d1a63c
binoinv.m: Implement binary search algorithm for 28X performance increase (bug #34363).
* binoinv.m: Call new functions scalar_binoinv or vector_binoinv to calculate
binoinv. If there are still uncalculated values then call bin_search_binoinv
to perform binary search for remaining values. Add more BIST tests.
* binoinv.m (scalar_binoinv): New subfunction to calculate binoinv for scalar x.
Stops when x > 1000.
* binoinv.m (vector_binoinv): New subfunction to calculate binoinv for scalar x.
Stops when x > 1000.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sun, 11 Oct 2015 19:49:40 -0700 |
parents | d9341b422488 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18206
diff
changeset
|
1 ## Copyright (C) 1995-2015 Kurt Hornik |
3426 | 2 ## |
3922 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
3426 | 9 ## |
3922 | 10 ## Octave is distributed in the hope that it will be useful, but |
3200 | 11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3426 | 13 ## General Public License for more details. |
14 ## | |
3200 | 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 |
17 ## <http://www.gnu.org/licenses/>. | |
3200 | 18 |
3367 | 19 ## -*- texinfo -*- |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
20 ## @deftypefn {Function File} {} cov (@var{x}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
21 ## @deftypefnx {Function File} {} cov (@var{x}, @var{opt}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
22 ## @deftypefnx {Function File} {} cov (@var{x}, @var{y}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
23 ## @deftypefnx {Function File} {} cov (@var{x}, @var{y}, @var{opt}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
24 ## Compute the covariance matrix. |
6754 | 25 ## |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
26 ## If each row of @var{x} and @var{y} is an observation, and each column is |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
27 ## a variable, then the @w{(@var{i}, @var{j})-th} entry of |
3367 | 28 ## @code{cov (@var{x}, @var{y})} is the covariance between the @var{i}-th |
6754 | 29 ## variable in @var{x} and the @var{j}-th variable in @var{y}. |
30 ## @tex | |
31 ## $$ | |
32 ## \sigma_{ij} = {1 \over N-1} \sum_{i=1}^N (x_i - \bar{x})(y_i - \bar{y}) | |
33 ## $$ | |
34 ## where $\bar{x}$ and $\bar{y}$ are the mean values of $x$ and $y$. | |
35 ## @end tex | |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
36 ## @ifnottex |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
37 ## |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
38 ## @example |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
39 ## cov (x) = 1/N-1 * SUM_i (x(i) - mean(x)) * (y(i) - mean(y)) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
40 ## @end example |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
41 ## |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
42 ## @end ifnottex |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
43 ## |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
44 ## If called with one argument, compute @code{cov (@var{x}, @var{x})}, the |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
45 ## covariance between the columns of @var{x}. |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
46 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
47 ## The argument @var{opt} determines the type of normalization to use. |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
48 ## Valid values are |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
49 ## |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
50 ## @table @asis |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
51 ## @item 0: |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
52 ## normalize with @math{N-1}, provides the best unbiased estimator of the |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
53 ## covariance [default] |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
54 ## |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
55 ## @item 1: |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
56 ## normalize with @math{N}, this provides the second moment around the mean |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
57 ## @end table |
18206
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 ## |
20384
d9341b422488
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
59 ## Compatibility Note:: Octave always computes the covariance matrix. |
18206
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
60 ## For two inputs, however, @sc{matlab} will calculate |
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 ## @code{cov (@var{x}(:), @var{y}(:))} whenever the number of elements in |
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 ## @var{x} and @var{y} are equal. This will result in a scalar rather than |
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
63 ## a matrix output. Code relying on this odd definition will need to be |
48dafd739840
cov.m: Document intentional Matlab incompatibility (bug #40751).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 ## changed when running in Octave. |
12856
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
65 ## @seealso{corr} |
3367 | 66 ## @end deftypefn |
3200 | 67 |
5428 | 68 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
3456 | 69 ## Description: Compute covariances |
3200 | 70 |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
71 function c = cov (x, y = [], opt = 0) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
72 |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
73 if (nargin < 1 || nargin > 3) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
74 print_usage (); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
75 endif |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
76 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
77 if ( ! (isnumeric (x) || islogical (x)) |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
78 || ! (isnumeric (y) || islogical (y))) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
79 error ("cov: X and Y must be numeric matrices or vectors"); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
80 endif |
3200 | 81 |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
82 if (ndims (x) != 2 || ndims (y) != 2) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
83 error ("cov: X and Y must be 2-D matrices or vectors"); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
84 endif |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
85 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
86 if (nargin == 2 && isscalar (y)) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
87 opt = y; |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
88 endif |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
89 |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
90 if (opt != 0 && opt != 1) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
91 error ("cov: normalization OPT must be 0 or 1"); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
92 endif |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
93 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
94 ## Special case, scalar has zero covariance |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
95 if (isscalar (x)) |
14336
34af9f9ff98b
Use Octave coding conventions (double-quote " in preference to single quote ')
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
96 if (isa (x, "single")) |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
97 c = single (0); |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
98 else |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
99 c = 0; |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
100 endif |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
101 return; |
3200 | 102 endif |
103 | |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
104 if (isrow (x)) |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
105 x = x.'; |
3200 | 106 endif |
107 n = rows (x); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
108 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
109 if (nargin == 1 || isscalar (y)) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
110 x = center (x, 1); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
111 c = conj (x' * x / (n - 1 + opt)); |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
112 else |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
113 if (isrow (y)) |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
114 y = y.'; |
3200 | 115 endif |
116 if (rows (y) != n) | |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
117 error ("cov: X and Y must have the same number of observations"); |
3200 | 118 endif |
8977
f464119ec165
further simplify some stats funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
119 x = center (x, 1); |
f464119ec165
further simplify some stats funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
120 y = center (y, 1); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
121 c = conj (x' * y / (n - 1 + opt)); |
3200 | 122 endif |
123 | |
124 endfunction | |
7411 | 125 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
126 |
7411 | 127 %!test |
128 %! x = rand (10); | |
129 %! cx1 = cov (x); | |
130 %! cx2 = cov (x, x); | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
131 %! assert (size (cx1) == [10, 10] && size (cx2) == [10, 10]); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
132 %! assert (cx1, cx2, 1e1*eps); |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
133 |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
134 %!test |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
135 %! x = [1:3]'; |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
136 %! y = [3:-1:1]'; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
137 %! assert (cov (x, y), -1, 5*eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
138 %! assert (cov (x, flipud (y)), 1, 5*eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
139 %! assert (cov ([x, y]), [1 -1; -1 1], 5*eps); |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
140 |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
141 %!test |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
142 %! x = single ([1:3]'); |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
143 %! y = single ([3:-1:1]'); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
144 %! assert (cov (x, y), single (-1), 5*eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
145 %! assert (cov (x, flipud (y)), single (1), 5*eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
146 %! assert (cov ([x, y]), single ([1 -1; -1 1]), 5*eps); |
7411 | 147 |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
148 %!test |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
149 %! x = [1:5]; |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
150 %! c = cov (x); |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
151 %! assert (isscalar (c)); |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
152 %! assert (c, 2.5); |
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
153 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
154 %!assert (cov (5), 0) |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
155 %!assert (cov (single (5)), single (0)) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
156 |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
157 %!test |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
158 %! x = [1:5]; |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
159 %! c = cov (x, 0); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
160 %! assert (c, 2.5); |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
161 %! c = cov (x, 1); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
162 %! assert (c, 2); |
7411 | 163 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
164 ## Test input validation |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
165 %!error cov () |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
166 %!error cov (1, 2, 3, 4) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
167 %!error cov ([1; 2], ["A", "B"]) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
168 %!error cov (ones (2,2,2)) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
169 %!error cov (ones (2,2), ones (2,2,2)) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
170 %!error cov (1, 3) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14336
diff
changeset
|
171 %!error cov (ones (2,2), ones (3,2)) |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
172 |