[Issue 10322] std.random.RandomSample.index() returns wrong value if called before front()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 10 09:06:35 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10322



--- Comment #3 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-06-10 09:06:33 PDT ---
Created an attachment (id=1223)
Example of error if popFront() is called before first call to front().

This code averages over multiple samples with the following cases:

  (1) a regular sample of 5 items from 100;

  (2) a sample initialized to request 5 items from 100 (labelled 0-99); .front
is called, followed by .popFront(), and then the remains of the sample is
taken.

  (3) a sample initialized to request 5 items from 100; .popFront() alone is
called, and then the remains of the sample is taken.

In the last case it is clear that the remains of the sampling process is in
practice taking 4 items with equal probability from the items 1-99, when what
_should_ be happening is that it is taking 4 items from the items remaining to
consider after the first sample point has been taken.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list