Mercurial > hg > octave-lyh
annotate scripts/deprecated/cor.m @ 17398:4bcd301754ce
Add Matlab-compatible flintmax function
* bitfcns.cc (Fflintmax): New function based on bitmax.
(Fbitmax, Fintmax, Fintmin): Update seealso to refer to flintmax.
* numbers.txi: Include flintmax docstring.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sun, 08 Sep 2013 17:28:05 -0400 |
parents | 72c96de7a403 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12856
diff
changeset
|
1 ## Copyright (C) 1995-2012 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 |
3453 | 19 ## -*- texinfo -*- |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
20 ## @deftypefn {Function File} {} cor (@var{x}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
21 ## @deftypefnx {Function File} {} cor (@var{x}, @var{y}) |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
22 ## Compute matrix of correlation coefficients. |
3200 | 23 ## |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
24 ## This is an alias for @code{corrcoef}. |
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
25 ## @seealso{corrcoef} |
3453 | 26 ## @end deftypefn |
3200 | 27 |
12555
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
28 function retval = cor (x, y = x) |
3200 | 29 |
12856
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
30 persistent warned = false; |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
31 if (! warned) |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
32 warned = true; |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
33 warning ("Octave:deprecated-function", |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
34 "cor is obsolete and will be removed from a future version of Octave; please use corr instead"); |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
35 endif |
cad4cba03f19
Deprecate corrcoef, cor and replace with Matlab equivalent corr
Rik <octave@nomad.inbox5.com>
parents:
12656
diff
changeset
|
36 |
3200 | 37 if (nargin < 1 || nargin > 2) |
6046 | 38 print_usage (); |
3200 | 39 endif |
40 | |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
41 retval = corrcoef (x, y); |
3200 | 42 |
43 endfunction | |
11436
e151e23f73bc
Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
44 |
12656
6b2f14af2360
Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents:
12557
diff
changeset
|
45 |
12555
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 %!test |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 %! x = rand (10, 2); |
12557
4715ce9f911d
cor.m: Increase tolerance of %!tests using random data to assure passage.
Rik <octave@nomad.inbox5.com>
parents:
12555
diff
changeset
|
48 %! assert (cor (x), corrcoef (x), 5*eps); |
12555
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
49 %! assert (cor (x(:,1), x(:,2)) == corrcoef (x(:,1), x(:,2))); |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
51 %% Test input validation |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
52 %!error corrcoef (); |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
53 %!error corrcoef (1, 2, 3); |
422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
54 |