# HG changeset patch # User Ben Abbott # Date 1335838754 14400 # Node ID 89504d0a5c5b069c0add097cf7bb0b270e185734 # Parent 000cd393f3c1391f57569bb79746cd5c2314807f poissrnd should return zero when lambda = 0. (Bug # 36326) poissrnd.m: poissonrnd should return zero when lambda = 0. Add demos. diff -r 000cd393f3c1 -r 89504d0a5c5b scripts/statistics/distributions/poissrnd.m --- a/scripts/statistics/distributions/poissrnd.m Thu Apr 19 16:24:14 2012 -0400 +++ b/scripts/statistics/distributions/poissrnd.m Mon Apr 30 22:19:14 2012 -0400 @@ -76,7 +76,7 @@ endif if (isscalar (lambda)) - if (lambda > 0 && lambda < Inf) + if (lambda >= 0 && lambda < Inf) rnd = randp (lambda, sz); if (strcmp (cls, "single")) rnd = single (rnd); @@ -87,13 +87,12 @@ else rnd = NaN (sz, cls); - k = (lambda > 0) & (lambda < Inf); + k = (lambda >= 0) & (lambda < Inf); rnd(k) = randp (lambda(k)); endif endfunction - %!assert(size (poissrnd (2)), [1, 1]); %!assert(size (poissrnd (ones(2,1))), [2, 1]); %!assert(size (poissrnd (ones(2,2))), [2, 2]); @@ -118,3 +117,6 @@ %!error poissrnd (ones(2,2), [3, 2]) %!error poissrnd (ones(2,2), 2, 3) +%!assert (poissrnd (0, 1, 1), 0) +%!assert (poissrnd ([0, 0, 0], [1, 3]), [0 0 0]) +