Skip to content

A pure PHP implementation of the Distinct Elements in Streams algorithm for estimating the number of distinct elements in a set.

License

Notifications You must be signed in to change notification settings

jbroadway/distinctelements

Repository files navigation

Distinct Elements in Streams

GitHub Workflow Status (branch) GitHub License Packagist Version Packagist PHP Version Support

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

About

A pure PHP implementation of the Distinct Elements in Streams algorithm for estimating the number of distinct elements in a set.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages