delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
In-Reply-To: | <200709051511.l85FBDts032068@envy.delorie.com> |
Subject: | Re: random() : What am I doing wrong? |
To: | djgpp AT delorie DOT com |
X-Mailer: | Lotus Notes Release 7.0.2 September 26, 2006 |
Message-ID: | <OF8023CA5C.B777E9E3-ON8725734D.00541573-8725734D.00544D8B@seagate.com> |
From: | Gordon DOT Schumacher AT seagate DOT com |
Date: | Wed, 5 Sep 2007 09:20:52 -0600 |
X-MIMETrack: | Serialize by Router on SV-GW1/Seagate Internet(Release 7.0.1 HF29|March 07, 2006) at |
09/05/2007 08:20:56 AM | |
MIME-Version: | 1.0 |
X-Proofpoint-FWRule: | outbound2 |
X-Proofpoint-Virus-Version: | vendor=fsecure engine=4.65.5502:2.3.11,1.2.37,4.0.164 definitions=2007-09-05_06:2007-09-05,2007-09-05,2007-09-05 signatures=0 |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
DJ Delorie <dj AT delorie DOT com> wrote on 09/05/2007 09:11:13 AM: # > That depends if you care about equidistribution; if you do, you'd be # > better off # # ... not using random() in the first place. Fair enough :) I can recommend the Mersenne Twister for this, if anyone cares... # This has *exactly* the same problem, it just involves different # numbers being weighted heavier. # # If you really want equidistribution, you have to check for the last # couple of numbers, and call random() again if you get them. Well, okay - random() doesn't anything like guarantee equidistribution. But that said, wouldn't scaling the result set at least not give you anything *worse* than what you started with? (I freely admit that we're pushing the bounds of what I know here, so this isn't meant as a challenge, but rather the possibility of learning something...)
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |