How to resolve the algorithm Permutation test step by step in the Seed7 programming language
How to resolve the algorithm Permutation test step by step in the Seed7 programming language
Table of Contents
Problem Statement
A new medical treatment was tested on a population of
n + m
{\displaystyle n+m}
volunteers, with each volunteer randomly assigned either to a group of
n
{\displaystyle n}
treatment subjects, or to a group of
m
{\displaystyle m}
control subjects.
Members of the treatment group were given the treatment,
and members of the control group were given a placebo.
The effect of the treatment or placebo on each volunteer
was measured and reported in this table.
Write a program that performs a
permutation test to judge
whether the treatment had a significantly stronger effect than the
placebo.
Extremely dissimilar values are evidence of an effect not entirely due to chance, but your program need not draw any conclusions. You may assume the experimental data are known at compile time if that's easier than loading them at run time. Test your solution on the data given above.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Permutation test step by step in the Seed7 programming language
Source code in the seed7 programming language
$ 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;
You may also check:How to resolve the algorithm Power set step by step in the ATS programming language
You may also check:How to resolve the algorithm Cullen and Woodall numbers step by step in the Lua programming language
You may also check:How to resolve the algorithm Hickerson series of almost integers step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Prime decomposition step by step in the V programming language
You may also check:How to resolve the algorithm String case step by step in the 360 Assembly programming language