# HG changeset patch # User Rik # Date 1287687522 25200 # Node ID 9cb5c0b7b43b386718442c6dc7c639c48567d2c8 # Parent 64728cd28d7ac9d43af4d4c4922f292fdc8014d3 Fix reversed documentation for shape and scale parameters in Weibull family of functions. diff -r 64728cd28d7a -r 9cb5c0b7b43b scripts/ChangeLog --- 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 + + * 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 * io/strread.m: Improve compatibility with Matlab. diff -r 64728cd28d7a -r 9cb5c0b7b43b scripts/statistics/distributions/wblcdf.m --- 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 diff -r 64728cd28d7a -r 9cb5c0b7b43b scripts/statistics/distributions/wblinv.m --- 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)); diff -r 64728cd28d7a -r 9cb5c0b7b43b scripts/statistics/distributions/wblpdf.m --- 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 @@ -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)); diff -r 64728cd28d7a -r 9cb5c0b7b43b scripts/statistics/distributions/wblrnd.m --- 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