# Julia equivalent of boost accumulator

**URL:** <https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733>\
**Category:** Statistics\
**Tags:** package\
**Created:** [November 26, 2023, 8:39am UTC](https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733 "2023-11-26T08:39:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yue-Zhengyuan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yue-zhengyuan/32/220439_2.png) [@Yue-Zhengyuan](https://discourse.julialang.org/u/Yue-Zhengyuan)\
**Post date:** [November 26, 2023, 8:39am UTC](https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733/1 "2023-11-26T08:39:32Z")

</div>

Is there a Julia package similar to [boost accumulator](https://www.boost.org/doc/libs/1_83_0/doc/html/accumulators/user_s_guide.html) of C++? The boost accumulator can calculate the statistical properties (average, standard error, etc) of a data stream on the fly without storing all datas.

---

<div class="post-metadata">

**Author:** ![RomeoV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romeov/32/37687_2.png) [@RomeoV](https://discourse.julialang.org/u/RomeoV)\
**Post date:** [November 26, 2023, 10:06am UTC](https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733/2 "2023-11-26T10:06:33Z")

</div>

Check out [`OnlineStats.jl`](https://github.com/joshday/OnlineStats.jl) or [`RollingFunctions.jl`](https://github.com/JeffreySarnoff/RollingFunctions.jl).

---

<div class="post-metadata">

**Author:** ![RomeoV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romeov/32/37687_2.png) [@RomeoV](https://discourse.julialang.org/u/RomeoV)\
**Post date:** [November 26, 2023, 10:09am UTC](https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733/3 "2023-11-26T10:09:40Z")

</div>

By the way, I’ve found the [JuliaHub AskAI](https://juliahub.com/ui/AskAI) GPT based ChatBot to be very useful for these questions. Feeding it your “prompt” yields

> Yes, there is a Julia package called OnlineStats that provides functionality similar to the boost accumulator in C++. OnlineStats allows you to perform statistical calculations on streaming or large datasets using online algorithms. These algorithms process data one observation at a time and use O(1) memory, which means they can calculate statistical properties on the fly without storing all the data.

> OnlineStats provides a wide range of statistical functions, including mean, variance, standard deviation, quantiles, histograms, and more. It also supports various types of data, such as numerical, categorical, and time series data.

> To use OnlineStats, you can install it by running `] add OnlineStats` in the Julia package manager. Once installed, you can import the package and create an accumulator object to perform the desired calculations. Here’s a simple example that calculates the mean and standard deviation of a data stream:

```julia
using OnlineStats

# Create an accumulator for mean and standard deviation
acc = Mean() + Variance()

# Process data stream
for observation in data_stream
    fit!(acc, observation)
end

# Get the calculated mean and standard deviation
mean_val = mean(acc)
std_dev = std(acc)

```

> In this example, `Mean()` and `Variance()` are accumulator objects provided by OnlineStats. The `fit!` function is used to update the accumulator with each observation from the data stream. Finally, you can retrieve the calculated mean and standard deviation using the `mean` and `std` functions, respectively.

> OnlineStats is a powerful package that allows you to perform various statistical calculations on streaming or large datasets efficiently. It provides similar functionality to the boost accumulator in C++ and is a great choice for real-time or memory-efficient statistical analysis in Julia.

Use this answer at your own discretion.

---

<div class="post-metadata">

**Author:** ![Yue-Zhengyuan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yue-zhengyuan/32/220439_2.png) [@Yue-Zhengyuan](https://discourse.julialang.org/u/Yue-Zhengyuan)\
**Post date:** [November 26, 2023, 10:15am UTC](https://discourse.julialang.org/t/julia-equivalent-of-boost-accumulator/106733/4 "2023-11-26T10:15:04Z")

</div>

`OnlineStats.jl` is exactly what I need. Thanks! (and I feel stupid for not asking GPT first lol)
