Thread Zufalls-LOTTO-Zahlen (9 answers)
Opened by pax77 at 2008-01-29 19:55

Taulmarill
 2008-01-31 15:07
#105401 #105401
User since
2004-02-19
1750 Artikel
BenutzerIn

user image
@topeg: deine art Pseudozufallszahlen zu erzeugen, erzeugt keine gleichmäßige Verteilung. Bei folgendem Script:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my @num = 0..9;
my %res;

for ( 1 .. 1_000_000 ) {
    $res{ $num[ rand @num ] }++;
}
print "Test 1:\n";
print "$_ => $res{$_}\n" for @num;

print "\n";
%res = ();

for ( 1 .. 1_000_000 ) {
    $res{ int( rand($#num) + 0.5 ) }++;
}
print "Test 2:\n";
print "$_ => $res{$_}\n" for @num;

bekomme ich folgendes Ergebnis:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Test 1:
0 => 99890
1 => 99720
2 => 100091
3 => 99762
4 => 100083
5 => 99604
6 => 99967
7 => 100189
8 => 99925
9 => 100769

Test 2:
0 => 55212
1 => 110670
2 => 111032
3 => 111548
4 => 110812
5 => 111082
6 => 111016
7 => 111557
8 => 111592
9 => 55479
$_=unpack"B*",~pack"H*",$_ and y&1|0& |#&&print"$_\n"for@.=qw BFA2F7C39139F45F78
0A28104594444504400 0A2F107D54447DE7800 0A2110453444450500 73CF1045138445F4800 0
F3EF2044E3D17DE 8A08A0451412411 F3CF207DF41C79E 820A20451412414 83E93C4513D17D2B

View full thread Zufalls-LOTTO-Zahlen