[Issue 11598] std.random.uniform could be faster for integrals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 25 00:37:52 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11598



--- Comment #3 from Chris Cain <zshazz at gmail.com> 2013-11-25 00:37:49 PST ---
Perhaps. There's an easy way to test this method to check whether this uniform
introduces any kind of skew. Just do uniform(ulong.min, (ulong.max/2 + 2)) and
count how many times the first and last number shows up over a long period of
time. Since there are two (giant) buckets, if something is wrong then the last
number will show up roughly half as often as the first.

Even better is to edit the source and make it so it acts on ushorts instead and
you can easily build an array to count those occurrences. Visually it looks
fine to me (I did this when developing this). While your rigging the source,
you can also change it so that it doesn't reroll and you'll see the effect I
described above clearly (that the first number shows up 2x more than the last).

Another alternative is I wrote up an informal proof on it a few months ago on
it (I've intended on submitting this sooner but just haven't been able to get
around to it). Here it is in pdf format:

https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf

So that all said, I'm almost certain of the quality of the approach. If you
find any problems with it, though, I would love to fix them.

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


More information about the Digitalmars-d-bugs mailing list