wesleyk079/statistic_functionalities

包含两个类的库:Correlation & Deviation。这些类可以用来计算标准差和斯皮尔曼等级相关系数。

dev-master 2019-01-24 10:36 UTC

This package is auto-updated.

Last update: 2024-09-25 08:13:35 UTC


README

此存储库是为涉及NewCompliance B.V集团软件的解决方案而创建的

此库包含的函数将计算来自JSON文件的偏差和相关性。

包含的示例将展示如何使用此库

安装库

在composer.json中需要库

composer require wesleyk079/statistic_functionalities "dev-master"

确保您的框架或PHP脚本从composer的vendor目录加载'autoload.php'。

#1 偏差

包含库

使用 'statisticFunctionalities\functions\Deviation';

调整所需的选项

//example for setting the options
$options = [
    "FileToCheck"               => json_decode(file_get_contents("../generatedFiles/generatedInformation.json")),
    "KeyToSelect"               => "Verrichting 1",
    "KeyToSearchFor"            => "Operatieduur",
    "RemoveOutliers"            => true,
    "SecondComparison"          => true,
    "SecondKeyToFindDeviation"  => "Geplande duur",
    "FirstCategoryMax"          => 20,
    "MiddleCategoryMax"         => 60,
    "FirstPercentageMeasure"    => 20,
    "MiddlePercentageMeasure"   => 12.5,
    "LastPercentageMeasure"     => 10,
    "PositiveFeedback"          => "Wel goed in te schatten",
    "NegativeFeedback"          => "Niet goed in te schatten"

];

初始化偏差类

$deviation = new statisticFunctions\Deviation($options);

获取结果

$deviationResults = $deviation->GetDeviationStatistics();

我的结果包含什么?

以下键将可用于返回数组中的所有结果

amount - 测量案例的数量

mean - 所有测量数字的平均值

standardDev - 标准差(1次)

statisticMin - 平均值 - (标准差 * 3)

statisticMax - 平均值 + (标准差 * 3)

lowerThanComparison - 小于比较数字的案例数量

higherThanComparison - 大于比较数字的案例数量

Advice - 根据设置(正面或负面反馈)提出的建议。如果(标准差 * 3)小于(平均值 * 百分比),则为正面。百分比将根据类别从percentageMeasure中获取。

如何处理结果示例

foreach($deviationResults as $result){
    <p>
    There were <?= $operation["amount"] ?> cases that included '<?= $caseTitle ?>' as <?= $options["KeyToSelect"] ?>.
        
    The data was divided by a standard deviation of ' ~ <?= intval($operation["standardDev"]) ?>' 
    </p>
    
    <p>
    This means in 68.26% of the cases, <?= $options["KeyToSearchFor"] ?> will be
    between <?= intval($operation["mean"] - $operation["standardDev"] * 1) 
    ?>
}

#2 相关性

更改选项以满足您的个人愿望和设置

包含库

使用 'statisticFunctionalities\functions\Correlation';

调整所需的选项

//example for setting the options
$options = [
    "FileToCheck"           => json_decode(file_get_contents("../generatedFiles/generatedInformation.json")),
    "KeyToSearchFor"        => "Operatieduur",
    "KeyToSelect"           => "Verrichting 1",
    "ValueForKeyToSelect"   => "Verwijderen buisjes uit oren",
    "ExcludeKeywords"       => ["Patiëntnummer", "Casusnummer"]
];

初始化偏差类

$correlation = new statisticFunctions\Correlation($options);

获取结果

$results = $correlation->calculateCorrelations();

我的结果包含什么?

xTitle - 被测量的x轴标题

yTitle - 被测量的y轴标题

coefficient - xTitle和yTitle值的关联系数

如果需要,可以使用这些结果获得建议

<!--Example on how to treat the data-->
<?php foreach ($all as $result): ?>
    <?= $correlation->getCorrelationAdvise($result["coefficient"], $result["xTitle"], $result["yTitle"]); ?><br/><br/>
    //Result: The variable 'Operatieduur' looks like growing when 'Wond open (min)' is higher. The correlation is stated as moderate correlation: 0.51029910576627

<?php endforeach; ?>