Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Permutation-test/Julia/permutation-test-1.julia
Normal file
28
Task/Permutation-test/Julia/permutation-test-1.julia
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Combinatorics
|
||||
|
||||
meandiff(a::Vector{T}, b::Vector{T}) where T <: Real = mean(a) - mean(b)
|
||||
|
||||
function bifurcate(a::AbstractVector, sel::Vector{T}) where T <: Integer
|
||||
x = a[sel]
|
||||
asel = trues(length(a))
|
||||
asel[sel] = false
|
||||
y = a[asel]
|
||||
return x, y
|
||||
end
|
||||
|
||||
function permutation_test(treated::Vector{T}, control::Vector{T}) where T <: Real
|
||||
effect0 = meandiff(treated, control)
|
||||
pool = vcat(treated, control)
|
||||
tlen = length(treated)
|
||||
plen = length(pool)
|
||||
better = worse = 0
|
||||
for subset in combinations(1:plen, tlen)
|
||||
t, c = bifurcate(pool, subset)
|
||||
if effect0 < meandiff(t, c)
|
||||
better += 1
|
||||
else
|
||||
worse += 1
|
||||
end
|
||||
end
|
||||
return better, worse
|
||||
end
|
||||
13
Task/Permutation-test/Julia/permutation-test-2.julia
Normal file
13
Task/Permutation-test/Julia/permutation-test-2.julia
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
const treated = [85, 88, 75, 66, 25, 29, 83, 39, 97]
|
||||
const control = [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]
|
||||
|
||||
(better, worse) = permutation_test(treated, control)
|
||||
|
||||
tot = better + worse
|
||||
|
||||
println("Permutation test using the following data:")
|
||||
println("Treated: ", treated)
|
||||
println("Control: ", control)
|
||||
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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue