How to resolve the algorithm Permutation test step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Permutation test step by step in the zkl 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 zkl programming language

Source code in the zkl programming language

fcn permutationTest(a,b){
   ab    := a.extend(b);
   tObs  := a.sum(0);
   combs := Utils.Helpers.pickNFrom(a.len(),ab);  // 92,378
   under := combs.reduce('wrap(sum,perm){ sum+(perm.sum(0) <= tObs) },0);
   100.0 * under / combs.len();
}
 
treatmentGroup := T(85, 88, 75, 66, 25, 29, 83, 39, 97);
controlGroup   := T(68, 41, 10, 49, 16, 65, 32, 92, 28, 98);
under          := permutationTest(treatmentGroup, controlGroup);
println("Under =%6.2f%%\nOver  =%6.2f%%".fmt(under, 100.0 - under));

  

You may also check:How to resolve the algorithm XML/XPath step by step in the Ruby programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Associative array/Creation step by step in the RLaB programming language
You may also check:How to resolve the algorithm Harshad or Niven series step by step in the VBScript programming language
You may also check:How to resolve the algorithm Palindrome dates step by step in the jq programming language