PHP code example of hichxm / hyperloglog

1. Go to this page and download the library: Download hichxm/hyperloglog library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hichxm / hyperloglog example snippets




use Hichxm\HyperLogLog\HyperLogLog;

$hll = new HyperLogLog();

$hll->add('apple');
$hll->add('banana');
$hll->add('orange');
$hll->add('apple'); // duplicate

echo $hll->count();

new HyperLogLog(
    int $counterBits = 5,
    string $hashAlgorithm = 'xxh3'
);

$hll = new HyperLogLog(
    counterBits: 10,
    hashAlgorithm: 'sha256'
);

$error = $hll->theoreticalErrorRate($hll->getM());

print_r(hash_algos());

$hll->add('user-123');

$count = $hll->count();

$error = $hll->theoreticalErrorRate($hll->getM());

$error = $hll->measureError($estimated, $actual);