ropi/cardinality-estimation

Cardinality estimation

Installs: 71

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/ropi/cardinality-estimation

v0.2.0 2022-03-29 20:35 UTC

This package is auto-updated.

Last update: 2025-09-16 01:22:18 UTC


README

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