Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
median-quickselect
Advanced tools
Fast implementation of median search using quickselect algorithm
Fast implementation of lower median search using Quick select algorithm. Ported from this C implementation.
Please read "Fast median search: an ANSI C implementation" by Nicolas Devillard for more info.
Note that result can be different from other packages, as median-quickselect
calculates lower median, because taking an average of the two central elements requires two calls to the routine, doubling the processing time.
Install from npm:
npm install --save median-quickselect
Or hot-link via unpkg.com
<script src="https://unpkg.com/median-quickselect"></script>
const median = require('median-quickselect');
median([1, 4, 10, 2, 5, 0, -5]); // 2
Note that the **order of elements ** on array passed to median()
will be changed after call.
$ npm run bench 1001 ms master
> node test/benchmark.js
benchmarking dataset of 100 numbers
median: 0.891ms
fast-median: 0.999ms
compute-median: 0.269ms
stats-median: 0.159ms
median-quickselect: 0.230ms
benchmarking dataset of 1000 numbers
median: 0.849ms
fast-median: 1.713ms
compute-median: 0.562ms
stats-median: 0.210ms
median-quickselect: 0.204ms
benchmarking dataset of 10000 numbers
median: 6.249ms
fast-median: 9.413ms
compute-median: 5.816ms
stats-median: 5.101ms
median-quickselect: 2.027ms
benchmarking dataset of 1000000 numbers
median: 576.688ms
fast-median: 886.843ms
compute-median: 786.714ms
stats-median: 662.177ms
median-quickselect: 13.027ms
benchmarking dataset of 10000000 numbers
median: 6347.193ms
fast-median: 8722.377ms
compute-median: 7278.490ms
stats-median: 7089.452ms
median-quickselect: 119.298ms
FAQs
Fast implementation of median search using quickselect algorithm
We found that median-quickselect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.