# How to calculate a weighted mean with missing observations

**URL:** https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281
**Category:** Statistics
**Created:** [January 4, 2019, 8:01pm UTC](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281 "2019-01-04T20:01:56Z")
**Posts on this page:** 1
**Showing post:** 14

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [January 5, 2019, 4:40pm UTC](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281/14 "2019-01-05T16:40:54Z")

</div>

Thanks for that link. But to be clear I think that’s _not_ the way to go.

That PR fixes `mapreduce` and the functions that use it like `sum` and `prod`, but you’d have to do the same for `reduce`. And `mean` doesn’t actually use `mapreduce` as far as I can tell, so you’d have to fix that as well. How many others are there? On top of that, StaticArrays has to reimplement these functions with `dims` arguments as well, so there’s even more implementation cost and opportunity for bugs. All of this could be avoided by just not having the `dims` keyword arguments and using the `eachslice` API to separate these concerns.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281)._
