diff scripts/statistics/distributions/wblpdf.m @ 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 a8ce6bdecce5
children 1740012184f9
line wrap: on
line diff
--- a/scripts/statistics/distributions/wblpdf.m
+++ b/scripts/statistics/distributions/wblpdf.m
@@ -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));