quickselect VS d3.median
✓ Published0🌍 Public
PPhilippe Rivière
Last edited Feb 14, 2017
Created on Feb 14, 2017
This example benchmarks the performance of `d3.median` against the `quickselect` algorithm on a dataset of one million random numbers. A single text element displays the comparison: both methods yield the same result, and quickselect’s runtime is shown as a percentage of d3.median’s. The code uses `d3.range`, `Math.random`, and `performance.now` for timing, with `partialSort` from the `quickselect` library to compute the median and `d3.format` for the percentage output.
AI-generated descriptionExploring mourner/quickselect as a faster alternative to compute d3.median()
Note: a better alternative is probably simplestatistics.
See d3 issue #1833.
mit Licensed