jbroadway/distinctelements

用于估计集合中不同元素数量的 Distinct Elements in Streams 算法的纯 PHP 实现。

1.0 2024-05-22 21:17 UTC

This package is auto-updated.

Last update: 2024-09-22 23:21:16 UTC


README

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

这是从以下论文中实现的 Distinct Elements in Streams 算法的纯 PHP 实现,用于估计集合中不同元素的数量:

https://arxiv.org/abs/2301.10191

使用 Composer 安装

composer require jbroadway/distinctelements

用法

<?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