Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Skybuck's Racing Random Number Generator V3 (algorithm fix..

 
Goto page Previous  1, 2, 3
   Game Forums (Home) -> Core War RSS
Next:  Happy 2008  
Author Message
vhepeter

External


Since: Jan 07, 2008
Posts: 4



(Msg. 31) Posted: Mon Jan 07, 2008 8:59 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>borland-delphi, others (more info?)

> I generated 20,000 numbers in the range 0..255 and wrote each byte to a
> binary file. Then analyzed it with this program:
>
> http://www.fourmilab.ch/random/
>
> I ran the sametestagainst the Delphi RandomRange function:
>
> F:\>ent.exe rand.bin
> Entropy = 7.991116 bits per byte.
>
> Optimum compression would reduce the size
> of this 20000 byte file by 0 percent.
>
> Chi square distribution for 20000 samples is 246.52, and randomly
> would exceed this value 50.00 percent of the times.
>
> Arithmetic mean value of data bytes is 126.9546 (127.5 = random).
> Monte Carlo value for Pi is 3.146714671 (error 0.16 percent).
> Serial correlation coefficient is -0.010652 (totally uncorrelated = 0.0).
>
Hello,
I'm comparing my own Random Number generator (using Mersenne Twister
Algorithm) with the Microsoft C# 's Random.Next function to see which
one is better.
In my comparison, I've them both produce 20,000 integer numbers(32
bits) range from 0 -255, which exactly like what you do, and run the
Went(a variant to the Original Ent) program against both of them.
For C#'s Random object:
Entropy = 0.541372 bits per bit.
Optimum compression would reduce the size of this 640000 bit file by
45 percent.
Chi square distribution for 640000 samples is 361498.56, and randomly
would exceed this value 0.01 percent of the times.
Arithmetic mean value of data bits is 0.1242 (0.5 = random).
Monte Carlo value for Pi is 4.000000000 (error 27.32 percent).
Serial correlation coefficient is 0.354847 (totally uncorrelated =
0.0).

For my own RNG:
Entropy = 0.542954 bits per bit.
Optimum compression would reduce the size of this 640000 bit file by
45 percent.
Chi square distribution for 640000 samples is 360417.12, and randomly
would exceed this value 0.01 percent of the times.
Arithmetic mean value of data bits is 0.1248 (0.5 = random).
Monte Carlo value for Pi is 4.000000000 (error 27.32 percent).
Serial correlation coefficient is 0.355082 (totally uncorrelated =
0.0).

It look very bad for both of them.
Am I doing something wrong with the generated number?
The number was produce and wrote to binary file using the following
code:

FileStream fs = new FileStream(path, FileMode.Append);
// Create the writer for data.
BinaryWriter w = new BinaryWriter(fs);
// Write data to Test.data.
for (int i = 0; i < 20000; i++)
{
w.Write(RandomHelperNew.SmallInt(0,255,false));//my own RNG

}
w.Close();
fs.Close();

Do you need to format your 32 bits integers(convert them into byte
array?) before you write them to binary file?

About the Ent test program, There are several options we could chose
from. Can you please give an example (the command you enter for your
test)?

 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
vhepeter

External


Since: Jan 07, 2008
Posts: 4



(Msg. 32) Posted: Tue Jan 08, 2008 5:37 am
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello,
Yes you are right William, Thanks. Another reason was because I did
not convert those Integer numbers into bytes before writing them to
the file, and after I did that the result look Ok to me now.

Entropy = 0.999339 bits per bit.
Optimum compression would reduce the size of this 640000 bit file by 0
percent.
Chi square distribution for 640000 samples is 586.00, and randomly
would exceed this value 0.01 percent of the times.
Arithmetic mean value of data bits is 0.4849 (0.5 = random).
Monte Carlo value for Pi is 3.481887047 (error 10.83 percent).
Serial correlation coefficient is 0.000422 (totally uncorrelated =
0.0).

 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
William

External


Since: Dec 31, 2007
Posts: 10



(Msg. 33) Posted: Tue Jan 08, 2008 1:05 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>borland-delphi, others (more info?)

You are writing a small integer, which takes up 16 bits, but your range
only uses 8 bits. So you are left with lots of trailing 0s.

Either use an 8 bit data type... or extend your range to 0..65535 Smile

vhepeter wrote:
> Hello,
> I'm comparing my own Random Number generator (using Mersenne Twister
> Algorithm) with the Microsoft C# 's Random.Next function to see which
> one is better.
> In my comparison, I've them both produce 20,000 integer numbers(32
> bits) range from 0 -255, which exactly like what you do, and run the
> Went(a variant to the Original Ent) program against both of them.
> For C#'s Random object:
> Entropy = 0.541372 bits per bit.
> Optimum compression would reduce the size of this 640000 bit file by
> 45 percent.
> Chi square distribution for 640000 samples is 361498.56, and randomly
> would exceed this value 0.01 percent of the times.
> Arithmetic mean value of data bits is 0.1242 (0.5 = random).
> Monte Carlo value for Pi is 4.000000000 (error 27.32 percent).
> Serial correlation coefficient is 0.354847 (totally uncorrelated =
> 0.0).
>
> For my own RNG:
> Entropy = 0.542954 bits per bit.
> Optimum compression would reduce the size of this 640000 bit file by
> 45 percent.
> Chi square distribution for 640000 samples is 360417.12, and randomly
> would exceed this value 0.01 percent of the times.
> Arithmetic mean value of data bits is 0.1248 (0.5 = random).
> Monte Carlo value for Pi is 4.000000000 (error 27.32 percent).
> Serial correlation coefficient is 0.355082 (totally uncorrelated =
> 0.0).
>
> It look very bad for both of them.
> Am I doing something wrong with the generated number?
> The number was produce and wrote to binary file using the following
> code:
>
> FileStream fs = new FileStream(path, FileMode.Append);
> // Create the writer for data.
> BinaryWriter w = new BinaryWriter(fs);
> // Write data to Test.data.
> for (int i = 0; i < 20000; i++)
> {
> w.Write(RandomHelperNew.SmallInt(0,255,false));//my own RNG
>
> }
> w.Close();
> fs.Close();
>
> Do you need to format your 32 bits integers(convert them into byte
> array?) before you write them to binary file?
>
> About the Ent test program, There are several options we could chose
> from. Can you please give an example (the command you enter for your
> test)?
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
William

External


Since: Dec 31, 2007
Posts: 10



(Msg. 34) Posted: Tue Jan 08, 2008 7:45 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

vhepeter wrote:
> Chi square distribution for 640000 samples is 586.00, and randomly
> would exceed this value 0.01 percent of the times.

This is very bad and would seem to indicate a problem with your generator.

Although I would perform tests with more samples to be sure.

You want to be as close to 50% as possible.
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
vhepeter

External


Since: Jan 07, 2008
Posts: 4



(Msg. 35) Posted: Tue Jan 08, 2008 11:11 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>borland-delphi, others (more info?)

On 1月9日, 上午3时45分, William <william_....DeleteThis@gmail.com> wrote:
> This is very bad and would seem to indicate a problem with your generator.
>
> Although I would perform tests with more samples to be sure.
>
> You want to be as close to 50% as possible.

Yes, your are right but there are different purposes for my and .Net's
Random generator.

They are not safe for encrypting or as password but what I want was
just some relatively random number as an ID for my object,

so it would be ok.

.Net also provided another much safer
generator(RandomNumberGenerator), which would be much better than my
and .Net's Random generator.

Here is the result for “RandomNumberGenerator”:

Entropy = 1.000000 bits per bit.
Optimum compression would reduce the size of this 5120000 bit file by
0 percent.
Chi square distribution for 5120000 samples is 1.30, and randomly
would exceed this value 50.00 percent of the times.
Arithmetic mean value of data bits is 0.5003 (0.5 = random).
Monte Carlo value for Pi is 3.138394615 (error 0.10 percent).
Serial correlation coefficient is 0.000177 (totally uncorrelated =
0.0).
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
Vend

External


Since: Dec 19, 2007
Posts: 7



(Msg. 36) Posted: Wed Jan 09, 2008 6:25 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 8 Gen, 14:37, vhepeter <vhepeter2... RemoveThis @gmail.com> wrote:
> Hello,
> Yes you are right William, Thanks. Another reason was because I did
> not convert those Integer numbers into bytes before writing them to
> the file, and after I did that the result look Ok to me now.
>
> Entropy = 0.999339 bits per bit.
> Optimum compression would reduce the size of this 640000 bit file by 0
> percent.
> Chi square distribution for 640000 samples is 586.00, and randomly
> would exceed this value 0.01 percent of the times.
> Arithmetic mean value of data bits is 0.4849 (0.5 = random).
> Monte Carlo value for Pi is 3.481887047 (error 10.83 percent).
> Serial correlation coefficient is 0.000422 (totally uncorrelated =
> 0.0).

I presume that if you are using the original Mersenne Twister this
shouldn't happen.
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
vhepeter

External


Since: Jan 07, 2008
Posts: 4



(Msg. 37) Posted: Fri Jan 11, 2008 4:40 am
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> I presume that if you are using the original Mersenne Twister this
> shouldn't happen.

There's nothing wrong with my "Mersenne Twister" number generator but
It's all my fault actually.

All previous tests were based on an assumption that the produced
number were 32 bits but they are not,
they are actually 31 bits number.

So after I correct this, it produced some amazing result:

Entropy = 1.000000 bits per bit.
Optimum compression would reduce the size of this 640000 bit file by 0
percent.
Chi square distribution for 640000 samples is 0.32, and randomly would
exceed this value 50.00 percent of the times.
Arithmetic mean value of data bits is 0.5004 (0.5 = random).
Monte Carlo value for Pi is 3.127278182 (error 0.46 percent).
Serial correlation coefficient is -0.000450 (totally uncorrelated =
0.0).
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
Vend

External


Since: Dec 19, 2007
Posts: 7



(Msg. 38) Posted: Fri Jan 11, 2008 11:48 am
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 11 Gen, 13:40, vhepeter <vhepeter2....TakeThisOut@gmail.com> wrote:
> > I presume that if you are using the original Mersenne Twister this
> > shouldn't happen.
>
> There's nothing wrong with my "Mersenne Twister" number generator but
> It's all my fault actually.
>
> All previous tests were based on an assumption that the produced
> number were 32 bits but they are not,
> they are actually 31 bits number.
>
> So after I correct this, it produced some amazing result:
>
> Entropy = 1.000000 bits per bit.
> Optimum compression would reduce the size of this 640000 bit file by 0
> percent.
> Chi square distribution for 640000 samples is 0.32, and randomly would
> exceed this value 50.00 percent of the times.
> Arithmetic mean value of data bits is 0.5004 (0.5 = random).
> Monte Carlo value for Pi is 3.127278182 (error 0.46 percent).
> Serial correlation coefficient is -0.000450 (totally uncorrelated =
> 0.0).

Ok, although the error on Pi seems a bit high.
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
William

External


Since: Dec 31, 2007
Posts: 10



(Msg. 39) Posted: Sat Jan 12, 2008 6:05 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>borland-delphi, others (more info?)

>> So after I correct this, it produced some amazing result:
>>
>> Entropy = 1.000000 bits per bit.
>> Optimum compression would reduce the size of this 640000 bit file by 0
>> percent.
>> Chi square distribution for 640000 samples is 0.32, and randomly would
>> exceed this value 50.00 percent of the times.
>> Arithmetic mean value of data bits is 0.5004 (0.5 = random).
>> Monte Carlo value for Pi is 3.127278182 (error 0.46 percent).
>> Serial correlation coefficient is -0.000450 (totally uncorrelated =
>> 0.0).
>
> Ok, although the error on Pi seems a bit high.

Should get better with more samples. 640000 bits isn't that much test data.
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
Jim P

External


Since: Dec 01, 2007
Posts: 16



(Msg. 40) Posted: Sat Jan 12, 2008 6:05 pm
Post subject: Re: Skybuck's Racing Random Number Generator V3 (algorithm fixed, [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

William wrote:
>>> So after I correct this, it produced some amazing result:
>>>
>>> Entropy = 1.000000 bits per bit.
>>> Optimum compression would reduce the size of this 640000 bit file by 0
>>> percent.
>>> Chi square distribution for 640000 samples is 0.32, and randomly would
>>> exceed this value 50.00 percent of the times.
>>> Arithmetic mean value of data bits is 0.5004 (0.5 = random).
>>> Monte Carlo value for Pi is 3.127278182 (error 0.46 percent).
>>> Serial correlation coefficient is -0.000450 (totally uncorrelated =
>>> 0.0).
>>
>> Ok, although the error on Pi seems a bit high.
>
> Should get better with more samples. 640000 bits isn't that much test data.

and skybuck was trying to do this testing with only 100 random numbers
and could not figure out what the problem was.

with 100 numbers out of 2 billion. anything would look random.
you need volumes to show random.


Jim P.
 >> Stay informed about: Skybuck's Racing Random Number Generator V3 (algorithm fix.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Odp: Skybuck's Racing Random Number Generator - Dnia 23-12-2007 o godz. 1:01 Skybuck Flying napisal: > [...] > > Third run: > > press enter to start > > press enter to stop > Number 0 A: 1117172294 > Number 1 A: 2096728732 > Number 2 A: 1845167743 > Number 3 A: 1451...

Score Surface for 94nop - Hi, some anonymous person (still called "bvowk" for simplicity ;-) is so kind to provide access to a pile of computers. I have suggested to calculate one score surface for standard settings. It takes roughly 1000 times the time of one "no...

Bug in pMARS - Hi, either I don't know how EQUs work or I have found a bug in the parser of pMARS. So far I cound pin it down to: ;redcode-tiny ;name test ;assert CORESIZE == 800 v3 EQU 3 * (3 / 2 + 1) + 3 v4 EQU (CORESIZE - v3) dat.f v3, v4 With the..

KOTH.ORG: Status - ICWS Experimental 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG ICWS Experimental 94..

KOTH.ORG: Status - MultiWarrior 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG Multiwarrior 94 CoreWar..
   Game Forums (Home) -> Core War All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Goto page Previous  1, 2, 3
Page 3 of 3

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]