This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients gerion, mark.dickinson, steven.daprano
Date 2017-07-25.01:33:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20170725013302.GS3149@ando.pearwood.info>
In-reply-to <1500924567.24.0.886645031856.issue30999@psf.upfronthosting.co.za>
Content
I've given this some more thought, and I think that a "key" argument 
would make sense for a general selection function.

The general selection problem is: given a set of items A, and a number k 
between 1 and the number of items, return the k-th item. In Python 
terms, we would use a list, and 0 <= k < len(A) instead.

https://www.cs.rochester.edu/~gildea/csc282/slides/C09-median.pdf

I've had the idea of adding a select(A, k) function to statistics for a 
while now. Then the median_low would be equivalent to select(A, 
len(A)//2) and median_high would be select(A, len(A)//2 + 1). I'd leave 
the median_* functions as they are, and possibly include a key function 
in select.

I don't think it makes sense to add key arguments to mode, mean, 
variance etc. I'm having trouble thinking of what that would even mean 
(no pun intented): it's unlikely that the mean will actually a data 
value (except by accident, or by careful construction of the data). 
Variance has the wrong units (it is the units of your data, squared) and 
the stdev is conceptually a difference between data values, not a data 
value itself, so it doesn't even make sense to apply a key function and 
return one of the data points.

And mode counts objects, so it already applies to non-numeric data. 
It's even documented as applying to nominal data.
History
Date User Action Args
2017-07-25 01:33:09steven.dapranosetrecipients: + steven.daprano, mark.dickinson, gerion
2017-07-25 01:33:09steven.dapranolinkissue30999 messages
2017-07-25 01:33:08steven.dapranocreate