Anonymous user
Verify distribution uniformity/Naive: Difference between revisions
Verify distribution uniformity/Naive (view source)
Revision as of 22:24, 27 March 2012
, 12 years agoUpdated D entry
m (whitespace) |
(Updated D entry) |
||
Line 206:
=={{header|D}}==
<lang d>import std.stdio, std.string, std.math
/**
Line 215 ⟶ 212:
+/- delta % of repeats/bincount.
*/
void distCheck(TF)(in TF func, in int nRepeats, in double delta)
if (isCallable!TF) {
int[int] counts;
foreach (i; 0 .. nRepeats)
Line 231 ⟶ 229:
writeln(k, " ", counts[k]);
writeln();
}
version (distCheck_demo) {
void main() {
import std.random;
distCheck(() => uniform(1, 6), 1_000_000, 1);
}
}</lang>
If compiled with -version=distCheck_demo:
{{out}}
<pre>1 199389
2 200195
3 199976
4 200016
5 200424</pre>
=={{header|Fortran}}==
|