-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
72 lines (58 loc) · 1.59 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
testSum () {
sum=`perl -ML -e '@a=(1..5);print sum @a'`
assertEquals $sum 15
}
testMax () {
max=`perl -ML -e '@a=(1..5);print max @a'`
assertEquals $max 5
}
testMin () {
min=`perl -ML -e '@a=(1..5);print min @a'`
assertEquals $min 1
}
testPercentile () {
percentile1=`perl -ML -e '@a=(0..100);print percentile @a,30'`
assertEquals $percentile1 30
percentile1=`perl -ML -e '@a=(0..100);print percentile @a,60'`
assertEquals $percentile1 60
}
testMean () {
mean=`perl -ML -e '@a=(1,2,3,3,4,5,6,7,14);print mean @a'`
assertEquals $mean 5
}
testMedian () {
median=`perl -ML -e '@a=(1,2,3,3,4,5,6,7,14);print median @a'`
assertEquals $median 4
}
testQ1 (){
q1=`perl -ML -e '@a=(0..100);print q1 @a'`
assertEquals $q1 25
}
testQ3 (){
q3=`perl -ML -e '@a=(0..100);print q3 @a'`
assertEquals $q3 75
}
testUniq () {
uniq1=`perl -ML -e '@a=(1,2,3,3,4);print uniq @a'`
assertEquals $uniq1 1234
uniq2=`perl -ML -e '@a=(1,3,3,4,1,2);print uniq @a'`
assertEquals $uniq2 1342
}
testSd () {
sd=`perl -ML -e '@a=(1..10);printf("%.3f", sd @a)'`
assertEquals $sd 3.028
}
testCv () {
cv=`perl -ML -e '@a=(-5,-4,7.5,8.7,3.4,9.4,0.8,1.5,2.6,0.9,0.6,9.4,8.4,6.6,9.4);printf("%.3f", cv @a)'`
assertEquals $cv 1.215
}
testZscore () {
zscore=`perl -ML -e '@a=(-5,-4,-2,-1,-1,0,2,2,3,3,4);@z=zscore @a;printf "%0.3f",$z[0]'`
assertEquals $zscore -1.707
}
testCor () {
cor=`perl -ML -e '@a=(100,82,89,0);@b=(26,10,5,1);printf "%0.3f", cor(\@a,\@b)'`
assertEquals $cor 0.677
}
. shunit2-source/2.1.6/src/shunit2