Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added kthvalue and median operations, tests, doc #182

Merged
merged 1 commit into from
Apr 4, 2015

Conversation

GeorgOstrovski
Copy link
Contributor

Added kthvalue function, to select k-th smallest value. Interface as close as possible to min/max, i.e. returns values and indices. Based on Quickselect algorithm (i.e. linear time) adapted from this Public Domain implementation, somewhat changed with tricks from the Quicksort implementation used in Torch.

Also added median function based on same algorithm. Median returns 'middle' element in case of odd-many elements, otherwise one-before-middle element (could also do the other convention to take mean of the two around-the-middle elements, but that would be twice more expensive, so I decided for this one).

@andresy
Copy link
Member

andresy commented Apr 4, 2015

good stuff, thanks

andresy added a commit that referenced this pull request Apr 4, 2015
Added kthvalue and median operations, tests, doc
@andresy andresy merged commit 7aa66c6 into torch:master Apr 4, 2015
colesbury pushed a commit to colesbury/torch7 that referenced this pull request Nov 3, 2016
Added kthvalue and median operations, tests, doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants