Verify distribution uniformity/Naive: Difference between revisions
Content added Content deleted
(Added Wren) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 25: | Line 25: | ||
*[[Verify distribution uniformity/Chi-squared test]] |
*[[Verify distribution uniformity/Chi-squared test]] |
||
<br><br> |
<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}}== |
=={{header|Ada}}== |