Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: (off topic) Is my math right?

Author: Erik Bergren

Date: 10:44:16 08/13/03

Go up one level in this thread


On August 11, 2003 at 18:44:19, Dieter Buerssner wrote:

>>     Your experimental method for producing
>>the probability curve was a good idea,
>>and not at all lazy (as you said).
>>    However your numbers are incorrect.
>>I suspect your random number generator
>>was bad.
>
>Yes, that is probable. One would need some rather decent random number
>generator, to get correct numbers in the tails of the distribution. Besides the
>exact PRNG used by Angrim, also the function flip() would be interesting.
>
>Regards,
>Dieter

Angrim has not yet told how "flip()" was computed.

Robert Hyatt's Random number generator
worked well ("rather decent") for that. You can find it
in the following letter.
============================================
============================================

I found the answer to a posted question as:

"The probability ( or "strangeness") of a computer
(randomized in some way to prevent bad ruts,
 (if possible?))
winning 85 (or higher) out of 100 games
from one of equal strength
(or against an identical computer, say) ,
and assuming that the "Probability Ratio"
for White to win is .6237,
is (certainly) equal to


 4.99769099966...*10^-14."

  thanks to help from:

George Tsavdaris
Angrim
William H. Rogers
Remi Coulom
Dieter Buerssner
Robert Hyatt's Crafty code




Here is how that answer was found and verified:


Unassemble of:
Program to give experimental
Numbers for number of wins for White in
10000000 matches of 100 games each where
players switch sides after every game,
and both players have equal "playing strength".
The "Probability Ratio"of white winning
is assumed to be .6237 (that number is
the ratio in "gm2600.pgn" at Robert Hyatt's
Crafty ftp site).

    The theoretical equation to predict
the results is:
(in format for programming a Texas Instrument "TI-85"
programmable calculator):

R=.6237
E0= R^x*(1-R)^(50-x)*50!/(x!*(50-x)!)
E1= (1-R)^x*R^(50-x)*50!/(x!*(50-x)!)
'REM W= # of wins for white
ProbableOutcome= sum(seq(E0,x,00,50-W,1)*seq(E0,x,W,50,1))*10000000

(The output numbers for that is listed below.)

Here is the Unassemble for the experimental data producer:

 u 700 7c8

3312:0700  90           start:	  nop
3312:0701  90           	        nop
3312:0702  8cc8         	        mov	     ax,cs
3312:0704  8ec0         	        mov	     es,ax
‘REM Here the coefficients for the random number
‘REM generator’s polynomial are loaded:
3312:0706  8d360006     	        lea	     si,x55     ;for(i=0;i<55;i++) y
3312:070a  bf0030       	        mov	     di,3000
3312:070d  b93700       	        mov	     cx,37
3312:0710  66 3 ad         	         3 lodsd
3312:0712  66 3 ab         	         3 stosd
3312:0714  66 3 33c0       	        xor	     eax,eax
3312:0717  66 3 ab         	         3 stosd
3312:0719  e2f5         	        loop	    710

'REM ( this is to time execution time
'REM ( the time it took on my machine
'REM    was 25B,0052,D5A1-1DC,C867,3896 clock cycles
'REM    of 334,132,000 Hertz = ~27 minutes)):
3312:071b  90           	        nop
3312:071c  0f31         	         5 rdtsc
3312:071e  66 3 a30042     	        mov	     [4200],eax
3312:0722  66 3 89160442   	        mov	     [4204],edx

'REM Here are the two nested loops to generate the
'REM 10000000 matches of 100 games:
'REM ("186a0" is the old setting I had for 100000 matches.)
3312:0727  66 3 b9a0860100 	        mov	     ecx,186a0
3312:072d  66 3 51         	        push	    ecx
3312:072f  66 3 c706240100000000	   mov	     d,xp,0
3312:0738  b96400       	        mov	     cx,64
3312:073b  51           	        push	    cx
'REM "rnd" generates random numbers in register eax
'REM "rnd" is copied from Robert Hyatt's random number
'REM generator in "utilities.c" which is a part
'REM of his free program "Crafty"
'REM (He used it to generate hash table IDs):
3312:073c  e85700       	        call	    rnd
3312:073f  eb00         	        jmp	     $+2
'REM "9faacd9e" is .6237 of ffffffff, thus
'REM this line controls the "Probability Ratio"
'REM of White winning:
3312:0741  66 3 81f89ecdaa9f	       cmp	     eax,9faacd9e
3312:0748  bb0000       	        mov	     bx,0
3312:074b  7303         	        jnc	     750
3312:074d  bb0100       	        mov	     bx,1

'REM Here the "players switching sides" is simulated
'REM by finding the parity ("modulus base two") of
'REM the number of games, and that is then "ORed"
'REM with the previous outcome result:
3312:0750  58           	        pop	     ax
3312:0751  50           	        push	    ax
3312:0752  83e001       	        and	     ax,+1
3312:0755  33c3         	        xor	     ax,bx

'REM Here the Win or Loss is summed
'REM ("xp" stores the number of White wins in the
'REM   current match):
3312:0757  d1d8         	        rcr	     ax,1
3312:0759  66 3 8316240100 	        adc	     d,xp,+0

3312:075f  59           	        pop	     cx
3312:0760  e2d9         	        loop	    73b
'REM That was the end of the loop for each game.

'REM Here the match result is stored
'REM in an array ordered by White wins per match
3312:0762  66 3 8b1e2401   	        mov	     ebx,xp
3312:0767  66 3 b801000000 	        mov	     eax,1
3312:076d  66 3 56         	        push	    esi
3312:076f  66 3 be00440000 	        mov	     esi,4400
3312:0775  67 3 66 3 0104de   	        add	     [esi+8*ebx],eax
3312:077a  66 3 5e         	        pop	     esi

3312:077c  66 3 59         	        pop	     ecx
3312:077e  67 3 e2ac       	        loop	    72d
'REM That was the end of the loop for each match.

3312:0781  0f31         	         5 rdtsc
3312:0783  66 3 a30842     	        mov	     [4208],eax
3312:0787  66 3 89160c42   	        mov	     [420c],edx
3312:078c  e91603       	        jmp	     stop
'REM That was for recording execution finish time.

3312:078f  90           	        nop
3312:0790  90           	        nop
3312:0791  90           	        nop
3312:0792  90           	        nop
3312:0793  90           	        nop
3312:0794  90           	        nop
3312:0795  90           	        nop

'REM Here is the random number generator :
'REM "rnd" generates random numbers in register eax
'REM "rnd" is copied from Robert Hyatt's random number
'REM generator in "utilities.c" which is a part
'REM of his free program "Crafty"
'REM (He used it to generate hash table IDs):
3312:0796  90           rnd:	    nop
3312:0797  66 3 bb17000000 	        mov	     ebx,17
3312:079d  66 3 ba36000000 	        mov	     edx,36
3312:07a3  b93700       	        mov	     cx,37
3312:07a6  90           	        nop
3312:07a7  be0030       	        mov	     si,3000
3312:07aa  bf0030       	        mov	     di,3000
3312:07ad  66 3 67 3 8b04de   	        mov	     eax,[esi+8*ebx]
3312:07b2  67 3 66 3 0104d6   	        add	     [esi+8*edx],eax
3312:07b7  4b           	        dec	     bx
3312:07b8  7903         	        jns	     7bd
3312:07ba  bb3600       	        mov	     bx,36
3312:07bd  4a           	        dec	     dx
3312:07be  7903         	        jns	     7c3
3312:07c0  ba3600       	        mov	     dx,36
3312:07c3  e2e8         	        loop	    7ad
3312:07c5  90           	        nop
3312:07c6  90           	        nop
3312:07c7  c3           	        ret
3312:07c8  90           	        nop
'REM Thats the end of the program.


 d x55 6e0
Here is the coeficient array called "x55" used in the above program.

3312:0600  f4 d5 14 54 30 53 93 b3-27 3e 77 d0 82 a1 62 ac
&#8992;&#9554;.T0Sô&#9474;'>w&#9576;éíb¼
3312:0610  92 0c b2 5d ac 18 e6 c1-6a 92 03 d0 b3 a3 1f 17
Æ.&#9619;]¼.µ&#9524;jÆ.&#9576;&#9474;ú..
3312:0620  01 21 d1 9a c1 72 21 76-c3 9d 5d bc 70 2a b7 07
.!&#9572;Ü&#9524;r!v&#9500;¥]&#9565;p*&#9558;.
3312:0630  90 c8 5a 6e d1 54 be f7-fa 32 63 0d be 8f ba 56
É&#9562;Zn&#9572;T&#9563;&#8776;•2c.&#9563;Å&#9553;V
3312:0640  ec 85 a5 eb c5 21 14 57-79 c0 b3 96 92 9b eb 12
&#8734;àÑ&#948;&#9532;!.Wy&#9492;&#9474;ûÆ¢&#948;.
3312:0650  78 09 7c c0 bd c5 00 07-13 35 a4 31 aa a4 eb 74
x.|&#9492;&#9564;&#9532;...5ñ1ñ&#948;t
3312:0660  b5 5d c5 4e e9 c2 91 2c-f6 71 87 20 04 e2 4e 30
&#9569;]&#9532;N&#920;&#9516;æ,÷qç .&#915;N0
3312:0670  73 46 00 1e f9 22 ac f3-eb 1f 56 a8 35 34 d1 de
sF..&#8729;"¼&#8804;&#948;.V¿54&#9572;&#9616;
3312:0680  13 75 3e d0 c2 6b e6 da-e1 0b c2 01 97 89 63 46
.u>&#9576;&#9516;kµ&#9484;ß.&#9516;.ùëcF
3312:0690  62 ce 26 fb c3 7f f8 01-99 60 01 c0 70 92 42 44
b&#9580;&&#8730;&#9500;°.Ö`.&#9492;pÆBD
3312:06a0  81 44 4f b0 d7 8a 1b f3-46 7a dd 86 91 20 e7 03
üDO&#9617;&#9579;è.&#8804;Fz&#9612;åæ &#964;.
3312:06b0  89 25 a2 96 d4 b7 dc 74-03 fc d0 12 e8 90 4a 47
ë%óû&#9560;&#9558;&#9604;t.&#8319;&#9576;.&#934;ÉJG
3312:06c0  7c ff f5 2f 92 ed bd 54-87 94 3a 78 8c 97 67 e7   |
&#8993;/Æ&#966;&#9564;Tçö:xîùg&#964;
3312:06d0  cd d5 52 30 91 a1 ec 16-15 6d af 8e dd dd dd dd
&#9552;&#9554;R0æí&#8734;..m»Ä&#9612;&#9612;&#9612;&#9612;
3312:06e0  90
 q
(End of program and data)

Here is the Theoretical and experimental data produced by
the programs above:


                     (After 10,000,000 matches):
                     (With Probability Ratio of .6237 for White to win.)
Number of White      Theoretical  Experimental  Experimental
Wins per             outcome      outcome       outcome
each match(="n"):    for "n":     for "100-n":  for "n"
==========================================================================
50                   821699       (823153)      823153
51                   804525       805157        803365
52                   755117       753009        756603
53                   679385       680519        678344
54                   585885       587044        585463
55                   484234       482899        484001
56                   383517       383030        383595
57                   291021       291419        290359
58                   211537       211395        211549
59                   147254       146946        147571
60                    98140        98336         98541
61                    62601        63001         63208
62                    38206        38150         38069
63                    22301        22647         22274
64                    12444        12388         12268
65                     6635         6534          6614
66                     3378         3295          3392
67                     1642         1662          1607
68                      761          757           735
69                      336          336           334
70                      142          153           129
71                       57           51            52
72                       22           16            21
73                        8           11             8
74                        3            1             1
75                        1            0             1
76                        0            0             0
(76 to 100 are all zero)

summing all the above (without rounding to integer)
(before multiplying by 10,000,000)
from 85 to 100 gives the answer 4.99769099966...*10^-14
(finally) to the question that was posted:

The probability ( or "strangeness") of a computer
(randomized in some way to prevent bad ruts,
 (if possible?))
winning 85 (or higher) out of 100 games
from one of equal strength
(or against an identical computer, say) ,
and assuming that the "Probability Ratio"
for White to win is .6237,
is (certainly) equal to


4.99769099966...*10^-14.


(With a probability ratio of .5 that is
 easier to solve and gives
 2.41271075197..*10^-13
 (or if the smooth "Gamma function(n-1)" was
 used in place of "Factorial" with
 a continuous integral it gives
 2.313..*10-13))

THE END

I found that thanks to help from:

George Tsavdaris
Angrim
William H. Rogers
Remi Coulom
Dieter Buerssner
Robert Hyatt's Crafty code




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.