Verify distribution uniformity/Naive: Difference between revisions

Added 11l
(Added Wren)
(Added 11l)
Line 25:
*[[Verify distribution uniformity/Chi-squared test]]
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F dice5()
R random:(1..5)
 
F distcheck(func, repeats, delta)
V bin = DefaultDict[Int, Int]()
L 1..repeats
bin[func()]++
V target = repeats I/ bin.len
V deltacount = Int(delta / 100.0 * target)
assert(all(bin.values().map(count -> abs(@target - count) < @deltacount)), ‘Bin distribution skewed from #. +/- #.: #.’.format(target, deltacount, sorted(bin.items()).map((key, count) -> (key, @target - count))))
print(bin)
 
distcheck(dice5, 1000000, 1)</lang>
 
{{out}}
<pre>
DefaultDict([1 = 199586, 2 = 200094, 3 = 198933, 4 = 200824, 5 = 200563])
</pre>
 
=={{header|Ada}}==
1,480

edits