@@ -409,6 +409,50 @@ export function nice(val, round) {
409
409
return exponent >= - 20 ? + val . toFixed ( exponent < 0 ? - exponent : 0 ) : val ;
410
410
}
411
411
412
+ /**
413
+ * BSD 3-Clause
414
+ *
415
+ * Copyright (c) 2010-2015, Michael Bostock
416
+ * All rights reserved.
417
+ *
418
+ * Redistribution and use in source and binary forms, with or without
419
+ * modification, are permitted provided that the following conditions are met:
420
+ *
421
+ * * Redistributions of source code must retain the above copyright notice, this
422
+ * list of conditions and the following disclaimer.
423
+ *
424
+ * * Redistributions in binary form must reproduce the above copyright notice,
425
+ * this list of conditions and the following disclaimer in the documentation
426
+ * and/or other materials provided with the distribution.
427
+ *
428
+ * * The name Michael Bostock may not be used to endorse or promote products
429
+ * derived from this software without specific prior written permission.
430
+ *
431
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
432
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
433
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
434
+ * DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
435
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
436
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
437
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
438
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
439
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
440
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
441
+ */
442
+
443
+ /**
444
+ * @see <https://github.com/mbostock/d3/blob/master/src/arrays/quantile.js>
445
+ * @see <http://en.wikipedia.org/wiki/Quantile>
446
+ * @param {Array.<number> } ascArr
447
+ */
448
+ export function quantile ( ascArr , p ) {
449
+ var H = ( ascArr . length - 1 ) * p + 1 ;
450
+ var h = Math . floor ( H ) ;
451
+ var v = + ascArr [ h - 1 ] ;
452
+ var e = H - h ;
453
+ return e ? v + e * ( ascArr [ h ] - v ) : v ;
454
+ }
455
+
412
456
/**
413
457
* Order intervals asc, and split them when overlap.
414
458
* expect(numberUtil.reformIntervals([
0 commit comments