Message305166
My recommendation is to have *weights* as an optional argument:
statistics.mean(values, weights=None)
While it is tempting to special case dicts and counters, I got feedback from Jake Vanderplas and Wes McKinney that in practice it is more common to have the weights as a separate list/array/vector.
That API has other advantages as well. For starters, it is a simple extension of the existing API, so it isn't a disruptive change. Also, it works well with mapping views:
statistics.mean(vehicle_sales.keys(), vehicle_sales.values())
And the API also helps support use cases where different weightings are being explored for the same population:
statistics.mean(salary, years_of_service)
statistics.mean(salary, education)
statistics.mean(salary, age) |
|
Date |
User |
Action |
Args |
2017-10-28 20:01:32 | rhettinger | set | recipients:
+ rhettinger, gregory.p.smith, ncoghlan, steven.daprano, oscarbenjamin, wolma |
2017-10-28 20:01:32 | rhettinger | set | messageid: <1509220892.08.0.213398074469.issue20479@psf.upfronthosting.co.za> |
2017-10-28 20:01:32 | rhettinger | link | issue20479 messages |
2017-10-28 20:01:31 | rhettinger | create | |
|