Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Add median and relatives to std/stats

Open HJarausch opened this issue 4 years ago • 5 comments

The statistics module is missing the computation of the median of a sequence. This PR adds quickSelect : quick selecting the k-th smallest or k-th largest element of a sequence using the Lomuto partition scheme

For a sequence of odd length N the median is that element which is larger-or-equal to (N-1)/2) elements and greater-or-equal than (N-1)/2) elements of the sequence.

median_low computes the median for a sequence of odd length. In case of even length N, median_low has the property that N/2 elements are less than or equal this value and N/2+1 elements are greater than or equal this value. It can be computed for any sequence of comparable items.

median_high computes the median for a sequence of odd length. In case of even length N, median_high has the property that N/2 elements are greater than or equal this value and N/2+1 elements are less than or equal this value. It can be computed for any sequence of comparable items.

median computes the median of a sequence of numeric items. For a sequence of odd length it is equivalent to median_low and median_high. In case of a sequence of even length it computes the arithmetic mean of median_low and median_high.

HJarausch avatar Apr 17 '21 15:04 HJarausch

I can't comment on if the procs belong to the stats module or not, but please make your code adhere to https://nim-lang.org/docs/nep1.html - try running nimpretty on it first of all.

ghost avatar Apr 17 '21 15:04 ghost

see also our contributing guide https://nim-lang.github.io/Nim/contributing.html

ringabout avatar Apr 17 '21 15:04 ringabout

What's blocking this issue? Looks like some CI is failing :thinking: https://github.com/nim-lang/Nim/pull/17756/checks?check_run_id=2392184550 not sure if these are related though.

codic12 avatar May 25 '21 06:05 codic12

What's blocking this issue? Looks like some CI is failing 🤔 #17756 (checks) not sure if these are related though.

tchannels timeout is unrelated, but that is fixed in devel please rebase (also to avoid merge conflicts)

timotheecour avatar May 25 '21 06:05 timotheecour

I'd love to see this included!

ErikSchierboom avatar Dec 07 '21 06:12 ErikSchierboom

This pull request is stale because it has been open for 1 year with no activity. Contribute more commits on the pull request and rebase it on the latest devel, or it will be closed in 30 days. Thank you for your contributions.

github-actions[bot] avatar Sep 24 '23 00:09 github-actions[bot]

This pull request has been marked as stale and closed due to inactivity after 395 days.

github-actions[bot] avatar Oct 25 '23 00:10 github-actions[bot]