changeset 22754:c38eb3b08284

ppplot.m, qqplot.m: Add @seealso section. Add BIST tests for input validation.. * ppplot.m, qqplot.m: Add @seealso section. Add BIST tests for input validation..
author Rik <rik@octave.org>
date Sun, 13 Nov 2016 06:16:06 -0800
parents 50fa2d656326
children 3a2b891d0b33
files scripts/statistics/base/ppplot.m scripts/statistics/base/qqplot.m
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/statistics/base/ppplot.m	Sun Nov 13 06:07:14 2016 -0800
+++ b/scripts/statistics/base/ppplot.m	Sun Nov 13 06:16:06 2016 -0800
@@ -44,6 +44,7 @@
 ## calculates the CDF of distribution @var{dist} exists.
 ##
 ## If no output is requested then the data are plotted immediately.
+## @seealso{qqplot}
 ## @end deftypefn
 
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
@@ -64,9 +65,12 @@
   p = ((1 : n)' - 0.5) / n;
   if (nargin == 1)
     F = @stdnormal_cdf;
+  else if (! ischar (dist))
+    error ("ppplot: DIST must me a string");
   else
-    F = str2func (sprintf ("%scdf", dist));
+    F = str2func ([dist "cdf"]);
   endif;
+
   if (nargin <= 2)
     y = feval (F, s);
   else
@@ -84,4 +88,5 @@
 ## Test input validation
 %!error ppplot ()
 %!error ppplot (ones (2,2))
+%!error <DIST must be a string> ppplot (1, 2)
 
--- a/scripts/statistics/base/qqplot.m	Sun Nov 13 06:07:14 2016 -0800
+++ b/scripts/statistics/base/qqplot.m	Sun Nov 13 06:16:06 2016 -0800
@@ -51,6 +51,7 @@
 ## @var{dist}.
 ##
 ## If no output arguments are given, the data are plotted directly.
+## @seealso{ppplot}
 ## @end deftypefn
 
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
@@ -111,3 +112,10 @@
 
 endfunction
 
+
+## Test input validation
+%!error qqplot ()
+%!error <X must be a numeric> qqplot ({1})
+%!error <X must be a .* vector> qqplot (ones (2,2))
+%!error <no inverse CDF found> qqplot (1, "foobar")
+