changeset 16935:a7b2fc7fe1a9

binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1. * scripts/statistics/distributions/binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
author Rik <rik@octave.org>
date Tue, 09 Jul 2013 14:39:39 -0700
parents 48f5b993b819
children 8f0a82add3da
files doc/interpreter/expr.txi scripts/deprecated/isequalwithequalnans.m scripts/deprecated/module.mk scripts/general/isequal.m scripts/general/isequaln.m scripts/general/isequalwithequalnans.m scripts/general/module.mk scripts/statistics/distributions/binocdf.m
diffstat 8 files changed, 110 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/expr.txi	Tue Jul 09 14:16:35 2013 -0700
+++ b/doc/interpreter/expr.txi	Tue Jul 09 14:39:39 2013 -0700
@@ -796,7 +796,7 @@
 
 @DOCSTRING(isequal)
 
-@DOCSTRING(isequalwithequalnans)
+@DOCSTRING(isequaln)
 
 @opindex <=
 @DOCSTRING(le)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/isequalwithequalnans.m	Tue Jul 09 14:39:39 2013 -0700
@@ -0,0 +1,50 @@
+## Copyright (C) 2005-2012 William Poetra Yoga Hadisoeseno
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} isequalwithequalnans (@var{x1}, @var{x2}, @dots{})
+## This function has been deprecated.  Use @code{@file{isequaln}} instead.
+## @seealso{isequaln}
+## @end deftypefn
+
+## Deprecated in 3.8
+
+function retval = isequalwithequalnans (varargin)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "isequalwithequalnans is obsolete and will be removed from a future version of Octave, please use isequaln instead");
+  endif
+
+  retval = isequaln (varargin{:});
+
+endfunction
+
+
+## test for equality
+%!assert (isequalwithequalnans ({1,2,NaN,4},{1,2,NaN,4}), true)
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,NaN,4]), true)
+## test for inequality
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,NaN,3,4]), false)
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,3,4]), false)
+## test for equality (struct)
+%!assert (isequalwithequalnans (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true)
+%!assert (isequalwithequalnans (1,2,1), false)
+
--- a/scripts/deprecated/module.mk	Tue Jul 09 14:16:35 2013 -0700
+++ b/scripts/deprecated/module.mk	Tue Jul 09 14:39:39 2013 -0700
@@ -9,6 +9,7 @@
   deprecated/java_debug.m \
   deprecated/error_text.m \
   deprecated/gen_doc_cache.m \
+  deprecated/isequalwithequalnans.m \
   deprecated/isstr.m \
   deprecated/java_convert_matrix.m \
   deprecated/java_get.m \
--- a/scripts/general/isequal.m	Tue Jul 09 14:16:35 2013 -0700
+++ b/scripts/general/isequal.m	Tue Jul 09 14:39:39 2013 -0700
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} isequal (@var{x1}, @var{x2}, @dots{})
 ## Return true if all of @var{x1}, @var{x2}, @dots{} are equal.
-## @seealso{isequalwithequalnans}
+## @seealso{isequaln}
 ## @end deftypefn
 
 function retval = isequal (x1, varargin)
@@ -74,3 +74,7 @@
 ## test for inequality (struct)
 %!assert (isequal (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), false)
 
+## Input validation
+%!error isequal ()
+%!error isequal (1)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/general/isequaln.m	Tue Jul 09 14:39:39 2013 -0700
@@ -0,0 +1,50 @@
+## Copyright (C) 2005-2012 William Poetra Yoga Hadisoeseno
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} isequaln (@var{x1}, @var{x2}, @dots{})
+## Return true if all of @var{x1}, @var{x2}, @dots{} are equal under the
+## additional assumption that NaN == NaN (no comparison of NaN placeholders
+## in dataset).
+## @seealso{isequal}
+## @end deftypefn
+
+function retval = isequaln (x1, varargin)
+
+  if (nargin < 2)
+    print_usage ();
+  endif
+
+  retval = __isequal__ (true, x1, varargin{:});
+
+endfunction
+
+
+## test for equality
+%!assert (isequaln ({1,2,NaN,4},{1,2,NaN,4}), true)
+%!assert (isequaln ([1,2,NaN,4],[1,2,NaN,4]), true)
+## test for inequality
+%!assert (isequaln ([1,2,NaN,4],[1,NaN,3,4]), false)
+%!assert (isequaln ([1,2,NaN,4],[1,2,3,4]), false)
+## test for equality (struct)
+%!assert (isequaln (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true)
+%!assert (isequaln (1,2,1), false)
+
+## Input validation
+%!error isequaln ()
+%!error isequaln (1)
--- a/scripts/general/isequalwithequalnans.m	Tue Jul 09 14:16:35 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-## Copyright (C) 2005-2012 William Poetra Yoga Hadisoeseno
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} isequalwithequalnans (@var{x1}, @var{x2}, @dots{})
-## Assuming NaN == NaN, return true if all of @var{x1}, @var{x2}, @dots{}
-## are equal.
-## @seealso{isequal}
-## @end deftypefn
-
-function retval = isequalwithequalnans (x1, varargin)
-
-  if (nargin < 2)
-    print_usage ();
-  endif
-
-  retval = __isequal__ (true, x1, varargin{:});
-
-endfunction
-
-
-## test for equality
-%!assert (isequalwithequalnans ({1,2,NaN,4},{1,2,NaN,4}), true)
-%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,NaN,4]), true)
-## test for inequality
-%!assert (isequalwithequalnans ([1,2,NaN,4],[1,NaN,3,4]), false)
-%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,3,4]), false)
-## test for equality (struct)
-%!assert (isequalwithequalnans (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true)
-%!assert (isequalwithequalnans (1,2,1), false)
-
--- a/scripts/general/module.mk	Tue Jul 09 14:16:35 2013 -0700
+++ b/scripts/general/module.mk	Tue Jul 09 14:39:39 2013 -0700
@@ -46,7 +46,7 @@
   general/iscolumn.m \
   general/isdir.m \
   general/isequal.m \
-  general/isequalwithequalnans.m \
+  general/isequaln.m \
   general/isrow.m \
   general/isscalar.m \
   general/issquare.m \
--- a/scripts/statistics/distributions/binocdf.m	Tue Jul 09 14:16:35 2013 -0700
+++ b/scripts/statistics/distributions/binocdf.m	Tue Jul 09 14:39:39 2013 -0700
@@ -60,9 +60,9 @@
   k = (x >= 0) & (x < n) & (n == fix (n)) & (p >= 0) & (p <= 1);
   tmp = floor (x(k));
   if (isscalar (n) && isscalar (p))
-    cdf(k) = 1 - betainc (p, tmp + 1, n - tmp);
+    cdf(k) = betainc (1 - p, n - tmp, tmp + 1);
   else
-    cdf(k) = 1 - betainc (p(k), tmp + 1, n(k) - tmp);
+    cdf(k) = betainc (1 .- p(k), n(k) - tmp, tmp + 1);
   endif
 
 endfunction