# HG changeset patch # User David Bateman # Date 1271406727 -7200 # Node ID 3306cfcb856e3824b7bdb9e87e8b9719ade07f7d # Parent 1c6ff93c025a16a972dae03c9b6efea0535417a8 Replace constructs like "NaN * one()" with "NaN()" and "Inf * ones ()" with "Inf()" diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,8 +1,13 @@ -2010-04-13 David Bateman - - * statistics/discrete_pdf.m: Reimplement using lookup. - * statistics/discrete_inv.m: Reimplement using lookup. - * statistics/discrete_cdf.m: typo in last patch. +2010-04-16 David Bateman + + * statistics/distributions/*: Replace constructs like "NaN * one()" + with "NaN()" and "Inf * ones ()" with "Inf()". + +2010-04-15 David Bateman + + * statistics/distributions/discrete_pdf.m: Reimplement using lookup. + * statistics/distributions/discrete_inv.m: Reimplement using lookup. + * statistics/distributions/discrete_cdf.m: typo in last patch. 2010-04-15 Jaroslav Hajek diff --git a/scripts/statistics/distributions/betarnd.m b/scripts/statistics/distributions/betarnd.m --- a/scripts/statistics/distributions/betarnd.m +++ b/scripts/statistics/distributions/betarnd.m @@ -76,7 +76,7 @@ if (isscalar(a) && isscalar(b)) if (find (!(a > 0) | !(a < Inf) | !(b > 0) | !(b < Inf))) - rnd = NaN * ones (sz); + rnd = NaN (sz); else r1 = randg(a,sz); rnd = r1 ./ (r1 + randg(b,sz)); @@ -86,7 +86,7 @@ k = find (!(a > 0) | !(a < Inf) | !(b > 0) | !(b < Inf)); if (any (k)) - rnd(k) = NaN * ones (size (k)); + rnd(k) = NaN (size (k)); endif k = find ((a > 0) & (a < Inf) & (b > 0) & (b < Inf)); diff --git a/scripts/statistics/distributions/binornd.m b/scripts/statistics/distributions/binornd.m --- a/scripts/statistics/distributions/binornd.m +++ b/scripts/statistics/distributions/binornd.m @@ -77,7 +77,7 @@ if (isscalar (n) && isscalar (p)) if (find (!(n >= 0) | !(n < Inf) | !(n == round (n)) | !(p >= 0) | !(p <= 1))) - rnd = NaN * ones (sz); + rnd = NaN (sz); elseif (n == 0) rnd = zeros (sz); else diff --git a/scripts/statistics/distributions/cauchy_cdf.m b/scripts/statistics/distributions/cauchy_cdf.m --- a/scripts/statistics/distributions/cauchy_cdf.m +++ b/scripts/statistics/distributions/cauchy_cdf.m @@ -47,7 +47,7 @@ endif sz = size (x); - cdf = NaN * ones (sz); + cdf = NaN (sz); k = find ((x > -Inf) & (x < Inf) & (location > -Inf) & (location < Inf) & (scale > 0) & (scale < Inf)); diff --git a/scripts/statistics/distributions/cauchy_inv.m b/scripts/statistics/distributions/cauchy_inv.m --- a/scripts/statistics/distributions/cauchy_inv.m +++ b/scripts/statistics/distributions/cauchy_inv.m @@ -47,7 +47,7 @@ endif sz = size (x); - inv = NaN * ones (sz); + inv = NaN (sz); ok = ((location > -Inf) & (location < Inf) & (scale > 0) & (scale < Inf)); diff --git a/scripts/statistics/distributions/cauchy_pdf.m b/scripts/statistics/distributions/cauchy_pdf.m --- a/scripts/statistics/distributions/cauchy_pdf.m +++ b/scripts/statistics/distributions/cauchy_pdf.m @@ -47,7 +47,7 @@ endif sz = size (x); - pdf = NaN * ones (sz); + pdf = NaN (sz); k = find ((x > -Inf) & (x < Inf) & (location > -Inf) & (location < Inf) & (scale > 0) & (scale < Inf)); diff --git a/scripts/statistics/distributions/cauchy_rnd.m b/scripts/statistics/distributions/cauchy_rnd.m --- a/scripts/statistics/distributions/cauchy_rnd.m +++ b/scripts/statistics/distributions/cauchy_rnd.m @@ -76,12 +76,12 @@ if (isscalar (l) && isscalar (scale)) if (find (!(l > -Inf) | !(l < Inf) | !(scale > 0) | !(scale < Inf))) - rnd = NaN * ones (sz); + rnd = NaN (sz); else rnd = l - cot (pi * rand (sz)) .* scale; endif else - rnd = NaN * ones (sz); + rnd = NaN (sz); k = find ((l > -Inf) & (l < Inf) & (scale > 0) & (scale < Inf)); if (any (k)) rnd(k) = l(k)(:) - cot (pi * rand (size (k))) .* scale(k)(:); diff --git a/scripts/statistics/distributions/chi2rnd.m b/scripts/statistics/distributions/chi2rnd.m --- a/scripts/statistics/distributions/chi2rnd.m +++ b/scripts/statistics/distributions/chi2rnd.m @@ -66,7 +66,7 @@ if (isscalar (n)) if (find (!(n > 0) | !(n < Inf))) - rnd = NaN * ones (sz); + rnd = NaN (sz); else rnd = 2 * randg(n/2, sz); endif diff --git a/scripts/statistics/distributions/exprnd.m b/scripts/statistics/distributions/exprnd.m --- a/scripts/statistics/distributions/exprnd.m +++ b/scripts/statistics/distributions/exprnd.m @@ -70,7 +70,7 @@ if ((l > 0) && (l < Inf)) rnd = rande(sz) * l; else - rnd = NaN * ones (sz); + rnd = NaN (sz); endif else rnd = zeros (sz); diff --git a/scripts/statistics/distributions/frnd.m b/scripts/statistics/distributions/frnd.m --- a/scripts/statistics/distributions/frnd.m +++ b/scripts/statistics/distributions/frnd.m @@ -90,7 +90,7 @@ elseif ((m > 0) && (m < Inf) && (n > 0) && (n < Inf)) rnd = n ./ m .* randg (m / 2, sz) ./ randg (n / 2, sz); else - rnd = NaN * ones (sz); + rnd = NaN (sz); endif else rnd = zeros (sz); diff --git a/scripts/statistics/distributions/gamrnd.m b/scripts/statistics/distributions/gamrnd.m --- a/scripts/statistics/distributions/gamrnd.m +++ b/scripts/statistics/distributions/gamrnd.m @@ -79,7 +79,7 @@ if (isscalar (a) && isscalar(b)) if (find (!(a > 0) | !(a < Inf) | !(b > 0) | !(b < Inf))) - rnd = NaN * ones (sz); + rnd = NaN (sz); else rnd = b .* randg(a, sz); endif diff --git a/scripts/statistics/distributions/geornd.m b/scripts/statistics/distributions/geornd.m --- a/scripts/statistics/distributions/geornd.m +++ b/scripts/statistics/distributions/geornd.m @@ -68,9 +68,9 @@ if (isscalar (p)) if (!(p >= 0) || !(p <= 1)) - rnd = NaN * ones (sz); + rnd = NaN (sz); elseif (p == 0) - rnd = Inf * ones (sz); + rnd = Inf (sz); elseif ((p > 0) & (p < 1)); rnd = floor (- rande(sz) ./ log (1 - p)); else @@ -81,12 +81,12 @@ k = find (!(p >= 0) | !(p <= 1)); if (any (k)) - rnd(k) = NaN * ones (1, length (k)); + rnd(k) = NaN (1, length (k)); endif k = find (p == 0); if (any (k)) - rnd(k) = Inf * ones (1, length (k)); + rnd(k) = Inf (1, length (k)); endif endif diff --git a/scripts/statistics/distributions/hygecdf.m b/scripts/statistics/distributions/hygecdf.m --- a/scripts/statistics/distributions/hygecdf.m +++ b/scripts/statistics/distributions/hygecdf.m @@ -44,7 +44,7 @@ if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) - cdf = NaN * ones (size (x)) + cdf = NaN (size (x)) else cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, t, m, n)); endif diff --git a/scripts/statistics/distributions/hygeinv.m b/scripts/statistics/distributions/hygeinv.m --- a/scripts/statistics/distributions/hygeinv.m +++ b/scripts/statistics/distributions/hygeinv.m @@ -41,7 +41,7 @@ if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) | (m != round (m)) | (n != round (n)) | (m > t) | (n > t)) - inv = NaN * ones (size (x)) + inv = NaN (size (x)) else inv = discrete_inv (x, 0 : n, hygepdf (0 : n, t, m, n)); endif diff --git a/scripts/statistics/distributions/hygepdf.m b/scripts/statistics/distributions/hygepdf.m --- a/scripts/statistics/distributions/hygepdf.m +++ b/scripts/statistics/distributions/hygepdf.m @@ -53,7 +53,7 @@ k = find (i1); if (any (k)) if (isscalar (t) && isscalar (m) && isscalar (n)) - pdf = NaN * ones (size (x)); + pdf = NaN (size (x)); else pdf (k) = NaN; endif diff --git a/scripts/statistics/distributions/hygernd.m b/scripts/statistics/distributions/hygernd.m --- a/scripts/statistics/distributions/hygernd.m +++ b/scripts/statistics/distributions/hygernd.m @@ -86,7 +86,7 @@ endfor else if (ne) - rnd = NaN * ones (sz); + rnd = NaN (sz); else v = 0:n; p = hygepdf (v, t, m, n); diff --git a/scripts/statistics/distributions/laplace_inv.m b/scripts/statistics/distributions/laplace_inv.m --- a/scripts/statistics/distributions/laplace_inv.m +++ b/scripts/statistics/distributions/laplace_inv.m @@ -32,7 +32,7 @@ print_usage (); endif - inv = (-Inf) * ones (size (x)); + inv = -Inf (size (x)); k = find (isnan (x) | (x < 0) | (x > 1)); if (any (k)) diff --git a/scripts/statistics/distributions/lognrnd.m b/scripts/statistics/distributions/lognrnd.m --- a/scripts/statistics/distributions/lognrnd.m +++ b/scripts/statistics/distributions/lognrnd.m @@ -77,7 +77,7 @@ if (isscalar (mu) && isscalar (sigma)) if (!(sigma > 0) || !(sigma < Inf)) - rnd = NaN * ones (sz); + rnd = NaN (sz); else rnd = exp(mu + sigma .* randn (sz)); endif diff --git a/scripts/statistics/distributions/nbinrnd.m b/scripts/statistics/distributions/nbinrnd.m --- a/scripts/statistics/distributions/nbinrnd.m +++ b/scripts/statistics/distributions/nbinrnd.m @@ -77,7 +77,7 @@ if (isscalar (n) && isscalar (p)) if ((n < 1) || (n == Inf) || (n != round (n)) || (p <= 0) || (p > 1)); - rnd = NaN * ones (sz); + rnd = NaN (sz); elseif ((n > 0) && (n < Inf) && (n == round (n)) && (p > 0) && (p <= 1)) rnd = randp ((1 - p) ./ p .* randg (n, sz)); diff --git a/scripts/statistics/distributions/normcdf.m b/scripts/statistics/distributions/normcdf.m --- a/scripts/statistics/distributions/normcdf.m +++ b/scripts/statistics/distributions/normcdf.m @@ -51,7 +51,7 @@ if (isscalar (m) && isscalar(s)) if (find (isinf (m) | isnan (m) | !(s >= 0) | !(s < Inf))) - cdf = NaN * ones (sz); + cdf = NaN (sz); else cdf = stdnormal_cdf ((x - m) ./ s); endif diff --git a/scripts/statistics/distributions/norminv.m b/scripts/statistics/distributions/norminv.m --- a/scripts/statistics/distributions/norminv.m +++ b/scripts/statistics/distributions/norminv.m @@ -51,7 +51,7 @@ if (isscalar (m) && isscalar (s)) if (find (isinf (m) | isnan (m) | !(s > 0) | !(s < Inf))) - inv = NaN * ones (sz); + inv = NaN (sz); else inv = m + s .* stdnormal_inv (x); endif diff --git a/scripts/statistics/distributions/normpdf.m b/scripts/statistics/distributions/normpdf.m --- a/scripts/statistics/distributions/normpdf.m +++ b/scripts/statistics/distributions/normpdf.m @@ -51,7 +51,7 @@ if (isscalar (m) && isscalar (s)) if (find (isinf (m) | isnan (m) | !(s >= 0) | !(s < Inf))) - pdf = NaN * ones (sz); + pdf = NaN (sz); else pdf = stdnormal_pdf ((x - m) ./ s) ./ s; endif diff --git a/scripts/statistics/distributions/normrnd.m b/scripts/statistics/distributions/normrnd.m --- a/scripts/statistics/distributions/normrnd.m +++ b/scripts/statistics/distributions/normrnd.m @@ -76,7 +76,7 @@ if (isscalar (m) && isscalar (s)) if (find (isnan (m) | isinf (m) | !(s > 0) | !(s < Inf))) - rnd = NaN * ones (sz); + rnd = NaN (sz); else rnd = m + s .* randn (sz); endif diff --git a/scripts/statistics/distributions/poissrnd.m b/scripts/statistics/distributions/poissrnd.m --- a/scripts/statistics/distributions/poissrnd.m +++ b/scripts/statistics/distributions/poissrnd.m @@ -66,7 +66,7 @@ if (isscalar (l)) if (!(l >= 0) | !(l < Inf)) - rnd = NaN * ones (sz); + rnd = NaN (sz); elseif ((l > 0) & (l < Inf)) rnd = randp(l, sz); else diff --git a/scripts/statistics/distributions/trnd.m b/scripts/statistics/distributions/trnd.m --- a/scripts/statistics/distributions/trnd.m +++ b/scripts/statistics/distributions/trnd.m @@ -67,7 +67,7 @@ if (isscalar (n)) if (!(n > 0) || !(n < Inf)) - rnd = NaN * ones (sz); + rnd = NaN (sz); elseif ((n > 0) && (n < Inf)) rnd = randn(sz) ./ sqrt(2*randg(n/2,sz)./n); else diff --git a/scripts/statistics/distributions/unifrnd.m b/scripts/statistics/distributions/unifrnd.m --- a/scripts/statistics/distributions/unifrnd.m +++ b/scripts/statistics/distributions/unifrnd.m @@ -75,7 +75,7 @@ if (isscalar(a) && isscalar(b)) if (find (!(-Inf < a) | !(a < b) | !(b < Inf))) - rnd = NaN * ones(sz); + rnd = NaN(sz); else rnd = a + (b - a) .* rand (sz); endif diff --git a/scripts/statistics/distributions/wblcdf.m b/scripts/statistics/distributions/wblcdf.m --- a/scripts/statistics/distributions/wblcdf.m +++ b/scripts/statistics/distributions/wblcdf.m @@ -58,7 +58,7 @@ endif endif - cdf = NaN * ones (size (x)); + cdf = NaN (size (x)); ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf)); diff --git a/scripts/statistics/distributions/wblinv.m b/scripts/statistics/distributions/wblinv.m --- a/scripts/statistics/distributions/wblinv.m +++ b/scripts/statistics/distributions/wblinv.m @@ -47,7 +47,7 @@ endif endif - inv = NaN * ones (size (x)); + inv = NaN (size (x)); ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf)); diff --git a/scripts/statistics/distributions/wblpdf.m b/scripts/statistics/distributions/wblpdf.m --- a/scripts/statistics/distributions/wblpdf.m +++ b/scripts/statistics/distributions/wblpdf.m @@ -59,7 +59,7 @@ endif endif - pdf = NaN * ones (size (x)); + pdf = NaN (size (x)); ok = ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf)); k = find ((x > -Inf) & (x <= 0) & ok); diff --git a/scripts/statistics/distributions/wblrnd.m b/scripts/statistics/distributions/wblrnd.m --- a/scripts/statistics/distributions/wblrnd.m +++ b/scripts/statistics/distributions/wblrnd.m @@ -80,7 +80,7 @@ if ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf)) rnd = scale .* rande(sz) .^ (1./shape); else - rnd = NaN * ones (sz); + rnd = NaN (sz); endif else rnd = scale .* rande(sz) .^ (1./shape);