CardinalityEstimation 1.14.0

dotnet add package CardinalityEstimation --version 1.14.0
                    
NuGet\Install-Package CardinalityEstimation -Version 1.14.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CardinalityEstimation" Version="1.14.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CardinalityEstimation" Version="1.14.0" />
                    
Directory.Packages.props
<PackageReference Include="CardinalityEstimation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CardinalityEstimation --version 1.14.0
                    
#r "nuget: CardinalityEstimation, 1.14.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CardinalityEstimation@1.14.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CardinalityEstimation&version=1.14.0
                    
Install as a Cake Addin
#tool nuget:?package=CardinalityEstimation&version=1.14.0
                    
Install as a Cake Tool

CardinalityEstimation

HyperLogLog-based set cardinality estimation library

This library estimates the number of unique elements in a set, in a quick and memory-efficient manner. It's based on the following:

  1. Flajolet et al., "HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm", DMTCS proc. AH 2007, http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
  2. Heule, Nunkesser and Hall 2013, "HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm", http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en/us/pubs/archive/40671.pdf

The accuracy/memory usage are user-selectable. Typically, a cardinality estimator will give a perfect estimate of small cardinalities (up to 100 unique elements), and 97% accuracy or better (usually much better) for any cardinality up to near 2^64, while consuming several KB of memory (no more than 16KB).

Usage

Usage is very simple:

ICardinalityEstimator<string> estimator = new CardinalityEstimator();

estimator.Add("Alice");
estimator.Add("Bob");
estimator.Add("Alice");
estimator.Add("George Michael");

ulong numberOfuniqueElements = estimator.Count(); // will be 3

Nuget Package

This code is available as the Nuget package CardinalityEstimation.

To install, run the following command in the Package Manager Console:

Install-Package CardinalityEstimation

Release Notes

Keeping things friendly

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CardinalityEstimation:

Package Downloads
AutoStat

Records statistics for a stream or collection of objects.

CardinalityEstimation.Benchmark

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.14.0 67 9/7/2025
1.13.0 141 9/4/2025
1.12.0 141 9/4/2025
1.11.1 6,470 11/27/2022
1.11.0 6,259 6/26/2022
1.10.0 54,177 2/1/2021
1.9.0 975 11/8/2020
1.8.0 772 10/7/2020
1.7.0 8,823 9/24/2018
1.6.0 3,101 10/23/2017
1.5.0 2,580 7/26/2017
1.4.0 4,819 3/19/2017
1.3.0 1,339 3/13/2017
1.2.1 1,487 8/21/2016
1.2.0 1,846 2/20/2016
1.1.0 1,592 11/18/2015
1.0.1 1,856 2/9/2015
1.0.0 2,068 2/9/2015

Added support for Span/ReadOnlySpan/Memory/ReadOnlyMemory
Added ConcurrentCardinalityEstimator
Updated XML docs