There's a really good section in Numerical Recipes for C on pseudo
random number generators. There's also a bit about doing 64-bit math in
two 32-bit numbers, which would be especially applicable for the OP's
Win32 implementation. I remember finding this chapter on the web in PDF
format a
At 15:19 -0500 2004/11/10, [EMAIL PROTECTED] wrote:
You could accomplish the same thing by something like this.
NUM1 = RND(33000)
NUM2 = RND(33000)
RNDNUM = (NUM1R%4:NUM2R%4) + 0
thus taking only the 4 rightmost digits of each.
You definitely shouldn't do this. Default RNG's are crappy to begin
I always multiply the random number generated by the system time in my
programs
-Dianne
[EMAIL PROTECTED] wrote:
So, how could you generate random numbers larger than 32K?
Call RND twice, multiply the first number by 32762 and add on the second number?
Probably lousy mathematics, but it might
I ran your code on UV 10.1 on AIX and the highest number generated was 370558
I don't think it's your code
Mel
UV 9.6.1.3 on NT.
I needed to generate some random numbers between 0 and 370570, and just to
check the distribution of numbers, I ran this snippet of code:
FOR I = 1 TO 99
The RND function has an upper limit of (2 ** 15) - 1, such that the range
can be
0 to 32767. High order bits are dropped. The documentation does
indicate that the value within the parenthesis is the total number of
integers, including 0, from which the random number can be selected; what
it
Oh yes. That is the limitation on 32-bit Windoze. Your numbers WILL
differ on UNIX systems.
At 02:36 PM 11/10/2004, you wrote:
I ran your code on UV 10.1 on AIX and the highest number generated was 370558
I don't think it's your code
Mel
UV 9.6.1.3 on NT.
I needed to generate some random
UV 10.0.15 ON Windows 2003 server
Largest RND returned is 32767
Hmm
Looks like the docco under HELP BASIC RND should say
Use the RND function to generate any positive or negative random 16-bit
integer or 0
So, how could you generate random numbers larger than 32K?
Call RND
I suspect from your description that the argument for RND() is a signed Small
Integer (0 through 32767).
Don't know why this is. Manual doesn't seem to help. Ask IBM.
Workaround is something like 32768 * Rnd(32767) + Rnd(32767).
- Original Message -
From: Barry Brevik [EMAIL PROTECTED]
UV 9.6.1.3 on NT.
I needed to generate some random numbers between 0 and 370570, and just to
check the distribution of numbers, I ran this snippet of code:
FOR I = 1 TO 99
THIS.NUM = RND(370570)
NEXT
Add this line to the top
PRECISION 0
and try it again.
Will
---
u2-users mailing list
So, how could you generate random numbers larger than 32K?
Call RND twice, multiply the first number by 32762 and add on the second
number? Probably lousy mathematics, but it might work!
Your idea works perfectly. The mathematics is correct.
You could accomplish the same thing by something like
Barry,
On UV10.0.16, HPUX11i, I get a reasonable distribution:
0001: DIM DISTRIB(10) ; MAT DISTRIB = 0
0002: FOR I = 1 TO 99
0003: THIS.NUM = RND(370570)
0004: DISTRIB( 1+ INT( THIS.NUM/37057 ) )+= 1
0005: NEXT
0006: FOR I = 1 TO 10
0007: CRT
I seem to remember something about 32,767 or 32,768 being involved in this
somewhere. Not being a math major, but this is a 8 bit number which I
believe is the max for the RND function. You will have to add some other
mathematics to reach your 370570.
Tom Dodds
[EMAIL PROTECTED]
630-235-2975
That happens because there is special code for the HP: it utilizes a
double, not an int.
At 03:23 PM 11/10/2004, you wrote:
Barry,
On UV10.0.16, HPUX11i, I get a reasonable distribution:
0001: DIM DISTRIB(10) ; MAT DISTRIB = 0
0002: FOR I = 1 TO 99
0003: THIS.NUM =
limitation on Windoze.
*=aee=*
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Glenn Herbert
Sent: Wednesday, November 10, 2004 12:01
To: [EMAIL PROTECTED]
Subject: RE: [U2] [UV] Random number (RND()) help
Oh yes. That is the limitation on 32
?
243449
?
253422
?
282865
?
33416
?
351549
Must be a Universe limitation on Windoze.
*=aee=*
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Glenn Herbert
Sent: Wednesday, November 10, 2004 12:01
To: [EMAIL PROTECTED]
Subject: RE: [U2] [UV] Random
deliberate top post
No. UniData and UniVerse are radically different animals wearing a similar
skin.
/deliberate top post
- Original Message -
From: Glenn Herbert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: [U2] [UV] Random number (RND()) help
Date: Wed, 10 Nov 2004 16:16:21
Workaround is something like 32768 * Rnd(32767) + Rnd(32767).
Wouldn't that be *unlikely* to generate numbers less than 32767? Or at least
they would be statisticlly skewed away from that lower range.
Maybe something like (for numbers between 0 and 370500):
ITERATIONS = 1
RND.MAX = 370500
Workaround is something like 32768 * Rnd(32767) + Rnd(32767).
Wouldn't that be *unlikely* to generate numbers less than 32767? Or at
least they would be statisticlly skewed away from that lower range.
Actually, it wouldn't skew at all. Here's a simple example to prove that
32768 *
18 matches
Mail list logo