binornd incorrect for n=0
David Bateman
David.Bateman at motorola.com
Mon Sep 8 02:55:38 CDT 2008
Could someone with the Matlab statistics toolbox check what
"binornd(0,0,1)" gives under matlab? I suspect this bug report is right
but would like to check what matlab returns before fully supporting its
inclusion..
Cheers
David
Mark van Rossum wrote:
> Bug report for Octave 3.0.1 configured for i386-redhat-linux-gnu
>
> Description:
> -----------
> Binornd returns a Nan when n=0.
> The case n=0 is mathematically well defined and should always be zero
>
>
> * Please replace this item with a detailed description of the
> problem. Suggestions or general comments are also welcome.
>
> Repeat-By:
> ---------
> binornd(0,0.1)
>
> * Please replace this item with a description of the sequence of
> events that causes the problem to occur.
>
> Fix:
> ---
>
> Replace in binornd.m
> if (find (!(n > 0) | !(n < Inf) | !(n == round (n)) |
> !(p >= 0) | !(p <= 1)))
> rnd = NaN * ones (sz);
> else
>
> with
> if (find (!(n >= 0) | !(n < Inf) | !(n == round (n)) |
> !(p >= 0) | !(p <= 1)))
> rnd = NaN * ones (sz);
> elseif (find(n == 0))
> rnd = 0 * ones (sz);
> else
>
> AND
>
> k = find (!(n > 0) | !(n < Inf) | !(n == round (n)) |
> !(p >= 0) | !(p <= 1));
> if (any (k))
> rnd(k) = NaN;
> endif
>
> with
>
> k = find ( !(n >= 0)| !(n < Inf) | !(n == round (n)) |
> !(p >= 0) | !(p <= 1));
> if (any (k))
> rnd(k) = NaN;
> endif
>
> rnd(find((n == 0))) =0;
>
> (Sorry for the ugly format)
>
>
>
> * If possible, replace this item with a description of how to
> fix the problem (if you don't have a fix for the problem, don't
> include this section, but please do submit your report anyway).
>
--
David Bateman David.Bateman at motorola.com
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
More information about the Bug-octave
mailing list