Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Permutation-test/Sidef/permutation-test.sidef
Normal file
20
Task/Permutation-test/Sidef/permutation-test.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
func statistic(ab, a) {
|
||||
var(sumab, suma) = (ab.sum, a.sum);
|
||||
suma/a.size - ((sumab-suma) / (ab.size-a.size))
|
||||
}
|
||||
|
||||
func permutationTest(a, b) {
|
||||
var ab = (a + b);
|
||||
var tobs = statistic(ab, a);
|
||||
var under = (var count = 0);
|
||||
ab.combinations(a.len).each { |perm|
|
||||
statistic(ab, perm) <= tobs && (under += 1);
|
||||
count += 1;
|
||||
};
|
||||
under * 100 / count;
|
||||
}
|
||||
|
||||
var treatmentGroup = [85, 88, 75, 66, 25, 29, 83, 39, 97];
|
||||
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));
|
||||
Loading…
Add table
Add a link
Reference in a new issue