Verify distribution uniformity/Naive: Difference between revisions

Added zkl
m (→‎{{header|REXX}}: added an execution note.)
(Added zkl)
Line 1,270:
Maximum found variation is 0.94%, desired limit is 3.00%.
Smooth!
 
=={{header|zkl}}==
This tests the random spread over 0..9. It starts at 10 samples and doubles the sample size until the spread is within 0.1% of 10% for each bucket.
<lang zkl>fcn rtest(N){
dist:=L(0,0,0,0,0,0,0,0,0,0);
do(N){n:=(0).random(10); dist[n]=dist[n]+1}
sum:=dist.sum();
dist=dist.apply('wrap(n){n.toFloat()/sum*100});
if (dist.filter((10.0).closeTo.fp1(0.1)).len() == 10)
{ "Good enough at %,d: %s".fmt(N,dist).println(); return(True); }
False
}
 
n:=10;
while(not rtest(n)) {n*=2}</lang>
{{out}}
Reported numbers is the percent that bucket has of all samples.
<pre>
Good enough at 163,840:
L(10.0665,9.94019,10.0146,9.99939,10.0775,10.0201,9.93713,10.0775,9.9054,9.96155)
</pre>
 
 
{{omit from|GUISS}}
Anonymous user