Random numbers generator test

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Lo! Please download random numbers generator test ( http://koule.hyperlinx.cz/Albion/RANDOMS.EXE ) and post here results together with your cpu speed (real speed, not "pentium rating" !)

I'd like to see if there is significant difference between differenct CPU frequencies (as it should be because random numbers are generated from current time)

Example/my result:

Intel Pentium 4 HT, 2400 MHz
unradnomized result: 0.9896 %
randomized result: 0.9919 %

Intel Pentium 4 HT, 4198 MHz (Overclock)
unrandomized result: 0.9537 %
randomized result: 0.9687 %
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
1) notice unrandomized random gives you always same result, while randomized random varies a bit. So for my measurement I'll be taking mainly unrandomized results.
2) Test is going to take about 20-21 M cycles so it can take a while to get result, don't worry, code is so simple that probability it stucks is very very very very very low ;-)
 

Dweller

Fledgling Freddie
Joined
Jan 9, 2004
Messages
300
No offence, but I don't think you're going to get many people volunteering to download a strange .exe file and running it, with all the viruses and trojans that abound on the internet these days.
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Dweller said:
No offence, but I don't think you're going to get many people volunteering to download a strange .exe file and running it, with all the viruses and trojans that abound on the internet these days.

I can give .pas, but don't think many pple would be able to compile it.
Also, everyone can use his antivirus software to be sure my piece is clear.

Just to add, file is 7824 bytes, if you get any other size, kick it off.
 

NetNifty

Fledgling Freddie
Joined
Dec 23, 2003
Messages
254
.pas = pascal?

Afaik when you do /random <number>, it just sends the command to the server which generates the random number, your computer doesn't generate it.
 

Iskander

Fledgling Freddie
Joined
Jan 7, 2004
Messages
309
I read somewhere (think is was VNboards) there is a hack, but it does require you to modify data going to and from the server, so it can be detected.
I'll see if I can find more info about it.
Note that I am not sure if it does really exists, just read some people claiming it does indeed exist.


P.S. here is your result

/Random 100=100 test brought to you by Honza
Testing phase 1 (nonrandomized random), please wait
Result:
Attempts made to get 1M random 100=100 : 1010515
Probability : 0.9896%
Testing phase 2 (randomized random), please wait
Result:
Attempts made to get 1M random 100=100 : 1011007
Probability : 0.9891%
End of test. Press any key to close application.
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
pas = pascal, yes
/random truly is generated by server, not your home computer

What sort of random generator... works this way:
1. first run uses CPU instruction to get you random number, is set to generate values 1-100. Programme counts how many throws were made till you get 1M of 100 results came from CPU.
2. 2nd run uses function that should make more random results (is influenced by current time in your computer) and otherwise works same way as first run.

There is random numbers generator code for those who would like to know:

...
{randomize;}
x:=0;
y:=0;
repeat
inc(x);
z:=inc(random(100));
if z=100 then inc(y);
until y=100000;
...

Thanks Iskalander for the first hit, just please add your cpu type/frequency to watch out if there is any connection in cpus type/speed and results.

In fact, it's not 1M but 100k, mislooked by one zero, but no use in changing it now. 100k attempts is significant enough.
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
Ah so it's just the standard generator in your pascal implementation. Likely a mersenne twister or linear congruence generator. Given that there should be no difference between different CPU frequencies as the algorithm is not based upon frequency of the computer at all (the randomize is done using the system clock, which counts seconds). In fact you will likely see little to no difference between people's results and yours as both the above random generators are deterministic.
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Danya said:
In fact you will likely see little to no difference between people's results and yours as both the above random generators are deterministic.

That I thought too, but since my own results overclocked/normal speed were so heavily different (see on top), I began to be very curious ;-)
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
That looks like your computer is producing erroneous data while overclocked - have you verified the overclock is good using prime95 or similar? If not you might want to, having a computer overclocked so hard is has data errors is a good way to crash and burn.
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Danya said:
That looks like your computer is producing erroneous data while overclocked - have you verified the overclock is good using prime95 or similar? If not you might want to, having a computer overclocked so hard is has data errors is a good way to crash and burn.
OFC I did, 12 hours non-stop testing with Hot CPU Tester PRO (prime numbers, breeding rabbits etc etc tests), without slightest error. If I'd get any error, I would immediately go lower with freq.
 

Belomar

Part of the furniture
Joined
Dec 30, 2003
Messages
5,107
I'm sorry, what are you trying to get at? That the pseudo-random number generator you implemented yourself is not perfect? Surely you realize that Mythic uses a different PRNG in the DAoC server, and although it may not be the best out there, it has nothing to do with your test here?
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Belomar said:
I'm sorry, what are you trying to get at? That the pseudo-random number generator you implemented yourself is not perfect? Surely you realize that Mythic uses a different PRNG in the DAoC server, and although it may not be the best out there, it has nothing to do with your test here?
I am trying to watch any connection between results gained and frequencies of cpu (if there is any).
Mythic uses different random number generator? I very very very very doubt about it - I'd bet on it they use same cpu instruction as me (there is cpu instruction that gives you "random" number). They do not need some difficult and cpu time consuming methods to give you /random or qua throw etc.
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
There's no CPU instruction to give you a random number. Additionally in my experience pascal and C compilers usually have markedly different random number generators. Assuming Mythic is using the standard C generator (which is by no means certain - it's not very hard to find code for other generators on the net), the odds on it being the same as your pascal implementation are not that great.

BTW, is there any evidence that Mythic's PRNG is actually of poor quality, or is that just popular opinion Belomar?
 

Thorwyn

FH is my second home
Joined
Dec 22, 2003
Messages
4,752
I thought every ingame /random 100 automatically sends an email to RightNow and there´s an employee sitting at his computer, constantly pressing F5 in his Outlook, with 2 ten-sided dice waiting on his desk! o_O

:D

Seriously... isn´t a pseudo-random event still random when you don´t have any ways to influence the throw b/c you can´t control the order of rolls or the exact time of when you´re rolling?
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Danya said:
There's no CPU instruction to give you a random number
Sorry to opose you, but there is, is part of numerical cooprocesor instruction set since 8087
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Thorwyn[B&Q] said:
Seriously... isn´t a pseudo-random event still random when you don´t have any ways to influence the throw b/c you can´t control the order of rolls or the exact time of when you´re rolling?

Unfortunately, it is not random. Computer doesn't have any dices to throw with.

And thinking about it, even when you are throwing dices in rl, it is not random. Result is influenced by billions and billions (and prolly much more) aspects, that we call chaos cause we are unable of describing em.
Imagine sub-atomic structure of such a dice (let's see on quark level to make it simplier), now imagine the difference you do with moving your hand bit faster or slower, you can get totaly different result. Internal energy of dice will be different, there will be slight deformations in the dice, turbulences you create moving your hand, and other :puke:

Computer simply does not have even slightest power to be able to compute these aspects, in fact computer is totaly dumb machine that know only 1 and 0, is able to put it in chain of 11101010101001010110100101 and is able of changing value of bit (1->0 and 0->1). In fact that's all what computer is capable of. That simply is not enough to be able to make something 'scientificaly random' if you understand what I mean (running out of words, this is getting too much scientific for my poor english).

So far, on unrandomized randoms we've gained rate 0.9896% for all machines except my overclocked one (which I'll have to run cpu tests again etc. just for sure result is correct). This could be taken as very very very faint proof that computer 'random' is not much random. Especially when you run test few more times, you can see you get exactly same results for unrandomized randoms.

It will be very interesting to see if AMDs give same result as Intels.
 

Oidche

Fledgling Freddie
Joined
Jun 22, 2004
Messages
41
Honza said:
And thinking about it, even when you are throwing dices in rl, it is not random. Result is influenced by billions and billions (and prolly much more) aspects, that we call chaos cause we are unable of describing em.

Actually, that IS random. Computer RNGs are called PSUEDO random because they generate numbers that aren't random, but the output of a function. The chance that a PRNG will generate the same numbers twice is zero.

Also: you're wrong in your assumption that the CPU is used for RNGs in all programming APIs. Delphi might do it, but I'm pretty damn sure C/C++ STD APIs don't. And since there is no way to influence de RND throws (they are done by the server, not by the client), your little programming excersize is just a waste of time.

Oh, and ofcourse no one in their right mind is going to download that .exe.
 

Oidche

Fledgling Freddie
Joined
Jun 22, 2004
Messages
41
Belomar said:
I'm sorry, what are you trying to get at? That the pseudo-random number generator you implemented yourself is not perfect?

He didn't 'implement' a RNG, he just used the standard Delphi RNG.
 

Belomar

Part of the furniture
Joined
Dec 30, 2003
Messages
5,107
Honza said:
Mythic uses different random number generator? I very very very very doubt about it - I'd bet on it they use same cpu instruction as me (there is cpu instruction that gives you "random" number). They do not need some difficult and cpu time consuming methods to give you /random or qua throw etc.
There is no instruction that gives you a pseudo-random number (preferred term to paraphrasing "random" all the time)--here is the 80x87 FPU instruction set, please show me the instruction you are referring to. Every standard library implements their own pseudo-random number generator, so your test has absolutely no bearing on Mythic's PRNG (which may or may not be a standard C library PRNG, or a higher-quality one).

I'm sorry, but you are barking up the wrong tree.
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
PRNGs are by their nature deterministic - if you run the code multiple times without calling the randomize function, you should get identical output. Even with the randomize function you don't get random numbers, just a reasonable approximation.

It's possible to generate truely random numbers on a computer, but to do so requires specific hardware support (many motherboards have some support for generating truely random numbers). It's not possible to use a purely algorithmic approach though, that will always be deterministic - to get truely random numbers you need to sample entropy from somewhere. Radioactive decay, noise and lava lamps are some common examples.

Sorry to opose you, but there is, is part of numerical cooprocesor instruction set since 8087
Which instruction is it then? Since you are so knowledgable you'll surely know that... ;)

The chance that a PRNG will generate the same numbers twice is zero.
I'm not sure quite what you mean by this... The chance a PRNG will generate the same numbers twice is 100%, so long as the initial conditions are set up the same each time. This is actually a very useful feature - it's much easier to debug something if you can reproduce it exactly every time.
 

Belomar

Part of the furniture
Joined
Dec 30, 2003
Messages
5,107
Danya said:
I'm not sure quite what you mean by this... The chance a PRNG will generate the same numbers twice is 100%, so long as the initial conditions are set up the same each time.
In addition, PRNG:s are usually cyclic, but with a very long period.
 

Honza

Fledgling Freddie
Joined
Jan 22, 2004
Messages
363
Oidche said:
He didn't 'implement' a RNG, he just used the standard Delphi RNG.
In fact I used old Pascal RNG. Did not bother of using Delphi to produce 300kB exe instead of 8kB pascal exe - imho you don't need nice window to show you result of such a test.

There is no instruction that gives you a pseudo-random number (preferred term to paraphrasing "random" all the time)--here is the 80x87 FPU instruction set, please show me the instruction you are referring to. Every standard library implements their own pseudo-random number generator, so your test has absolutely no bearing on Mythic's PRNG (which may or may not be a standard C library PRNG, or a higher-quality one).

1. I know DAoC generates randoms on server. But I was just curious so wanted to experiment a bit. This test does not have nothing together with DAoC, only original idea came from it.

2. You are true, there is no PRNG in that set. Does anybody have Borland Pascal 7.1 with english help files? Cause my czech translated hlp sais that random(x) function uses 80x87 cpu RNG instructions for generating one (if compiler is set to use x87) otherwise it is generated by code function.
As I see this is bullshit I'd like rather original hlp file not to saying anymore nonsenses /shamed.
 

sibanac

Fledgling Freddie
Joined
Dec 19, 2003
Messages
824
Honza said:
I am trying to watch any connection between results gained and frequencies of cpu (if there is any).
Mythic uses different random number generator? I very very very very doubt about it - I'd bet on it they use same cpu instruction as me (there is cpu instruction that gives you "random" number). They do not need some difficult and cpu time consuming methods to give you /random or qua throw etc.

I dont remember there beeing any such thing as a cpu instruction for a random number instruction in anything upto 80368 cpu's.

There are vastly diffrent generators out there, using diffrent algoritms.


EDIT: stupid users calling me while posting
 

Belomar

Part of the furniture
Joined
Dec 30, 2003
Messages
5,107
Oh, just noticed this:
Danya said:
BTW, is there any evidence that Mythic's PRNG is actually of poor quality, or is that just popular opinion Belomar?
I'm no expert and I don't know anything about the inner the workings of the DAoC server, but it seems to me that this is only popular opinion. Like Thorwyn said, even if the PRNG would be poor, there is an external source of randomness affecting the game as well: user input. People are autonomous and produce commands that get sent to the server and interfere with the internal processes of the game serve (admittedly, the network I/O might reduce some entropy). Due to the nature of an PRNG, even if a poor implementation could mean that, say, one party of a 1-vs-1 fight would be blocking or evading all the time (i.e. not due to pure "luck" but due to some flaw in the PRNG), there are thousands of simultaneous external events that interfere and add non-determinism to the process.

These are just my own theories, of course.
 

Oidche

Fledgling Freddie
Joined
Jun 22, 2004
Messages
41
Danya said:
I'm not sure quite what you mean by this... The chance a PRNG will generate the same numbers twice is 100%, so long as the initial conditions are set up the same each time. This is actually a very useful feature - it's much easier to debug something if you can reproduce it exactly every time.

I know.

I meant that if you set up a PRNG, number N and number N+1 will never be the same. Ofcourse this depends on the implementation, but most PRGNs give a pretty homogenous distribution of values.
 

Users who are viewing this thread

Top Bottom