PHPackages                             hichxm/hyperloglog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hichxm/hyperloglog

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hichxm/hyperloglog
==================

A PHP implementation of the HyperLogLog algorithm.

v1.1.5(1mo ago)135↓83.3%MITPHPPHP ^7.0|^7.1|^7.2|^7.3|^7.4|^8.0|^8.1|^8.2|^8.3|^8.4|^8.5CI passing

Since Jul 3Pushed 1mo agoCompare

[ Source](https://github.com/hichxm/HyperLogLog)[ Packagist](https://packagist.org/packages/hichxm/hyperloglog)[ RSS](/packages/hichxm-hyperloglog/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (0)

HyperLogLog for PHP
===================

[](#hyperloglog-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/224bf3a029ea134b7f36ff9fa57a5bae451363227b2a323fe79ff94ca86743a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68696368786d2f68797065726c6f676c6f673f6c6162656c3d76657273696f6e)](https://camo.githubusercontent.com/224bf3a029ea134b7f36ff9fa57a5bae451363227b2a323fe79ff94ca86743a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68696368786d2f68797065726c6f676c6f673f6c6162656c3d76657273696f6e)[![Supported PHP Versions](https://camo.githubusercontent.com/53c466ed495fd5728ef630bbad678e962b7e534151b2324f831a490ab371dc84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f68696368786d2f68797065726c6f676c6f672f7068703f6c6f676f3d706870)](https://camo.githubusercontent.com/53c466ed495fd5728ef630bbad678e962b7e534151b2324f831a490ab371dc84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f68696368786d2f68797065726c6f676c6f672f7068703f6c6f676f3d706870)

[![Tests](https://camo.githubusercontent.com/e9ee6fad738d5b7d1ed5a5f1c08b5f845991419dab5ea66c84ea337a7e8ec5ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68696368786d2f68797065726c6f676c6f672f746573742d616e616c797a652d7461672d72656c656173652e796d6c3f6c6162656c3d7465737473266c6f676f3d676974687562)](https://camo.githubusercontent.com/e9ee6fad738d5b7d1ed5a5f1c08b5f845991419dab5ea66c84ea337a7e8ec5ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68696368786d2f68797065726c6f676c6f672f746573742d616e616c797a652d7461672d72656c656173652e796d6c3f6c6162656c3d7465737473266c6f676f3d676974687562)

A lightweight and dependency-free PHP implementation of the **HyperLogLog** probabilistic data structure for **approximate cardinality estimation**.

HyperLogLog allows you to estimate the number of **distinct elements** in very large datasets while using only a small, fixed amount of memory.

View on Packagist: [hichxm/hyperloglog](https://packagist.org/packages/hichxm/hyperloglog)

Features
--------

[](#features)

- 🚀 Fast approximate distinct counting
- 📦 Zero dependencies
- 🔧 Configurable number of registers (`counterBits`)
- 🔐 Configurable hashing algorithm (`xxh3`, `sha256`, `md5`, etc.)
- 📊 Theoretical error rate calculation
- 🧮 Small and large cardinality bias corrections
- ✅ Strict types and fully documented source code

When to Use HyperLogLog
-----------------------

[](#when-to-use-hyperloglog)

HyperLogLog is well suited for:

- Counting unique visitors
- Counting unique IP addresses
- Analytics pipelines
- Large log processing
- Stream processing
- Database statistics
- Big data applications

It is **not** appropriate when an exact distinct count is required.

Requirements
------------

[](#requirements)

- **PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5**
- No external dependencies

> **Note:** The `xxh3` and `xxh128` hash algorithms are available only when supported by your PHP version and build. If unavailable, you can use any other algorithm returned by `hash_algos()`, such as `sha256`, `sha512`, or `md5`.

Installation
------------

[](#installation)

Install via Composer:

```
composer require hichxm/hyperloglog
```

Basic Usage
-----------

[](#basic-usage)

```
