# Feedback requested: monoidal-stats

**URL:** <https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833>\
**Category:** Show and Tell\
**Created:** [July 4, 2023, 5:55pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833 "2023-07-04T17:55:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [July 4, 2023, 5:55pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/1 "2023-07-04T17:55:27Z")

</div>

I just pulled this out of the voronoizer code I wrote a few weeks ago, because I ended up wanting it for another side project. Rather than jumping to pollution of hackage, I thought I’d do a quick poll if anyone thinks they’d ever use it.

> **[GitHub - cdsmith/monoidal-stats](https://github.com/cdsmith/monoidal-stats/)**
>
> Contribute to cdsmith/monoidal-stats development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![LaurentRDC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/laurentrdc/32/4950_2.png) [@LaurentRDC](https://discourse.haskell.org/u/LaurentRDC)\
**Post date:** [July 4, 2023, 6:03pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/2 "2023-07-04T18:03:08Z")

</div>

I’m not sure I would use it, but this is very cool!

---

<div class="post-metadata">

**Author:** ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)\
**Post date:** [July 4, 2023, 6:16pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/3 "2023-07-04T18:16:32Z")

</div>

I’m not qualified to compare, but I know that there are several existing libraries for single-pass statistics:

- [monoid-statistics: Monoids for calculation of statistics of sample](https://hackage.haskell.org/package/monoid-statistics)
- [streamly-statistics: Statistical measures for finite or infinite data streams.](https://hackage.haskell.org/package/streamly-statistics)

---

<div class="post-metadata">

**Author:** ![jhenahan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jhenahan/32/3578_2.png) [@jhenahan](https://discourse.haskell.org/u/jhenahan)\
**Post date:** [July 4, 2023, 6:23pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/4 "2023-07-04T18:23:29Z")

</div>

Reminded me of [HLearn](https://izbicki.me/blog/gausian-distributions-are-monoids.html).

---

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [July 4, 2023, 7:15pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/5 "2023-07-04T19:15:20Z")

</div>

Ah, thanks! If nothing else, that reminds me that one of the things I specifically wanted here was statistics on a vector space, which sadly I wasn’t able to find easily usable elsewhere. The packages you link to are indeed a great existing alternative if you are computing statistics on scalars!

---

<div class="post-metadata">

**Author:** ![Vlix](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/vlix/32/1551_2.png) [@Vlix](https://discourse.haskell.org/u/Vlix)\
**Post date:** [July 5, 2023, 12:46pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/6 "2023-07-05T12:46:33Z")

</div>

Would it be possible to add the functionality `monoidal-stats` has into e.g. `monoid-statistics`?

---

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [July 5, 2023, 1:09pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/7 "2023-07-05T13:09:09Z")

</div>

Sounds quite reasonable to me! I filed [Incorporate stats for vector spaces · Issue #8 · Shimuuar/monoid-statistics · GitHub](https://github.com/Shimuuar/monoid-statistics/issues/8) to see there’s interest from the maintainer of that package. It seems recently maintained, so there’s probably reason to be hopeful here.

---

<div class="post-metadata">

**Author:** ![Axman6](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Axman6](https://discourse.haskell.org/u/Axman6)\
**Post date:** [July 5, 2023, 10:55pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/8 "2023-07-05T22:55:24Z")

</div>

Just to jump on the “have you seen”’s, my foldl-statistics package also contains a type ([LMVSKState](https://hackage.haskell.org/package/foldl-statistics-0.1.5.1/docs/Control-Foldl-Statistics.html#v:fastLMVSK)) which computes the length, sum, mean, skewness and kurtosis of a set of Doubles and has a Monoid instance.

---

<div class="post-metadata">

**Author:** ![turion](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/turion/32/989_2.png) [@turion](https://discourse.haskell.org/u/turion)\
**Post date:** [July 6, 2023, 2:55pm UTC](https://discourse.haskell.org/t/feedback-requested-monoidal-stats/6833/9 "2023-07-06T14:55:48Z")

</div>

One thing that I had in mind since some time that seems related: You could have a [finger tree](https://hackage.haskell.org/package/fingertree) indexed by a monoidal statistic. When adding further values to it, it automatically keeps the statistic of the whole set updated.
