PHP code example of ropi / cardinality-estimation

1. Go to this page and download the library: Download ropi/cardinality-estimation 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/ */

    

ropi / cardinality-estimation example snippets



$estimator = new \Ropi\CardinalityEstimation\HyperLogLogCardinalityEstimator();

for ($i = 0; $i < 1000020; $i++) {
    $estimator->addValue((string) $i);
}

$estimator->estimate(); // Returns 995265 as approximated value