Package to help estimate stats based on partial data and historic averages.
Example:
- given the average rainfall in December in 20 cities for the last 5 years (e.g.86 mm for Brussels, ...)
- when I have the rainfall this year for 15 of those cities,
- estimate the other 5 cities
You can install the package via 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
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email author_email instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.