Permutation test: Difference between revisions

m
syntax highlighting fixup automation
m (syntax highlighting fixup automation)
Line 57:
{{trans|Kotlin}}
 
<langsyntaxhighlight lang="11l">V data = [85, 88, 75, 66, 25, 29, 83, 39, 97,
68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
 
Line 79:
 
print(‘<= : #.6% #.’.format(100 * le / total, le))
print(‘ > : #.6% #.’.format(100 * gt / total, gt))</langsyntaxhighlight>
 
{{out}}
Line 89:
=={{header|Ada}}==
 
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; with Iterate_Subsets;
 
procedure Permutation_Test is
Line 150:
New_Line;
end;
end Permutation_Test;</langsyntaxhighlight>
 
This solution uses an auxiliary package Iterate_Subsets. Here is the Spec:
<langsyntaxhighlight Adalang="ada">generic
Subset_Size, More_Elements: Positive;
package Iterate_Subsets is
Line 169:
 
end Iterate_Subsets;
</syntaxhighlight>
</lang>
 
And here is the implementation:
 
<langsyntaxhighlight Adalang="ada">package body Iterate_Subsets is
 
function First return Subset is
Line 206:
end Last;
 
end Iterate_Subsets;</langsyntaxhighlight>
 
{{out}}
Line 214:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f PERMUTATION_TEST.AWK
# converted from C
Line 240:
return pick(at-1,remain-1,accu+data[at-1],treat) + ( (at > remain) ? pick(at-1,remain,accu,treat) : 0 )
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 249:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> ntreated% = 9
nplacebo% = 10
DIM results%(ntreated% + nplacebo% - 1)
Line 286:
N% = (N% + (N% >>> 4)) AND &0F0F0F0F
N% += N% >>> 8 : N% += N% >>> 16
= N% AND &7F</langsyntaxhighlight>
{{out}}
<pre>
Line 294:
 
=={{header|C}}==
<langsyntaxhighlight Clang="c">#include <stdio.h>
 
int data[] = { 85, 88, 75, 66, 25, 29, 83, 39, 97,
Line 322:
100 * le / total, le, 100 * gt / total, gt);
return 0;
}</langsyntaxhighlight>
Output:<syntaxhighlight lang="text"><= : 87.197168% 80551
> : 12.802832% 11827</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
{{trans|Java}}
<langsyntaxhighlight lang="cs">using System;
using System.Collections.Generic;
 
Line 364:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>&lt;= 87.1971681569205% 80551
Line 371:
=={{header|C++}}==
This is a translaion of C
<langsyntaxhighlight lang="cpp">#include<iostream>
#include<vector>
#include<numeric>
Line 409:
std::cout << "<= : " << 100.0 * lesser / total << "% " << lesser << std::endl
<< " > : " << 100.0 * greater / total << "% " << greater << std::endl;
}</langsyntaxhighlight>
Output:<syntaxhighlight lang="text"><= : 87.197168% 80551
> : 12.802832% 11827</langsyntaxhighlight>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(defun perm-test (s1 s2)
(let ((more 0) (leq 0)
(all-data (append s1 s2))
Line 437:
(format t "<=: ~a ~6f%~% >: ~a ~6f%~%"
x (* 100e0 (/ x s))
y (* 100e0 (/ y s))))</langsyntaxhighlight>output<syntaxhighlight lang="text"><=: 80551 87.197%
>: 11827 12.803%</langsyntaxhighlight>
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio, std.algorithm, std.array, combinations3;
 
auto permutationTest(T)(in T[] a, in T[] b) pure nothrow @safe {
Line 455:
immutable under = permutationTest(treatmentGroup, controlGroup);
writefln("Under =%6.2f%%\nOver =%6.2f%%", under, 100.0 - under);
}</langsyntaxhighlight>
{{out}}
<pre>Under = 87.20%
Line 462:
Alternative version:
{{trans|C}}
<langsyntaxhighlight lang="d">void main() @safe {
import std.stdio, std.algorithm, std.range;
 
Line 485:
writefln(" > : %2.2f%% %d", 100.0 * gt / t, gt);
writefln("<= : %2.2f%% %d", 100.0 * le / t, le);
}</langsyntaxhighlight>
{{out}}
<pre> > : 12.80% 11827
Line 492:
{{libheader| System.SysUtils}}
{{Trans|Go}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Permutation_test;
 
Line 574:
 
{$IFNDEF UNIX} readln; {$ENDIF}
end.</langsyntaxhighlight>
 
=={{header|Elixir}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="elixir">defmodule Permutation do
def statistic(ab, a) do
sumab = Enum.sum(ab)
Line 605:
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
under = Permutation.test(treatmentGroup, controlGroup)
:io.fwrite "under = ~.2f%, over = ~.2f%~n", [under, 100-under]</langsyntaxhighlight>
 
{{out}}
Line 613:
 
=={{header|GAP}}==
<langsyntaxhighlight lang="gap">a := [85, 88, 75, 66, 25, 29, 83, 39, 97];
b := [68, 41, 10, 49, 16, 65, 32, 92, 28, 98];
 
Line 663:
# in order, % less or greater than original diff
PermTest(a, b);
[ "87.197", "12.802" ]</langsyntaxhighlight>
 
 
=={{header|FreeBASIC}}==
{{trans|Phix}}
<langsyntaxhighlight lang="freebasic">
Dim Shared datos(18) As Integer => {85, 88, 75, 66, 25, 29, 83, 39, 97,_
68, 41, 10, 49, 16, 65, 32, 92, 28, 98}
Line 700:
Print Using " > : ##.######% #####"; 100*gt/total; gt
Sleep
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 710:
=={{header|Go}}==
A version doing all math in integers until computing final percentages.
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 781:
}
rc(0, 0)
}</langsyntaxhighlight>
{{out}}
<pre>
Line 789:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">binomial n m = (f !! n) `div` (f !! m) `div` (f !! (n - m))
where f = scanl (*) 1 [1..]
 
Line 809:
[68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
in do putStr "> : "; print r
putStr "<=: "; print $ 100 - r</langsyntaxhighlight>
{{out}}
<pre>
Line 817:
 
Somewhat faster, this goes from top down:
<langsyntaxhighlight lang="haskell">binomial n m = (f !! n) `div` (f !! m) `div` (f !! (n - m))
where f = scanl (*) 1 [1..]
 
Line 835:
(a, b) = perms [85, 88, 75, 66, 25, 29, 83, 39, 97]
[68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
lt = (fromIntegral a) / (fromIntegral b) * 100</langsyntaxhighlight>
 
In cases where the sample data are a large number of relatively small positive integers, counting number of partial sums is a lot faster:
<langsyntaxhighlight lang="haskell">combs maxsum len x = foldl f [(0,0,1)] x where
f a n = merge a (map (addNum n) $ filter (\(l,_,_) -> l < len) a)
addNum n (a,s,c)
Line 863:
-- how many combinations are less than current sum
main = print$ permtest [85, 88, 75, 66, 25, 29, 83, 39, 97]
[68, 41, 10, 49, 16, 65, 32, 92, 28, 98]</langsyntaxhighlight>
 
=={{header|J}}==
<langsyntaxhighlight lang="j">require'stats'
trmt=: 0.85 0.88 0.75 0.66 0.25 0.29 0.83 0.39 0.97
ctrl=: 0.68 0.41 0.1 0.49 0.16 0.65 0.32 0.92 0.28 0.98
Line 873:
all=: trmt(#@[ ({. difm }.) |:@([ (comb ~.@,"1 i.@])&# ,) { ,) ctrl
smoutput 'under: ','%',~":100*mean all <: result
smoutput 'over: ','%',~":100*mean all > result</langsyntaxhighlight>
 
Result:
<syntaxhighlight lang="text">under: 87.1972%
over: 12.8028%</langsyntaxhighlight>
 
=={{header|Java}}==
{{trans|Kotlin}}
<langsyntaxhighlight Javalang="java">public class PermutationTest {
private static final int[] data = new int[]{
85, 88, 75, 66, 25, 29, 83, 39, 97,
Line 910:
System.out.printf(" > : %f%% %d\n", 100.0 * gt / total, gt);
}
}</langsyntaxhighlight>
{{out}}
<pre><= : 87.197168% 80551
Line 918:
{{works with|jq|1.4}}
'''Part 1: Combinations'''
<langsyntaxhighlight lang="jq"># combination(r) generates a stream of combinations of r items from the input array.
def combination(r):
if r > length or r < 0 then empty
Line 925:
( .[1:]|combination(r))
end;
</syntaxhighlight>
</lang>
'''Part 2: Permutation Test'''
<langsyntaxhighlight lang="jq"># a and b should be arrays:
def permutationTest(a; b):
 
Line 952:
| .[1] += 1 )
| .[0] * 100.0 / .[1] # under/count
;</langsyntaxhighlight>
'''Example:'''
<langsyntaxhighlight lang="jq">def treatmentGroup: [85, 88, 75, 66, 25, 29, 83, 39, 97];
def controlGroup: [68, 41, 10, 49, 16, 65, 32, 92, 28, 98];
 
permutationTest(treatmentGroup; controlGroup) as $under
| "% under=\($under)", "% over=\(100 - $under)"</langsyntaxhighlight>
{{out}}
$ jq -n -r -f permutation_test.jq
Line 969:
 
'''Functions'''
<langsyntaxhighlight lang="julia">using Combinatorics
 
meandiff(a::Vector{T}, b::Vector{T}) where T <: Real = mean(a) - mean(b)
Line 996:
end
return better, worse
end</langsyntaxhighlight>
 
'''Main'''
<langsyntaxhighlight lang="julia">const treated = [85, 88, 75, 66, 25, 29, 83, 39, 97]
const control = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
 
Line 1,011:
println("\nThere are $tot different permuted groups of these data.")
@printf("%8d, %5.2f%% showed better than actual results.\n", better, 100 * better / tot)
print(@sprintf("%8d, %5.2f%% showed equalivalent or worse results.", worse, 100 * worse / tot))</langsyntaxhighlight>
 
{{out}}
Line 1,024:
=={{header|Kotlin}}==
{{trans|C}}
<langsyntaxhighlight lang="scala">// version 1.1.2
 
val data = intArrayOf(
Line 1,047:
System.out.printf("<= : %f%% %d\n", 100.0 * le / total, le)
System.out.printf(" > : %f%% %d\n", 100.0 * gt / total, gt)
}</langsyntaxhighlight>
 
{{out}}
Line 1,057:
=={{header|M2000 Interpreter}}==
{{trans|C}}
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module Checkit {
Global data(), treat=0
Line 1,075:
}
Checkit
</syntaxhighlight>
</lang>
{{out}}
<pre><= : 87.2% 80551
Line 1,083:
Slower version, using a lambda function with a series of inner lambda functions to return each combination at a time.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckThis {
Function CombinationsStep (a, nn) {
Line 1,128:
}
CheckThis
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight lang="mathematica">"<=: " <> ToString[#1] <> " " <> ToString[100. #1/#2] <> "%\n >: " <>
ToString[#2 - #1] <> " " <> ToString[100. (1 - #1/#2)] <> "%" &[
Count[Total /@ Subsets[Join[#1, #2], {Length@#1}],
n_ /; n <= Total@#1],
Binomial[Length@#1 + Length@#2, Length@#1]] &[{85, 88, 75, 66, 25,
29, 83, 39, 97}, {68, 41, 10, 49, 16, 65, 32, 92, 28, 98}]</langsyntaxhighlight>
{{out}}
<pre><=: 80551 87.1972%
Line 1,143:
=={{header|Nim}}==
{{trans|C}}
<langsyntaxhighlight lang="nim">import strformat
 
const data = [85, 88, 75, 66, 25,
Line 1,170:
le = int(total - float(gt))
echo fmt"<= : {100.0 * float(le) / total:.6f}% {le}"
echo fmt" > : {100.0 * float(gt) / total:.6f}% {gt}"</langsyntaxhighlight>
{{out}}
<pre>
Line 1,178:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
use warnings;
use strict;
Line 1,261:
92
28
98</langsyntaxhighlight>
{{out}}
equal 313 0.339%
Line 1,269:
=={{header|Phix}}==
{{Trans|C}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">constant</span> <span style="color: #000000;">data</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">85</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">88</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">75</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">66</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">25</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">29</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">83</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">39</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">97</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">68</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">41</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">10</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">49</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">16</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">65</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">32</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">92</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">28</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">98</span> <span style="color: #0000FF;">}</span>
Line 1,290:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"&lt;= : %f%% %d\n &gt; : %f%% %d\n"</span><span style="color: #0000FF;">,</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">100</span><span style="color: #0000FF;">*</span><span style="color: #000000;">le</span><span style="color: #0000FF;">/</span><span style="color: #000000;">total</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">le</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">100</span><span style="color: #0000FF;">*</span><span style="color: #000000;">gt</span><span style="color: #0000FF;">/</span><span style="color: #000000;">total</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">gt</span><span style="color: #0000FF;">})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,298:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/simul.l") # For 'subsets'
 
(scl 2)
Line 1,329:
 
(let N (permutationTest *TreatmentGroup *ControlGroup)
(prinl "under = " (round N) "%, over = " (round (- 100.0 N)) "%") )</langsyntaxhighlight>
{{out}}
<pre>under = 87.85%, over = 12.15%</pre>
Line 1,344:
the treatment group or the control group
 
<syntaxhighlight lang="purebasic">
<lang PureBasic>
 
Define.f meanTreated,meanControl,diffInMeans
Line 1,436:
Debug StrF(100*diffLessOrEqual/TotalComBinations,2)+" "+Str(diffLessOrEqual)
Debug StrF(100*diffGreater /TotalComBinations,2)+" "+Str(diffGreater)
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,446:
=={{header|Python}}==
{{trans|Tcl}}
<langsyntaxhighlight lang="python">from itertools import combinations as comb
 
def statistic(ab, a):
Line 1,465:
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
under = permutationTest(treatmentGroup, controlGroup)
print("under=%.2f%%, over=%.2f%%" % (under, 100. - under))</langsyntaxhighlight>
{{out}}
<pre>under=89.11%, over=10.89%</pre>
 
The above solution does a different thing than the other solutions. I'm not really sure why. If you want to do the same thing as the other solutions, then this is the solution:
<langsyntaxhighlight lang="python">from itertools import combinations as comb
 
def permutationTest(a, b):
Line 1,484:
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
under = permutationTest(treatmentGroup, controlGroup)
print("under=%.2f%%, over=%.2f%%" % (under, 100. - under))</langsyntaxhighlight>
{{out}}
<pre>under=87.20%, over=12.80%</pre>
Line 1,490:
=={{header|R}}==
 
<langsyntaxhighlight lang="r">permutation.test <- function(treatment, control) {
perms <- combinations(length(treatment)+length(control),
length(treatment),
Line 1,497:
p <- mean(rowMeans(perms) <= mean(treatment))
c(under=p, over=(1-p))
}</langsyntaxhighlight>
 
<langsyntaxhighlight lang="r">> permutation.test(c(85, 88, 75, 66, 25, 29, 83, 39, 97),
+ c(68, 41, 10, 49, 16, 65, 32, 92, 28, 98))
under over
0.8719717 0.1280283 </langsyntaxhighlight>
 
=={{header|Racket}}==
{{trans|Common Lisp}}
 
<langsyntaxhighlight Racketlang="racket">#lang racket/base
 
(define-syntax-rule (inc! x)
Line 1,532:
more (real->decimal-string (* 100. (/ more sum)) 2)
leq (real->decimal-string (* 100. (/ leq sum)) 2))))
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,545:
{{works with|Rakudo|2018.09}}
 
<syntaxhighlight lang="raku" perl6line>sub stats ( @test, @all ) {
([+] @test / +@test) - ([+] flat @all, (@test X* -1)) / @all - @test
}
Line 1,563:
say 'Equal to : %', 100 * @trials[1] / [+] @trials;
say 'Greater than : %', 100 * @trials[2] / [+] @trials;
say 'Less or Equal: %', 100 * ( [+] @trials[0,1] ) / [+] @trials;</langsyntaxhighlight>
 
{{out}}
Line 1,576:
=={{header|REXX}}==
This REXX program is modeled after the &nbsp; '''C''' &nbsp; version, with some generalizations and optimization added.
<langsyntaxhighlight lang="rexx">/*REXX program performs a permutation test on N + M subjects (volunteers): */
/* ↑ ↑ */
/* │ │ */
Line 1,608:
else q= 0
itP= it - 1 /*set temporary var.*/
return picker(itP, rest - 1, eff + #.itP) + q /*recurse. */</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 1,624:
=={{header|Ruby}}==
{{trans|Python}}
<langsyntaxhighlight lang="ruby">def statistic(ab, a)
sumab, suma = ab.inject(:+).to_f, a.inject(:+).to_f
suma / a.size - (sumab - suma) / (ab.size - a.size)
Line 1,643:
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
under = permutationTest(treatmentGroup, controlGroup)
puts "under=%.2f%%, over=%.2f%%" % [under, 100 - under]</langsyntaxhighlight>
 
{{out}}
Line 1,651:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
fn main() {
let treatment = vec![85, 88, 75, 66, 25, 29, 83, 39, 97];
Line 1,705:
combinations(total - data[0], number - 1, &tail) + combinations(total, number, &tail)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,715:
===Imperative version (Ugly, side effects)===
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/69o8tJX/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/jpUyNPetRXabZkEKc68FAA Scastie (remote JVM)].
<langsyntaxhighlight Scalalang="scala">object PermutationTest extends App {
private val data =
Array(85, 88, 75, 66, 25, 29, 83, 39, 97, 68, 41, 10, 49, 16, 65, 32, 92, 28, 98)
Line 1,737:
println(f" > : ${100.0 * gt / total}%f%% ${gt}%d")
 
}</langsyntaxhighlight>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "float.s7i";
 
Line 1,778:
writeln("<= : " <& 100.0 * flt(le) / flt(total) digits 6 <& "% " <& le);
writeln(" > : " <& 100.0 * flt(gt) / flt(total) digits 6 <& "% " <& gt);
end func;</langsyntaxhighlight>
{{out}}
<= : 87.197168% 80551
Line 1,785:
=={{header|Sidef}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="ruby">func statistic(ab, a) {
var(sumab, suma) = (ab.sum, a.sum)
suma/a.size - ((sumab-suma) / (ab.size-a.size))
Line 1,804:
var controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
var under = permutationTest(treatmentGroup, controlGroup)
say ("under=%.2f%%, over=%.2f%%" % (under, 100 - under))</langsyntaxhighlight>
{{out}}
<pre>
Line 1,811:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
 
# Difference of means; note that the first list must be the concatenation of
Line 1,857:
set count [tcl::mathfunc::double $count]
list [expr {$overcount / $count}] [expr {$undercount / $count}]
}</langsyntaxhighlight>
Demonstration code:
<langsyntaxhighlight lang="tcl">set treatmentGroup {0.85 0.88 0.75 0.66 0.25 0.29 0.83 0.39 0.97}
set controlGroup {0.68 0.41 0.10 0.49 0.16 0.65 0.32 0.92 0.28 0.98}
lassign [permutationTest $treatmentGroup $controlGroup] over under
puts [format "under=%.2f%%, over=%.2f%%" [expr {$under*100}] [expr {$over*100}]]</langsyntaxhighlight>
{{out}}
<pre>under=86.90%, over=13.10%</pre>
 
=={{header|Ursala}}==
<langsyntaxhighlight Ursalalang="ursala">#import std
#import nat
#import flo
Line 1,882:
#show+
 
t = --* *-'%'@lrNCC printf/$'%0.2f' times/$100. f(treatment_group,control_group)</langsyntaxhighlight>
{{out}}
<pre>
Line 1,891:
{{trans|C}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight lang="ecmascript">import "/fmt" for Fmt
 
var data = [85, 88, 75, 66, 25, 29, 83, 39, 97, 68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
Line 1,910:
var le = (total - gt).truncate
Fmt.print("<= : $f\% $d", 100 * le / total, le)
Fmt.print(" > : $f\% $d", 100 * gt / total, gt)</langsyntaxhighlight>
 
{{out}}
Line 1,921:
A solution that is not going to scale gracefully at all.
{{trans|D}}
<langsyntaxhighlight lang="zkl">fcn permutationTest(a,b){
ab := a.extend(b);
tObs := a.sum(0);
Line 1,932:
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));</langsyntaxhighlight>
{{out}}
<pre>
10,333

edits