summaryrefslogtreecommitdiff
path: root/modules/statistics/tests/unit_tests/trimmean.tst
blob: 7abf15a616f232853535f591225bebd0de206edd (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2008 - INRIA - Michael Baudin
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

// With x as a vector and 1 argument
data = [10, 20, 30, 40, 50, 60, 70, 80, 4000];
computed = trimmean(data);
expected = 50;
if abs(computed-expected)>%eps then pause,end
// With x as a vector and 2 arguments
data = [10, 20, 30, 40, 50, 60, 70, 80, 4000];
computed = trimmean(data,25);
expected = 50;
if abs(computed-expected)>%eps then pause,end
// With x as a matrix and 2 arguments
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,25);
expected = 45;
if abs(computed-expected)>%eps then pause,end
// With x as a vector and specified orient
data = [10, 20, 30, 40, 50, 60, 70, 80, 4000];
computed = trimmean(data,25,"all");
expected = 50;
if abs(computed-expected)>%eps then pause,end
// With x as a matrix and specified orient
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,25,"all");
expected = 45;
if abs(computed-expected)>%eps then pause,end
// With x as a vector and non-positionnal orien="all"
data = [10, 20, 30, 40, 50, 60, 70, 80, 4000];
computed = trimmean(data,25,orien="all");
expected = 50;
if abs(computed-expected)>%eps then pause,end
// With x as a matrix and non-positionnal orien="all"
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,25,orien="all");
expected = 45;
if abs(computed-expected)>%eps then pause,end
// With x as a matrix and positionnal orien="r"
data = [
10 10 10 10
20 20 20 20
30 30 30 30
4000 4000 4000 4000
];
computed = trimmean(data,50,"r");
expected = [25,25,25,25];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and positionnal orien=1
data = [
10 10 10 10
20 20 20 20
30 30 30 30
4000 4000 4000 4000
];
computed = trimmean(data,50,1);
expected = [25,25,25,25];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and positionnal orien="c"
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,50,"c");
expected = [25;65];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and positionnal orien=2
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,50,2);
expected = [25;65];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and non-positionnal orien="r"
data = [
10 10 10 10
20 20 20 20
30 30 30 30
4000 4000 4000 4000
];
computed = trimmean(data,orien="r",50);
expected = [25,25,25,25];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and non-positionnal orien=1
data = [
10 10 10 10
20 20 20 20
30 30 30 30
4000 4000 4000 4000
];
computed = trimmean(data,orien="r",50);
expected = [25,25,25,25];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and non-positionnal orien="c"
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,orien="c",50);
expected = [25;65];
if norm(computed-expected)>%eps then pause,end
// With x as a matrix and non-positionnal orien=2
data = [
10 20 30 40
50 60 70 4000
];
computed = trimmean(data,orien=2,50);
expected = [25;65];
if norm(computed-expected)>%eps then pause,end
// Test extremal values of discard.
data = [10, 20, 30, 40, 50, 60, 70, 80, 90];
computed = trimmean(data,discard=0);
expected = 50;
if abs(computed-expected)>%eps then pause,end
// Test extremal values of discard.
data = [10, 20, 30, 40, 50, 60, 70, 80, 4000];
computed = trimmean(data,discard=100);
expected = 50;
if abs(computed-expected)>%eps then pause,end