Statistics/Basic: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: removed the last blank line. -- ~~~~) |
(Updated D entry) |
||
Line 530:
return tuple(0.0L, 0.0L);
real sx = 0.0, sxx = 0.0;
ulong n;
foreach (x; numbers) {
Line 540:
}
void
enum maxWidth = 50; // N. characters.
ulong[10] bins;
foreach (x; numbers) {
bins[index]++;
}
immutable real maxFreq = bins.reduce!max
alias std.array.replicate R;
foreach (n, i; bins)
writefln(" %3.1f: %s", n /
R("*", cast(int)(i / maxFreq * maxWidth)));
writeln
}
version (statistics_basic_main) {
writefln(" Mean: %8.6f, SD: %8.6f", n.meanStdDev.tupleof);
n.showHistogram01;
}
}
}</lang>
Compile with "-version=statistics_basic_main" to run the main function.
{{out}}
<pre>10 numbers:
|