Verify distribution uniformity/Naive: Difference between revisions

Updated D entry
m (whitespace)
(Updated D entry)
Line 206:
 
=={{header|D}}==
<lang d>import std.stdio, std.string, std.math:, std.algorithm, absstd.traits;
import std.string: format;
import std.stdio: writeln;
import std.algorithm: sort;
 
/**
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}}==