jbroadway / distinctelements
A pure PHP implementation of the Distinct Elements in Streams algorithm for estimating the number of distinct elements in a set.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/jbroadway/distinctelements
Requires
- php: >=7.2
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2025-09-23 01:39:32 UTC
README
A pure PHP implementation of the Distinct Elements in Streams algorithm for estimating the number of distinct elements in a set, from the following paper:
https://arxiv.org/abs/2301.10191
Install using Composer:
composer require jbroadway/distinctelements
Usage:
<?php require __DIR__ . '/vendor/autoload.php'; $stream = [1, 2, 3, 4, 1, 2, 3, 4, 5, 4, 3, 1, 2]; $epsilon = 0.1; $delta = 0.1; $output = DistinctElements::streaming_algorithm ($stream, $epsilon, $delta); var_dump ($output); // 5