| @@ 352-361 (lines=10) @@ | ||
| 349 | * |
|
| 350 | * @return void |
|
| 351 | */ |
|
| 352 | public function testVariancePopulationIntegers() |
|
| 353 | { |
|
| 354 | $values = [2, 4, 4, 4, 5, 5, 7, 9]; |
|
| 355 | $sample = false; |
|
| 356 | ||
| 357 | $result = Statistics::variance($values, $sample); |
|
| 358 | $expected = 4; |
|
| 359 | ||
| 360 | $this->assertSame($expected, $result); |
|
| 361 | } |
|
| 362 | ||
| 363 | /** |
|
| 364 | * Tests `variance`. |
|
| @@ 421-430 (lines=10) @@ | ||
| 418 | * |
|
| 419 | * @return void |
|
| 420 | */ |
|
| 421 | public function testStandardDeviationSampleFloats() |
|
| 422 | { |
|
| 423 | $values = [1.5, 2.5, 2.5, 2.75, 3.25, 4.75]; |
|
| 424 | $sample = true; |
|
| 425 | ||
| 426 | $result = Statistics::standardDeviation($values, $sample); |
|
| 427 | $expected = 1.081087; |
|
| 428 | ||
| 429 | $this->assertEquals($expected, $result, '', pow(10, -4)); |
|
| 430 | } |
|
| 431 | ||
| 432 | /** |
|
| 433 | * Tests `standardDeviation`. |
|
| @@ 439-448 (lines=10) @@ | ||
| 436 | * |
|
| 437 | * @return void |
|
| 438 | */ |
|
| 439 | public function testStandardDeviationPopulationIntegers() |
|
| 440 | { |
|
| 441 | $values = [2, 4, 4, 4, 5, 5, 7, 9]; |
|
| 442 | $sample = false; |
|
| 443 | ||
| 444 | $result = Statistics::standardDeviation($values, $sample); |
|
| 445 | $expected = 2.0; |
|
| 446 | ||
| 447 | $this->assertSame($expected, $result); |
|
| 448 | } |
|
| 449 | ||
| 450 | /** |
|
| 451 | * Tests `standardDeviation`. |
|
| @@ 457-466 (lines=10) @@ | ||
| 454 | * |
|
| 455 | * @return void |
|
| 456 | */ |
|
| 457 | public function testStandardDeviationPopulationFloats() |
|
| 458 | { |
|
| 459 | $values = [1.5, 2.5, 2.5, 2.75, 3.25, 4.75]; |
|
| 460 | $sample = false; |
|
| 461 | ||
| 462 | $result = Statistics::standardDeviation($values, $sample); |
|
| 463 | $expected = 0.9868; |
|
| 464 | ||
| 465 | $this->assertEquals($expected, $result, '', pow(10, -4)); |
|
| 466 | } |
|
| 467 | ||
| 468 | /** |
|
| 469 | * Tests `range`. |
|