pforret / estimator
PHP包,用于基于历史参考数据帮助进行统计估计(外推)
1.5.5
2022-01-13 20:14 UTC
Requires
- php: ^7.4 | ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.18
README
包,用于基于部分数据和历史平均值进行统计估计。
示例
- 给定过去5年中20个城市12月份的平均降雨量(例如,布鲁塞尔为86毫米,……)
- 当我有这15个城市的今年降雨量时,
- 估计其他5个城市
安装
您可以通过composer安装此包
composer require pforret/estimator
用法
use Pforret\Estimator\Estimator; $est = new Estimator(); $est->set_references($references); // and then $estimated = $est->estimate_from_partials($partials); // or $estimated = $est->estimate_from_total(100);
$evaluation = $est->evaluate_partials($partials);
// references = values set with set_references
[references_count] => 4
[references_maximum] => 25
[references_mean] => 25
[references_median] => 25
[references_minimum] => 25
[references_sum] => 100
// partials = values specified with estimate_from_partials
[partials_maximum] => 28
[partials_mean] => 26
[partials_median] => 25
[partials_minimum] => 25
[partials_multiplier] => 1.04
[partials_sum] => 78
// found = subset of references, matching with partials keys
[found_count] => 3
[found_count_fraction] => 0.75
[found_mean] => 25
[found_sum] => 75
[found_sum_fraction] => 0.75
// stat = statistic evaulation of estimate/extrapolation
[stat_confidence] => 74.913
[stat_deviation] => 3
示例
$references=[
"John" => 100,
"Kevin" => 120,
"Sarah" => 100,
"Vince" => 100,
];
$est = new Estimator();
$est->set_references($references);
$partials=[
"John" => 120,
"Kevin" => 150,
// "Sarah" is to be estimated
"Vince" => 175,
];
$estimation=$est->estimate_from_partials();
/*
[John] => 120
[Kevin] => 150
[Vince] => 175
[Sarah] => 139 <<< estimation
*/
测试
composer test
变更日志
请参阅CHANGELOG了解最近更改的详细信息。
贡献
请参阅CONTRIBUTING了解详细信息。
安全
如果您发现任何与安全相关的问题,请通过author_email而不是使用问题跟踪器发送电子邮件。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件了解更多信息。