tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
20
Task/Permutation-test/Python/permutation-test-1.py
Normal file
20
Task/Permutation-test/Python/permutation-test-1.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from itertools import combinations as comb
|
||||
|
||||
def statistic(ab, a):
|
||||
sumab, suma = sum(ab), sum(a)
|
||||
return ( suma / len(a) -
|
||||
(sumab -suma) / (len(ab) - len(a)) )
|
||||
|
||||
def permutationTest(a, b):
|
||||
ab = a + b
|
||||
Tobs = statistic(ab, a)
|
||||
under = 0
|
||||
for count, perm in enumerate(comb(ab, len(a)), 1):
|
||||
if statistic(ab, perm) <= Tobs:
|
||||
under += 1
|
||||
return under * 100. / count
|
||||
|
||||
treatmentGroup = [85, 88, 75, 66, 25, 29, 83, 39, 97]
|
||||
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
|
||||
under = permutationTest(treatmentGroup, controlGroup)
|
||||
print("under=%.2f%%, over=%.2f%%" % (under, 100. - under))
|
||||
15
Task/Permutation-test/Python/permutation-test-2.py
Normal file
15
Task/Permutation-test/Python/permutation-test-2.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from itertools import combinations as comb
|
||||
|
||||
def permutationTest(a, b):
|
||||
ab = a + b
|
||||
Tobs = sum(a)
|
||||
under = 0
|
||||
for count, perm in enumerate(comb(ab, len(a)), 1):
|
||||
if sum(perm) <= Tobs:
|
||||
under += 1
|
||||
return under * 100. / count
|
||||
|
||||
treatmentGroup = [85, 88, 75, 66, 25, 29, 83, 39, 97]
|
||||
controlGroup = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
|
||||
under = permutationTest(treatmentGroup, controlGroup)
|
||||
print("under=%.2f%%, over=%.2f%%" % (under, 100. - under))
|
||||
Loading…
Add table
Add a link
Reference in a new issue