Calculating the median of an array with only a single element fails. The median code uses percentile(50) and that crashes if there are not al least two elements.
I know that it makes little sense to calculate the median of a single element, however, I use the desctiptive_statistics gem to do batch processing of large amounts of data and process arrays with lengths from 1 to n.
While I can handle that case in my code, I think that others would also benefit if median would work for one element.
Thanks! I've updated the code and tests to cover that case in version 2.0.1. Your input is much appreciated. I would love to hear more of how you use the gem.
Calculating the median of an array with only a single element fails. The median code uses percentile(50) and that crashes if there are not al least two elements.
I know that it makes little sense to calculate the median of a single element, however, I use the desctiptive_statistics gem to do batch processing of large amounts of data and process arrays with lengths from 1 to n.
While I can handle that case in my code, I think that others would also benefit if median would work for one element.