[Rd] rmultinom has a bug. (PR#4431)

maechler at stat.math.ethz.ch maechler at stat.math.ethz.ch
Mon Oct 6 16:05:11 MEST 2003


>>>>> "MM" == Martin Maechler <maechler at stat.math.ethz.ch>
>>>>>     on Mon, 6 Oct 2003 12:33:56 +0200 (MET DST) writes:

>>>>> "skon" == skon  <skon at stats.snu.ac.kr>
>>>>>     on Mon, 6 Oct 2003 12:22:36 +0200 (MET DST) writes:

    skon> Full_Name: SungGON Yi.  Version: 1.7.1 OS: Windows
    skon> 2000 pro Submission from: (NULL) (147.46.24.107)

    skon> p <- runif(4) rmultinom(1, 100, c(p, 0, 0, 0, 0))

    skon> That result are a wrong.

    MM> Confirmed for R 1.8.0 beta (on Linux).

    MM> Thank you for the report!
 
    MM> A slightly example is

    MM>   rmultinom(1,100, c(6, 8, 4, 0,0))

    MM> which has (almost?) always an NA at the 3rd position.

    MM> I will investigate.

and have now committed a bug fix (still in time for R 1.8.0).

The reason was that
    s := (a + b + c) - a - b  can be  >  c 
such that a call to rbinom(*, prob = s/c) gave NA, since s/c > 1

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><



More information about the R-devel mailing list