changeset 11128:9cb5c0b7b43b

Fix reversed documentation for shape and scale parameters in Weibull family of functions.
author Rik <octave@nomad.inbox5.com>
date Thu, 21 Oct 2010 11:58:42 -0700
parents 64728cd28d7a
children 0de5cc44e690
files scripts/ChangeLog scripts/statistics/distributions/wblcdf.m scripts/statistics/distributions/wblinv.m scripts/statistics/distributions/wblpdf.m scripts/statistics/distributions/wblrnd.m
diffstat 5 files changed, 32 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Oct 21 23:38:15 2010 +0800
+++ b/scripts/ChangeLog	Thu Oct 21 11:58:42 2010 -0700
@@ -1,3 +1,9 @@
+2010-10-21  Rik  <octave@nomad.inbox5.com>
+
+	* statistics/distributions/wblcdf.m, statistics/distributions/wblinv.m,
+	  statistics/distributions/wblpdf.m, statistics/distributions/wblrnd.m:
+	  Fix reversed documentation for shape and scale parameters.
+
 2010-10-21  Ben Abbott <bpabbott@mac.com>
 
 	* io/strread.m: Improve compatibility with Matlab.
--- a/scripts/statistics/distributions/wblcdf.m	Thu Oct 21 23:38:15 2010 +0800
+++ b/scripts/statistics/distributions/wblcdf.m	Thu Oct 21 11:58:42 2010 -0700
@@ -19,16 +19,16 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} wblcdf (@var{x}, @var{scale}, @var{shape})
 ## Compute the cumulative distribution function (CDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
+## Weibull distribution with scale parameter @var{scale} and shape
 ## parameter @var{shape}, which is
 ## @tex
-## $$ 1 - \exp(-(x/shape)^{scale}) $$
-## for $x\geq 0$.
+## $$ 1 - e^{-({x \over scale})^{shape}} $$
+## for $x \geq 0$.
 ## @end tex
 ## @ifnottex
 ##
 ## @example
-## 1 - exp(-(x/shape)^scale)
+## 1 - exp(-(x/scale)^shape)
 ## @end example
 ##
 ## @noindent
--- a/scripts/statistics/distributions/wblinv.m	Thu Oct 21 23:38:15 2010 +0800
+++ b/scripts/statistics/distributions/wblinv.m	Thu Oct 21 11:58:42 2010 -0700
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} wblinv (@var{x}, @var{scale}, @var{shape})
 ## Compute the quantile (the inverse of the CDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
+## Weibull distribution with scale parameter @var{scale} and shape
 ## parameter @var{shape}.
 ## @end deftypefn
 
@@ -40,8 +40,8 @@
     scale = 1;
   endif
 
-  if (!isscalar (shape) || !isscalar (scale))
-    [retval, x, shape, scale] = common_size (x, shape, scale);
+  if (!isscalar (scale) || !isscalar (shape))
+    [retval, x, scale, shape] = common_size (x, scale, shape);
     if (retval > 0)
       error ("wblinv: x, scale and shape must be of common size or scalar");
     endif
@@ -49,7 +49,7 @@
 
   inv = NaN (size (x));
 
-  ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf));
+  ok = ((scale > 0) & (scale < Inf) & (shape > 0) & (shape < Inf));
 
   k = find ((x == 0) & ok);
   if (any (k))
@@ -58,7 +58,7 @@
 
   k = find ((x > 0) & (x < 1) & ok);
   if (any (k))
-    if (isscalar (shape) && isscalar (scale))
+    if (isscalar (scale) && isscalar (shape))
       inv(k) = scale * (- log (1 - x(k))) .^ (1 / shape);
     else
       inv(k) = scale(k) .* (- log (1 - x(k))) .^ (1 ./ shape(k));
--- a/scripts/statistics/distributions/wblpdf.m	Thu Oct 21 23:38:15 2010 +0800
+++ b/scripts/statistics/distributions/wblpdf.m	Thu Oct 21 11:58:42 2010 -0700
@@ -19,20 +19,20 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} wblpdf (@var{x}, @var{scale}, @var{shape})
 ## Compute the probability density function (PDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
+## Weibull distribution with scale parameter @var{scale} and shape
 ## parameter @var{shape} which is given by
 ## @tex
-## $$  scale \cdot shape^{-scale} x^{scale-1} \exp(-(x/shape)^{scale}) $$
+## $$  {shape \over scale^{shape}} \cdot x^{shape-1} \cdot e^{-({x \over scale})^{shape}} $$
 ## @end tex
 ## @ifnottex
 ##
 ## @example
-##    scale * shape^(-scale) * x^(scale-1) * exp(-(x/shape)^scale)
+##    shape * scale^(-shape) * x^(shape-1) * exp(-(x/scale)^shape)
 ## @end example
 ##
 ## @end ifnottex
 ## @noindent
-## for @var{x} > 0.
+## for @var{x} >= 0.
 ## @end deftypefn
 
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
@@ -52,15 +52,15 @@
     scale = 1;
   endif
 
-  if (!isscalar (shape) || !isscalar (scale))
-    [retval, x, shape, scale] = common_size (x, shape, scale);
+  if (!isscalar (scale) || !isscalar (shape))
+    [retval, x, scale, shape] = common_size (x, scale, shape);
     if (retval > 0)
       error ("wblpdf: x, scale and shape must be of common size or scalar");
     endif
   endif
 
   pdf = NaN (size (x));
-  ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf));
+  ok = ((scale > 0) & (scale < Inf) & (shape > 0) & (shape < Inf));
 
   k = find ((x > -Inf) & (x <= 0) & ok);
   if (any (k))
@@ -69,7 +69,7 @@
 
   k = find ((x > 0) & (x < Inf) & ok);
   if (any (k))
-    if (isscalar (shape) && isscalar (scale))
+    if (isscalar (scale) && isscalar (shape))
       pdf(k) = (shape .* (scale .^ -shape)
                 .* (x(k) .^ (shape - 1))
                 .* exp(- (x(k) / scale) .^ shape));
--- a/scripts/statistics/distributions/wblrnd.m	Thu Oct 21 23:38:15 2010 +0800
+++ b/scripts/statistics/distributions/wblrnd.m	Thu Oct 21 11:58:42 2010 -0700
@@ -34,10 +34,10 @@
 function rnd = wblrnd (scale, shape, r, c)
 
   if (nargin > 1)
-    if (!isscalar(shape) || !isscalar(scale)) 
-      [retval, shape, scale] = common_size (shape, scale);
+    if (!isscalar(scale) || !isscalar(shape)) 
+      [retval, scale, shape] = common_size (scale, shape);
       if (retval > 0)
-        error ("wblrnd: shape and scale must be of common size or scalar");
+        error ("wblrnd: scale and shape must be of common size or scalar");
       endif
     endif
   endif
@@ -54,7 +54,7 @@
     if (any (size (scale) != 1) && 
         ((length (size (scale)) != length (sz))
          || any (size (scale) != sz)))
-      error ("wblrnd: shape and scale must be scalar or of size [r, c]");
+      error ("wblrnd: scale and shape must be scalar or of size [r, c]");
     endif
   elseif (nargin == 3)
     if (isscalar (r) && (r > 0))
@@ -68,23 +68,23 @@
     if (any (size (scale) != 1) && 
         ((length (size (scale)) != length (sz))
          || any (size (scale) != sz)))
-      error ("wblrnd: shape and scale must be scalar or of size sz");
+      error ("wblrnd: scale and shape must be scalar or of size sz");
     endif
   elseif (nargin == 2)
-    sz = size(shape);
+    sz = size(scale);
   else
     print_usage ();
   endif
 
-  if (isscalar (shape) && isscalar (scale))
-    if (shape > 0 && shape < Inf && scale > 0 && scale < Inf)
+  if (isscalar (scale) && isscalar (shape))
+    if (scale > 0 && scale < Inf && shape > 0 && shape < Inf)
       rnd = scale .* rande(sz) .^ (1./shape);
     else
       rnd = NaN (sz);
     endif
   else
     rnd = scale .* rande(sz) .^ (1./shape);
-    k = find ((shape <= 0) | (shape == Inf) | ((scale <= 0) & (scale == Inf)));
+    k = find ((scale <= 0) | (scale == Inf) | ((shape <= 0) & (shape == Inf)));
     if (any(k))
       rnd(k) = NaN;
     endif