March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -1,7 +1,5 @@
import std.stdio, std.algorithm, std.array, combinations3;
alias sum = reduce!q{a + b};
auto permutationTest(T)(in T[] a, in T[] b) /*pure nothrow*/ {
immutable tObs = a.sum;
//auto combs = combinations!false(a ~ b, a.length); // Not a Range.

View file

@ -4,7 +4,7 @@ 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.reduce!q{a + b};
immutable sTreat = treatment.sum;
T pick(T)(in size_t at, in size_t remain, in T accu) pure nothrow {
if (remain == 0)

View file

@ -0,0 +1,39 @@
$ include "seed7_05.s7i";
include "float.s7i";
const array integer: treatmentGroup is [] (85, 88, 75, 66, 25, 29, 83, 39, 97);
const array integer: controlGroup is [] (68, 41, 10, 49, 16, 65, 32, 92, 28, 98);
const array integer: both is treatmentGroup & controlGroup;
const func integer: pick (in integer: at, in integer: remain, in integer: accu, in integer: treat) is func
result
var integer: picked is 0;
begin
if remain = 0 then
picked := ord(accu > treat);
else
picked := pick(at - 1, remain - 1, accu + both[at], treat);
if at > remain then
picked +:= pick(at - 1, remain, accu, treat);
end if;
end if;
end func;
const proc: main is func
local
var integer: experimentalResult is 0;
var integer: treat is 0;
var integer: total is 1;
var integer: le is 0;
var integer: gt is 0;
var integer: i is 0;
begin
for experimentalResult range treatmentGroup do
treat +:= experimentalResult;
end for;
total := 19 ! 10; # Binomial coefficient
gt := pick(19, 9, 0, treat);
le := total - gt;
writeln("<= : " <& 100.0 * flt(le) / flt(total) digits 6 <& "% " <& le);
writeln(" > : " <& 100.0 * flt(gt) / flt(total) digits 6 <& "% " <& gt);
end func;