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

Replaced the sort in median and quantileSeq with a partition-based selection function #373

Merged
merged 1 commit into from May 18, 2015

Conversation

Projects
None yet
2 participants
@BigFav
Collaborator

BigFav commented May 16, 2015

This brings the average case down to O(n) from O(nlogn).

Also, removed the flatted call in median for a sequence (still needed for an Array or Matrix input), and added a few more comments in quantileSeq.

Replaced the sort in `median` and `quantileSeq` with a partition-base…
…d selection function. Also removed the flatted call in `median` for a sequence (still needed for an Array or Matrix input).
@BigFav

This comment has been minimized.

Collaborator

BigFav commented May 16, 2015

One question, I could not store math.partitionSelect inside of a variable at the top of the file; the variable would have the value undefined instead of [Function]. Do you know why?

@josdejong

This comment has been minimized.

Owner

josdejong commented May 18, 2015

Thanks, nice improvement!

One question, I could not store math.partitionSelect inside of a variable at the top of the file; the variable would have the value undefined instead of [Function]. Do you know why?

I guess it's not yet loaded there? When math.partitionSelect is loaded after math.median, it's still undefined at the moment you load math.median. So just don't make these sort of shortcuts. Note that in v2 you can (have to) explicitly load dependencies on other functions, so you will not have that issue there (see this example in det.js).

josdejong added a commit that referenced this pull request May 18, 2015

Merge pull request #373 from BigFav/quickselect_quantile
Replaced the sort in median and quantileSeq with a partition-based selection function

@josdejong josdejong merged commit 74805c7 into josdejong:develop May 18, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment