active
library
Accumux
C++20 library for compositional online data reductions
Resources & Distribution
Accumux is a modern C++20 library for compositional online data reductions with mathematical rigor. It provides a framework for combining statistical accumulators using algebraic composition, enabling single-pass computation of complex statistical measures with optimal numerical stability.
Key Features
- Numerically Stable: Kahan-Babuška-Neumaier and Welford algorithms for maximum accuracy
- Single-Pass Efficiency: Compute multiple statistics in O(1) space complexity
- Compositional: Natural algebraic syntax (
a + b
) for combining accumulators - Type Safe: C++20 concepts prevent incorrect compositions at compile-time
- Header-Only: Zero dependencies, easy integration
Usage Example
#include "accumux/accumulators/kbn_sum.hpp"
#include "accumux/accumulators/welford.hpp"
#include "accumux/core/composition.hpp"
using namespace accumux;
// Create composed accumulator for sum + statistics
auto stats = kbn_sum<double>() + welford_accumulator<double>();
// Process data in single pass
for (const auto& value : data) {
stats += value;
}
// Extract results
auto sum = stats.get_first().eval();
auto mean = stats.get_second().mean();
auto variance = stats.get_second().variance();
Core Accumulators
kbn_sum<T>
- Numerically stable summationwelford_accumulator<T>
- Mean, variance, standard deviationminmax_accumulator<T>
- Combined min/max trackingcount_accumulator
- Element countingproduct_accumulator<T>
- Product with overflow protection
Built on solid algebraic foundations (monoids, homomorphisms) with performance benchmarks showing 476M values/sec for single accumulator operations.