Skip to content

ro-pi/cardinality-estimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Cardinality estimation library for PHP

Resources

License

Stars

Watchers

Forks

Languages