From m@echler @ending from @t@t@m@th@ethz@ch  Thu Sep 20 17:46:18 2018
From: m@echler @ending from @t@t@m@th@ethz@ch (Martin Maechler)
Date: Thu, 20 Sep 2018 17:46:18 +0200
Subject: [Rd] A different error in sample()
In-Reply-To: <23459.19022.858260.194660@stat.math.ethz.ch>
References: <5b6950ce-ac7a-4f6a-da61-8e70d25bb08c@gmail.com>
 <CAO1zAVbHXAz9o7uf98Q5pUm7R8pSHFigAAtQn90FrGdPfqUn1A@mail.gmail.com>
 <SYCPR01MB41112555F67E1CAD438FCB6BCD1C0@SYCPR01MB4111.ausprd01.prod.outlook.com>
 <90332569-2e20-e645-26de-9c2cd43eaea9@embl.de>
 <a90aa1d8-6f6d-4be1-140a-5f776df36fd0@embl.de>
 <23459.19022.858260.194660@stat.math.ethz.ch>
Message-ID: <23459.49354.466423.813313@stat.math.ethz.ch>

>>>>> Martin Maechler 
>>>>>     on Thu, 20 Sep 2018 09:20:46 +0200 writes:

>>>>> Wolfgang Huber 
>>>>>     on Thu, 20 Sep 2018 08:47:47 +0200 writes:

    >> FWIW, I suspect this is related to the function
    >> R_unif_index that was introduced in src/main/RNG.c around
    >> revision 72356, or the way this function is used in
    >> do_sample in src/main/random.c.

    > Yes, it is just the use of 'dn' instead of 'n'
    > - a one letter thinko I'd say.

    > But *no*, it's much older than revision 72356; e.g., it's already in

    > R version 3.0.0 (2013-04-03) -- "Masked Marvel"

    > but not yet in

    > R version 2.15.3 (2013-03-01) -- "Security Blanket"

    > ----

    > Here, I clearly think we see a regression bug, and hopefully not
    > one that should trigger often in practice...
    > and  -- without any statistics about the consequences out in
    > package space --
    > I do think we should fix this in code and let the documentation
    > become "great again" ;-)

We have agreed that this is simply a regression and should be
fixed without a change to the documenation.

Consequently, ~ 5 minutes ago

$ svn log -v -c75338
------------------------------------------------------------------------
r75338 | maechler | 2018-09-20 17:38:46 +0200 (Thu, 20 Sep 2018) | 1 line
Changed paths:
   M /trunk/doc/NEWS.Rd
   M /trunk/src/main/random.c
   M /trunk/tests/reg-tests-1d.R

revert sample.int(<non-integer>, k, replace=TRUE) to sane pre_R-3.0.0 behaviour
------------------------------------------------------------------------

This is now back to "correct" behaviour  in  "R-devel (>= 75338)"

(and, as Duncan Murdoch also said by choosing this thread's
 Subject, this is really a different issue than the  "Bias in R's....")

Martin



[Rd] A different error in sample()
Martin Maechler