Mercurial > hg > octave-nkf
changeset 16058:444de2c0af0e
binopdf.m: Ensure Matlab compatibility for boundary values (bug #38292).
* scripts/statistics/distributions/binopdf.m: Return 1 for special cases
of 'binopdf (0,n,0)' and 'binopdf (n,n,1)'.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 13 Feb 2013 21:53:39 -0800 |
parents | c3057d80cf91 |
children | 2175c41b12d1 |
files | scripts/statistics/distributions/binopdf.m |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/statistics/distributions/binopdf.m +++ b/scripts/statistics/distributions/binopdf.m @@ -64,6 +64,12 @@ + x(k).*log (p(k)) + (n(k)-x(k)).*log (1-p(k))); endif + ## Special case inputs + ksp = k & (p == 0) & (x == 0); + pdf(ksp) = 1; + ksp = k & (p == 1) & (x == n); + pdf(ksp) = 1; + endfunction @@ -82,6 +88,11 @@ %!assert (binopdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 0]) %!assert (binopdf ([x, NaN], 2, 0.5), [y, NaN], tol) +## Test Special input values +%!assert (binopdf (0, 3, 0), 1); +%!assert (binopdf (2, 2, 1), 1); +%!assert (binopdf (1, 2, 1), 0); + %% Test class of input preserved %!assert (binopdf (single ([x, NaN]), 2, 0.5), single ([y, NaN])) %!assert (binopdf ([x, NaN], single (2), 0.5), single ([y, NaN]))