Re: RND Contest (3)



On 24 Feb 2006 08:14:08 -0800, "\\\~\o/~///annabee"
<faq@xxxxxxxxxxxxxx> wrote:

Here is the tests with ENT for aVb two routines,
the light one first, then the complete one.

G:\...>ent test5.bin
Entropy = 7.949142 bits per byte.

Optimum compression would reduce the size
of this 4000 byte file by 0 percent.

Chi square distribution for 4000 samples is 265.47, and randomly
would exceed this value 50.00 percent of the times.

Arithmetic mean value of data bytes is 127.6893 (127.5 = random).
Monte Carlo value for Pi is 3.147147147 (error 0.18 percent).
Serial correlation coefficient is -0.010268 (totally uncorrelated =
0.0).

_______________

G:\...>ent test6.bin
Entropy = 7.939788 bits per byte.

Optimum compression would reduce the size
of this 4000 byte file by 0 percent.

Chi square distribution for 4000 samples is 316.80, and randomly
would exceed this value 0.50 percent of the times.

Arithmetic mean value of data bytes is 125.4270 (127.5 = random).
Monte Carlo value for Pi is 3.231231231 (error 2.85 percent).
Serial correlation coefficient is 0.017971 (totally uncorrelated =
0.0).


Hope I did not screw up something.

i have change something for doing these routines more random
because they change their seed 1 time over 0FFFh times each

; AVB


[base: d$ 729705821, 117058121, 142896521, 77731121, 168277221,
172637321, 415378721, 337878321, 41537821, 124366521,
33767221, 34578721, 97845421, 41875421, 98111921,
4457821 ]
[seed: d$ 12333, 4432223, 233322, 435454, 71358, 45737,
314573, 782598, 787472, 9828, 972811, 718455,
70844, 7810454, 41544, 711877 ]
[seed0: d$ 123, 4578, 43745, 4913, 12585, 44312
7874, 1548, 15789, 5848, 7844, 34566, 784841,
457121
784123, 7848, ]
[conta: d$ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[index: d$ 0, 0]
[index1: d$ 0, 0]
[basea: d$ 31415821]
[seeda: d$ 123]
[dieci: d$ 10, 0]
[cento: d$ 100, 0]
[ora: d$ 0, 0]


; uint _RND_lineare_m()
; dd, .base=31415821, .seed=123;
_RND_lineare_m:
push edx
mov eax, D$basea
mul D$seeda
inc eax
mov D$seeda, eax
pop edx
ret


; uint RND_MultiL(base, seed, seed0)
; 0 b, 4 r, 8 c, 12 Ra, 16@Base, 20@Seed, 24@Seed0
_RND_MultiL:
push ecx
push edx
push ebx

mov edx, D$esp+16
mov ecx, D$esp+20
mov ebx, D$edx
mov eax, D$ecx
mul ebx
inc eax
mov edx, D$esp+24
mov edx, D$edx
mov D$ecx, eax
cmp eax, edx
jne c0>
call _RND_lineare_m
xor eax, ebx
test eax, 1
jnz l0>
inc eax
l0: ; cambia base ma dispari
mov edx, D$esp+16
mov D$edx, eax
call _RND_lineare_m ; cambia seed0
mov edx, D$esp+24
xor D$edx, eax
mov eax, D$esp+20 ; cambia seed=seed0 e lo ritorna
mov edx, D$edx
mov D$eax, edx
mov eax, edx
c0:
pop ebx
pop edx
pop ecx
ret 12

; eax:uint RND_Multiineare(void);
; risultato in eax numero pseudocasuale tra 0 e 0x7FFFFFFF
_RND_Multilinear_m:
push ebx
push ecx
push edx
push esi
mov eax, D$index1
lea ebx, D$base+ eax*4
lea ecx, D$seed+ eax*4
lea edx, D$seed0+eax*4
inc D$conta+eax*4 ; ogli xxx volte cambia il seed
mov esi, D$conta+eax*4
and esi, 0FFFh
cmp esi, 0FFFh
jne b0>
pushad
call 'KERNEL32.GetTickCount'
and eax, 0FFFFh
mov D$ora, eax
popad
mov eax, D$ecx
and eax, 0FFFF0000h
or eax, D$ora
b0:
push edx
push ecx
push ebx
call _RND_MultiL
mov ebx, eax
mov cl, ah
shr ebx, 1
and ecx, 0Fh
and ebx, 0Fh
cmp ebx, D$index1
jne c0>
inc ebx
and ebx, 0Fh
c0: ; 0..7<->24..31, 8..15<->16..23
bswap eax
test eax, 080000000h
jz c2>
or ax, 080h
and eax, 07FFFFFFFh
c2:
xor eax, D$seed + ebx*4
mov D$index1, ecx
..c1:
and eax, 07FFFFFFFh
pop esi
pop edx
pop ecx
pop ebx
ret

; eax:uint _RND_RangeMLineare_m(uint max)
; risultato in eax numero pseudocasuale tra min e max
; 0 r, 4 c, 8 Ra, 12 @Max
AVB_RND_RangeMLineare_m:
push ecx
push edx
call _RND_Multilinear_m
mov ecx, D$esp+12
cmp ecx, 0
jne c0>
inc ecx
c0:
mov edx, 0
div ecx
mov eax, edx
pop edx
pop ecx
ret 4
---------------------------

/* eax:uint RND_Multiineare(void);
/* risultato in eax numero pseudocasuale tra 0 e 0x7FFFFFFF
_RND_Multilinear_m:
< b, c, r, i
a=*index1
b= &[base+ 4*a]; c= &[seed+ 4*a]; r= &[seed0+ 4*a];
++D[conta+4*a]; /* ogli xxx volte cambia il seed
i=[conta+4*a]; i&=0FFFh; i==0FFFh!#.b0;
{ pushad
*GetTickCount();
a&=0FFFFh; D[ora]=a;
popad
a=*c; a&=0FFFF0000h; a|=D[ora];
}
..b0: RND_MultiL(b, c, r);
b=a; cl=ah; b>>=1; c&=0Fh; b&=0Fh;
b==[index1]!#.c0;
{++b; b&=0Fh;}
..c0: bswap a; /* 0..7<->24..31, 8..15<->16..23
a & 0x80000000 | jz .cil
{ax|=0x80; a&=0x7FFFFFFF;}
..cil: a^=[seed + 4*b]; *index1=c;
..c1: a&=0x7FFFFFFF;
b, c, r, i
ret

.



Relevant Pages