nl_tokens: end FUNCTION quantiles () FUNCTION : quantile ( vector percent ) Finds a quantile value .
pl_tokens: function quantile ( vector , percent ) { var numValues = vector . length , id , value ; // Calculate the vector index marking the quantile: id = ( numValues * percent ) - 1 ; // Is the index an integer? if ( id === parseInt ( id , 10 ) ) { // Value is the average between the value at id and id+1: value = ( vector [ <mask> ] + vector [ id + 1 ] ) / 2.0 ; } else { // Round up to the next index: id = Math . ceil ( id ) ; value = vector [ id ] ; } return value ; }