Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,51 +0,0 @@
|
|||
with Ada.Numerics.Discrete_Random, Ada.Text_IO;
|
||||
|
||||
procedure Naive_Random is
|
||||
|
||||
type M_1000 is mod 1000;
|
||||
package Rand is new Ada.Numerics.Discrete_Random(M_1000);
|
||||
Gen: Rand.Generator;
|
||||
|
||||
procedure Perform(Modulus: Positive; Expected, Margin: Natural;
|
||||
Passed: out boolean) is
|
||||
Low: Natural := (100-Margin) * Expected/100;
|
||||
High: Natural := (100+Margin) * Expected/100;
|
||||
Buckets: array(0 .. Modulus-1) of Natural := (others => 0);
|
||||
Index: Natural;
|
||||
begin
|
||||
for I in 1 .. Expected * Modulus loop
|
||||
Index := Integer(Rand.Random(Gen)) mod Modulus;
|
||||
Buckets(Index) := Buckets(Index) + 1;
|
||||
end loop;
|
||||
Passed := True;
|
||||
for I in Buckets'Range loop
|
||||
Ada.Text_IO.Put("Bucket" & Integer'Image(I+1) & ":" &
|
||||
Integer'Image(Buckets(I)));
|
||||
if Buckets(I) < Low or else Buckets(I) > High then
|
||||
Ada.Text_IO.Put_Line(" (failed)");
|
||||
Passed := False;
|
||||
else
|
||||
Ada.Text_IO.Put_Line(" (passed)");
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end Perform;
|
||||
|
||||
Number_Of_Buckets: Positive := Natural'Value(Ada.Text_IO.Get_Line);
|
||||
Expected_Per_Bucket: Natural := Natural'Value(Ada.Text_IO.Get_Line);
|
||||
Margin_In_Percent: Natural := Natural'Value(Ada.Text_IO.Get_Line);
|
||||
OK: Boolean;
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put_Line( "Buckets:" & Integer'Image(Number_Of_Buckets) &
|
||||
", Expected:" & Integer'Image(Expected_Per_Bucket) &
|
||||
", Margin:" & Integer'Image(Margin_In_Percent));
|
||||
Rand.Reset(Gen);
|
||||
|
||||
Perform(Modulus => Number_Of_Buckets,
|
||||
Expected => Expected_Per_Bucket,
|
||||
Margin => Margin_In_Percent,
|
||||
Passed => OK);
|
||||
|
||||
Ada.Text_IO.Put_Line("Test Passed? (" & Boolean'Image(OK) & ")");
|
||||
end Naive_Random;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
-- 28 Jul 2025
|
||||
include Settings
|
||||
-- 24 Aug 2025
|
||||
include Setting
|
||||
parse arg xx','yy','zz
|
||||
if xx = '' then
|
||||
xx = 'Random'
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
Option Explicit
|
||||
|
||||
sub verifydistribution(calledfunction, samples, delta)
|
||||
Dim i, n, maxdiff
|
||||
'We could cheat via Dim d(7), but "7" wasn't mentioned in the Task. Heh.
|
||||
Dim d : Set d = CreateObject("Scripting.Dictionary")
|
||||
wscript.echo "Running """ & calledfunction & """ " & samples & " times..."
|
||||
for i = 1 to samples
|
||||
Execute "n = " & calledfunction
|
||||
d(n) = d(n) + 1
|
||||
next
|
||||
n = d.Count
|
||||
maxdiff = 0
|
||||
wscript.echo "Expected average count is " & Int(samples/n) & " across " & n & " buckets."
|
||||
for each i in d.Keys
|
||||
dim diff : diff = abs(1 - d(i) / (samples/n))
|
||||
if diff > maxdiff then maxdiff = diff
|
||||
wscript.echo "Bucket " & i & " had " & d(i) & " occurences" _
|
||||
& vbTab & " difference from expected=" & FormatPercent(diff, 2)
|
||||
next
|
||||
wscript.echo "Maximum found variation is " & FormatPercent(maxdiff, 2) _
|
||||
& ", desired limit is " & FormatPercent(delta, 2) & "."
|
||||
if maxdiff > delta then wscript.echo "Skewed!" else wscript.echo "Smooth!"
|
||||
end sub
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
verifydistribution "dice7", 1000, 0.03
|
||||
verifydistribution "dice7", 100000, 0.03
|
||||
Loading…
Add table
Add a link
Reference in a new issue