PHPackages                             pforret/estimator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pforret/estimator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pforret/estimator
=================

PHP package to help with statistic estimation (extrapolation) based on historic reference data

1.5.5(4y ago)2339MITPHPPHP ^7.4 | ^8.0CI failing

Since Aug 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pforret/estimator)[ Packagist](https://packagist.org/packages/pforret/estimator)[ Docs](https://github.com/pforret/estimator)[ RSS](/packages/pforret-estimator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (11)Used By (0)

Historical Estimator / Extrapolator
===================================

[](#historical-estimator--extrapolator)

Github: [![GitHub tag](https://camo.githubusercontent.com/f1e4fb34604b0dd197a0d0976549f6625e7f39346e260f277c7eb3ee1a5a59c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f70666f727265742f657374696d61746f72)](https://camo.githubusercontent.com/f1e4fb34604b0dd197a0d0976549f6625e7f39346e260f277c7eb3ee1a5a59c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f70666f727265742f657374696d61746f72)[![Tests](https://github.com/pforret/estimator/workflows/Run%20Tests/badge.svg)](https://github.com/pforret/estimator/workflows/Run%20Tests/badge.svg)[![Psalm](https://github.com/pforret/estimator/workflows/Detect%20Psalm%20warnings/badge.svg)](https://github.com/pforret/estimator/workflows/Detect%20Psalm%20warnings/badge.svg)[![Styling](https://github.com/pforret/estimator/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/pforret/estimator/workflows/Check%20&%20fix%20styling/badge.svg)

Packagist: [![Packagist Version](https://camo.githubusercontent.com/04d7b8c949340e271a698e3de8133bf8fc3be6680dd5252aa5e0b549b0e40665/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70666f727265742f657374696d61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pforret/estimator)[![Packagist Downloads](https://camo.githubusercontent.com/54c53c5a307dfd41b1fb8b921383fff2c2c6b426b89cb354552164d3379097bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70666f727265742f657374696d61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pforret/estimator)

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

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require pforret/estimator
```

Usage
-----

[](#usage)

```
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

```

Example
-------

[](#example)

```
$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
