-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor standard deviation to include sample and population (#55)
Standard deviation parameters in full.json, full.php, full.yml and README.md files were renamed for clarity. They now include both sample and population standard deviation. Ensued that this change is correctly reflected in related code and related tests have been added for standard deviation of a population.
- Loading branch information
Showing
8 changed files
with
116 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* JBZoo Toolbox - Csv-Blueprint. | ||
* | ||
* This file is part of the JBZoo Toolbox project. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license MIT | ||
* @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
* @see https://github.com/JBZoo/Csv-Blueprint | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JBZoo\CsvBlueprint\Rules\Aggregate; | ||
|
||
use MathPHP\Statistics\Descriptive; | ||
|
||
final class ComboSdPopulation extends AbstarctAggregateRuleCombo | ||
{ | ||
protected const NAME = 'standard deviation (SD+)'; | ||
|
||
protected const HELP_TOP = [ | ||
'SD+ (Standard deviation for a population; uses population variance)', | ||
]; | ||
|
||
protected function getActualAggregate(array $colValues): ?float | ||
{ | ||
return Descriptive::standardDeviation(self::stringsToFloat($colValues), Descriptive::POPULATION); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* JBZoo Toolbox - Csv-Blueprint. | ||
* | ||
* This file is part of the JBZoo Toolbox project. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license MIT | ||
* @copyright Copyright (C) JBZoo.com, All rights reserved. | ||
* @see https://github.com/JBZoo/Csv-Blueprint | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JBZoo\PHPUnit\Rules\Aggregate; | ||
|
||
use JBZoo\CsvBlueprint\Rules\AbstarctRule as Combo; | ||
use JBZoo\CsvBlueprint\Rules\Aggregate\ComboSdPopulation; | ||
use JBZoo\PHPUnit\Rules\AbstractAggregateRuleCombo; | ||
|
||
use function JBZoo\PHPUnit\isSame; | ||
|
||
class ComboSdPopulationTest extends AbstractAggregateRuleCombo | ||
{ | ||
protected string $ruleClass = ComboSdPopulation::class; | ||
|
||
public function testEqual(): void | ||
{ | ||
$rule = $this->create(2.3570226039552, Combo::EQ); | ||
isSame('', $rule->test([1, 5, 1, 1, 1, 2, 8, 1, 1])); | ||
|
||
$rule = $this->create(3, Combo::EQ); | ||
isSame( | ||
'The standard deviation (SD+) in the column is "2.3570226039552", which is not equal than the expected "3"', | ||
$rule->test([1, 5, 1, 1, 1, 2, 8, 1, 1]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters