Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,9 +1,8 @@
import std.stdio, std.algorithm, std.array, combinations3;
auto permutationTest(T)(in T[] a, in T[] b) /*pure nothrow*/ {
auto permutationTest(T)(in T[] a, in T[] b) pure nothrow @safe {
immutable tObs = a.sum;
//auto combs = combinations!false(a ~ b, a.length); // Not a Range.
const combs = combinations(a ~ b, a.length).array; // Slow.
auto combs = combinations!false(a ~ b, a.length);
immutable under = combs.count!(perm => perm.sum <= tObs);
return under * 100.0 / combs.length;
}

View file

@ -1,12 +1,12 @@
import std.stdio, std.algorithm, std.range;
void main() @safe {
import std.stdio, std.algorithm, std.range;
void main() {
immutable treatment = [85, 88, 75, 66, 25, 29, 83, 39, 97];
immutable control = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98];
immutable both = treatment ~ control;
immutable sTreat = treatment.sum;
T pick(T)(in size_t at, in size_t remain, in T accu) pure nothrow {
T pick(T)(in size_t at, in size_t remain, in T accu) pure nothrow @safe @nogc {
if (remain == 0)
return accu > sTreat;