1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
class StatisticalTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function setUp() |
12
|
|
|
{ |
13
|
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @dataProvider providerAVEDEV |
18
|
|
|
* |
19
|
|
|
* @param mixed $expectedResult |
20
|
|
|
*/ |
21
|
|
|
public function testAVEDEV($expectedResult, ...$args) |
22
|
|
|
{ |
23
|
|
|
$result = Statistical::AVEDEV(...$args); |
24
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function providerAVEDEV() |
28
|
|
|
{ |
29
|
|
|
return require 'data/Calculation/Statistical/AVEDEV.php'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @dataProvider providerAVERAGE |
34
|
|
|
* |
35
|
|
|
* @param mixed $expectedResult |
36
|
|
|
*/ |
37
|
|
|
public function testAVERAGE($expectedResult, ...$args) |
38
|
|
|
{ |
39
|
|
|
$result = Statistical::AVERAGE(...$args); |
40
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function providerAVERAGE() |
44
|
|
|
{ |
45
|
|
|
return require 'data/Calculation/Statistical/AVERAGE.php'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @dataProvider providerAVERAGEA |
50
|
|
|
* |
51
|
|
|
* @param mixed $expectedResult |
52
|
|
|
*/ |
53
|
|
|
public function testAVERAGEA($expectedResult, ...$args) |
54
|
|
|
{ |
55
|
|
|
$result = Statistical::AVERAGEA(...$args); |
56
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function providerAVERAGEA() |
60
|
|
|
{ |
61
|
|
|
return require 'data/Calculation/Statistical/AVERAGEA.php'; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @dataProvider providerAVERAGEIF |
66
|
|
|
* |
67
|
|
|
* @param mixed $expectedResult |
68
|
|
|
*/ |
69
|
|
|
public function testAVERAGEIF($expectedResult, ...$args) |
70
|
|
|
{ |
71
|
|
|
$result = Statistical::AVERAGEIF(...$args); |
72
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function providerAVERAGEIF() |
76
|
|
|
{ |
77
|
|
|
return require 'data/Calculation/Statistical/AVERAGEIF.php'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @dataProvider providerBETADIST |
82
|
|
|
* |
83
|
|
|
* @param mixed $expectedResult |
84
|
|
|
*/ |
85
|
|
|
public function testBETADIST($expectedResult, ...$args) |
86
|
|
|
{ |
87
|
|
|
$result = Statistical::BETADIST(...$args); |
88
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function providerBETADIST() |
92
|
|
|
{ |
93
|
|
|
return require 'data/Calculation/Statistical/BETADIST.php'; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @dataProvider providerBETAINV |
98
|
|
|
* |
99
|
|
|
* @param mixed $expectedResult |
100
|
|
|
*/ |
101
|
|
|
public function testBETAINV($expectedResult, ...$args) |
102
|
|
|
{ |
103
|
|
|
$result = Statistical::BETAINV(...$args); |
104
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function providerBETAINV() |
108
|
|
|
{ |
109
|
|
|
return require 'data/Calculation/Statistical/BETAINV.php'; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @dataProvider providerBINOMDIST |
114
|
|
|
* |
115
|
|
|
* @param mixed $expectedResult |
116
|
|
|
*/ |
117
|
|
|
public function testBINOMDIST($expectedResult, ...$args) |
118
|
|
|
{ |
119
|
|
|
$result = Statistical::BINOMDIST(...$args); |
120
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function providerBINOMDIST() |
124
|
|
|
{ |
125
|
|
|
return require 'data/Calculation/Statistical/BINOMDIST.php'; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @dataProvider providerCHIDIST |
130
|
|
|
* |
131
|
|
|
* @param mixed $expectedResult |
132
|
|
|
*/ |
133
|
|
|
public function testCHIDIST($expectedResult, ...$args) |
134
|
|
|
{ |
135
|
|
|
$result = Statistical::CHIDIST(...$args); |
136
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function providerCHIDIST() |
140
|
|
|
{ |
141
|
|
|
return require 'data/Calculation/Statistical/CHIDIST.php'; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @dataProvider providerCHIINV |
146
|
|
|
* |
147
|
|
|
* @param mixed $expectedResult |
148
|
|
|
*/ |
149
|
|
|
public function testCHIINV($expectedResult, ...$args) |
150
|
|
|
{ |
151
|
|
|
$result = Statistical::CHIINV(...$args); |
152
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function providerCHIINV() |
156
|
|
|
{ |
157
|
|
|
return require 'data/Calculation/Statistical/CHIINV.php'; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @dataProvider providerCONFIDENCE |
162
|
|
|
* |
163
|
|
|
* @param mixed $expectedResult |
164
|
|
|
*/ |
165
|
|
|
public function testCONFIDENCE($expectedResult, ...$args) |
166
|
|
|
{ |
167
|
|
|
$result = Statistical::CONFIDENCE(...$args); |
168
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function providerCONFIDENCE() |
172
|
|
|
{ |
173
|
|
|
return require 'data/Calculation/Statistical/CONFIDENCE.php'; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @dataProvider providerCORREL |
178
|
|
|
* |
179
|
|
|
* @param mixed $expectedResult |
180
|
|
|
*/ |
181
|
|
|
public function testCORREL($expectedResult, array $xargs, array $yargs) |
182
|
|
|
{ |
183
|
|
|
$result = Statistical::CORREL($xargs, $yargs); |
184
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function providerCORREL() |
188
|
|
|
{ |
189
|
|
|
return require 'data/Calculation/Statistical/CORREL.php'; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @dataProvider providerCOUNTIF |
194
|
|
|
* |
195
|
|
|
* @param mixed $expectedResult |
196
|
|
|
*/ |
197
|
|
|
public function testCOUNTIF($expectedResult, ...$args) |
198
|
|
|
{ |
199
|
|
|
$result = Statistical::COUNTIF(...$args); |
200
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function providerCOUNTIF() |
204
|
|
|
{ |
205
|
|
|
return require 'data/Calculation/Statistical/COUNTIF.php'; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @dataProvider providerCOUNTIFS |
210
|
|
|
* |
211
|
|
|
* @param mixed $expectedResult |
212
|
|
|
*/ |
213
|
|
|
public function testCOUNTIFS($expectedResult, ...$args) |
214
|
|
|
{ |
215
|
|
|
$result = Statistical::COUNTIFS(...$args); |
216
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
public function providerCOUNTIFS() |
220
|
|
|
{ |
221
|
|
|
return require 'data/Calculation/Statistical/COUNTIFS.php'; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @dataProvider providerCOVAR |
226
|
|
|
* |
227
|
|
|
* @param mixed $expectedResult |
228
|
|
|
*/ |
229
|
|
|
public function testCOVAR($expectedResult, ...$args) |
230
|
|
|
{ |
231
|
|
|
$result = Statistical::COVAR(...$args); |
232
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
public function providerCOVAR() |
236
|
|
|
{ |
237
|
|
|
return require 'data/Calculation/Statistical/COVAR.php'; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @dataProvider providerFORECAST |
242
|
|
|
* |
243
|
|
|
* @param mixed $expectedResult |
244
|
|
|
*/ |
245
|
|
|
public function testFORECAST($expectedResult, ...$args) |
246
|
|
|
{ |
247
|
|
|
$result = Statistical::FORECAST(...$args); |
248
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
public function providerFORECAST() |
252
|
|
|
{ |
253
|
|
|
return require 'data/Calculation/Statistical/FORECAST.php'; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @dataProvider providerINTERCEPT |
258
|
|
|
* |
259
|
|
|
* @param mixed $expectedResult |
260
|
|
|
*/ |
261
|
|
|
public function testINTERCEPT($expectedResult, array $xargs, array $yargs) |
262
|
|
|
{ |
263
|
|
|
$result = Statistical::INTERCEPT($xargs, $yargs); |
264
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
public function providerINTERCEPT() |
268
|
|
|
{ |
269
|
|
|
return require 'data/Calculation/Statistical/INTERCEPT.php'; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @dataProvider providerMAXIFS |
274
|
|
|
* |
275
|
|
|
* @param mixed $expectedResult |
276
|
|
|
*/ |
277
|
|
|
public function testMAXIFS($expectedResult, ...$args) |
278
|
|
|
{ |
279
|
|
|
$result = Statistical::MAXIFS(...$args); |
280
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function providerMAXIFS() |
284
|
|
|
{ |
285
|
|
|
return require 'data/Calculation/Statistical/MAXIFS.php'; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @dataProvider providerMINIFS |
290
|
|
|
* |
291
|
|
|
* @param mixed $expectedResult |
292
|
|
|
*/ |
293
|
|
|
public function testMINIFS($expectedResult, ...$args) |
294
|
|
|
{ |
295
|
|
|
$result = Statistical::MINIFS(...$args); |
296
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
public function providerMINIFS() |
300
|
|
|
{ |
301
|
|
|
return require 'data/Calculation/Statistical/MINIFS.php'; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @dataProvider providerRSQ |
306
|
|
|
* |
307
|
|
|
* @param mixed $expectedResult |
308
|
|
|
*/ |
309
|
|
|
public function testRSQ($expectedResult, array $xargs, array $yargs) |
310
|
|
|
{ |
311
|
|
|
$result = Statistical::RSQ($xargs, $yargs); |
312
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
public function providerRSQ() |
316
|
|
|
{ |
317
|
|
|
return require 'data/Calculation/Statistical/RSQ.php'; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @dataProvider providerSLOPE |
322
|
|
|
* |
323
|
|
|
* @param mixed $expectedResult |
324
|
|
|
*/ |
325
|
|
|
public function testSLOPE($expectedResult, array $xargs, array $yargs) |
326
|
|
|
{ |
327
|
|
|
$result = Statistical::SLOPE($xargs, $yargs); |
328
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
public function providerSLOPE() |
332
|
|
|
{ |
333
|
|
|
return require 'data/Calculation/Statistical/SLOPE.php'; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* @dataProvider providerSTEYX |
338
|
|
|
* |
339
|
|
|
* @param mixed $expectedResult |
340
|
|
|
*/ |
341
|
|
|
public function testSTEYX($expectedResult, array $xargs, array $yargs) |
342
|
|
|
{ |
343
|
|
|
$result = Statistical::STEYX($xargs, $yargs); |
344
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function providerSTEYX() |
348
|
|
|
{ |
349
|
|
|
return require 'data/Calculation/Statistical/STEYX.php'; |
350
|
|
|
} |
351
|
|
|
} |
352
|
|
|
|