# StatsBase.wsum doesn't work for iterators

**URL:** https://discourse.julialang.org/t/statsbase-wsum-doesnt-work-for-iterators/118289
**Category:** New to Julia
**Tags:** stats
**Created:** [August 16, 2024, 7:44pm UTC](https://discourse.julialang.org/t/statsbase-wsum-doesnt-work-for-iterators/118289 "2024-08-16T19:44:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)
#### Post date: [August 16, 2024, 7:44pm UTC](https://discourse.julialang.org/t/statsbase-wsum-doesnt-work-for-iterators/118289/1 "2024-08-16T19:44:27Z")

</div>

StatsBase.wsum (and others) don’t work on iterators.

Is there a fundamental reason for this?

And speaking of which, the docstring shows `wsum(v, w::AbstractVector, [dim])` but in reality all methods are `v::AbstractArray`.

---

<div class="post-metadata">

### Author: ![palday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palday/32/12640_2.png) [@palday](https://discourse.julialang.org/u/palday)
#### Post date: [August 19, 2024, 4:56pm UTC](https://discourse.julialang.org/t/statsbase-wsum-doesnt-work-for-iterators/118289/2 "2024-08-19T16:56:28Z")

</div>

There is no fundamental reason for it. It just requires that somebody contributes the necessary code. We would need to check whether it makes sense to keep both generic iterator and specialized array methods around (depends on performance aspects – the [use of generated functions](https://github.com/JuliaStats/StatsBase.jl/blob/87f372ca912e5da94cbd7531d2fa5724832df98a/src/weights.jl#L517) highlights how much effort has gone into making the existing methods performant).
