General > Off Topic

Rnd function

<< < (5/9) > >>

MightyPenguin:
Two processors?

Numsgil:
I can't find any information on the VB random number generator, or how good it is, or what its period is.

For one program I needed to generate at least 200 billion random numbers, so there are times when you need a good random number generator.

DB probably isn't there yet, but I love talking about random numbers!

Botsareus:
I was Basing it on the msdn help for the rnd function.
I also did a timed test too see aprox. the number of rnd calls in two seconds.
/ 2 x 45 running smexe: came out to 225000 calls per second.


Forgive me if I messed this one up but somthing like:

Form_load()
show
Do
j = j + 1
if (timer) /2 = (timer) \2 then msgbox j 'forget about the fact thats it has to do the
'loop code and the j++ code ...  ;)
Loop
End Sub

Botsareus:
OK gess what the rnd function DOES NOT WORK LIKE THIS

newrndnumberinlist = rnd(-oldrandomnumber)

<>

newrndnumberinlist = rnd

The Truth is no one has a clue were vb gets its next random number in stack from:

newrndnumberinlist = rnd(-???????)


Ok here is the second thing that people should look out for:

lets say you have a number that changes in low range: 0.001 , 0.002 , 0.003....

DO NOT ADD ANY HIGH RANGE NUMBERs like 700000  TO IT EX:

70000.001 , 70000.002 , 7000 0.003 ...

IT WILL LOSE SENSATIVITY TO LOWER RANGE CHANGE

rnd(-(rnd+70000)) <------ not so good idea.

Finaly , If you want to make the random function more powerfull you have first run the list:

For I = 0 to 1000000
thelist(I) = rnd
next

into memory,

Then combine it later with your own random numbers:

yourownrandomnumber = rnd(-cpuflux)

t = t +1

'COMBINE ONLY USING ATN() FUNCTION , I use getang as a custom atn using function

result = rnd(-(getang( rnd(-yourownrandomnumber) -0.5  , rnd(-thelist(t)) -0.5 )/360)

Numsgil:
I'm sticky-ing this thread because every two or three months I go hunting for that incredibly book with the chapters I posted near the beginning of the thread, and have to hunt this damn thign down.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version