|
15 | 15 | )->toThrow(InvalidDataInputException::class); |
16 | 16 | }); |
17 | 17 |
|
| 18 | +it('calculates fmean (static)', function () { |
| 19 | + expect( |
| 20 | + Stat::mean([1, 2, 3, 4, 4]), |
| 21 | + )->toEqual(2.8); |
| 22 | + expect( |
| 23 | + Stat::mean([-1.0, 2.5, 3.25, 5.75]), |
| 24 | + )->toEqual(2.625); |
| 25 | + expect( |
| 26 | + fn() => Stat::mean([]), |
| 27 | + )->toThrow(InvalidDataInputException::class); |
| 28 | + expect( |
| 29 | + Stat::fmean([3.5, 4.0, 5.25]), |
| 30 | + )->toBeFloat()->toEqual(4.25); |
| 31 | + expect( |
| 32 | + Stat::fmean([85, 92, 83, 91], [0.20, 0.20, 0.30, 0.30], 2), |
| 33 | + )->toBeFloat()->toEqual(87.6); |
| 34 | + expect( |
| 35 | + Stat::fmean([3.5, 4.0, 5.25], [1, 2, 1]), |
| 36 | + )->toBeFloat()->toEqual(4.1875); |
| 37 | + expect( |
| 38 | + Stat::fmean([3.5, 4.0, 5.25], precision: 2), |
| 39 | + )->toBeFloat()->toEqual(4.25); |
| 40 | + expect( |
| 41 | + Stat::fmean([3.5, 4.0, 5.25], [1, 2, 1], precision: 3), |
| 42 | + )->toBeFloat()->toEqual(4.188); |
| 43 | + |
| 44 | +}); |
| 45 | + |
18 | 46 | it('calculates median (static)', function () { |
19 | 47 | expect( |
20 | 48 | Stat::median([1, 3, 5]), |
|
0 commit comments