This library is a PHP based implementation for estimating cardinalities.
Following cardinality estimators are implemented:
- HyperLogLog (approx. cardinality estimation but very low memory usage)
- Exact (exact cardinality estimation but very high memory usage)
- PHP ^8.1
The library can be installed from a command line interface by using composer.
composer require ropi/cardinality-estimation
<?php
$estimator = new \Ropi\CardinalityEstimation\HyperLogLogCardinalityEstimator();
for ($i = 0; $i < 1000020; $i++) {
$estimator->addValue((string) $i);
}
$estimator->estimate(); // Returns 995265 as approximated value