Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 857 Bytes

File metadata and controls

28 lines (21 loc) · 857 Bytes

Cardinality estimation library for PHP

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)

Requirements

  • PHP ^8.1

Installation

The library can be installed from a command line interface by using composer.

composer require ropi/cardinality-estimation

Basic usage

<?php
$estimator = new \Ropi\CardinalityEstimation\HyperLogLogCardinalityEstimator();

for ($i = 0; $i < 1000020; $i++) {
    $estimator->addValue((string) $i);
}

$estimator->estimate(); // Returns 995265 as approximated value