Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
verifydistribution "dice7", 1000, 0.03
|
||||
verifydistribution "dice7", 100000, 0.03
|
||||
Loading…
Add table
Add a link
Reference in a new issue