Skip to content

Instantly share code, notes, and snippets.

@willwhite
Created November 30, 2011 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willwhite/1409554 to your computer and use it in GitHub Desktop.
Save willwhite/1409554 to your computer and use it in GitHub Desktop.
Quantiles
/**
* Quantile breaks in a dataset
* @param {array}: data list of data.
* @param {number}: n number of breaks.
* @return {array} of break places.
*/
function quantile(data, n) {
return _.select(data.sort(), function(val, index) {
return index % (data.length / (n - 1)) == 0;
}).concat(_.max(data));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment