| Conditions | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /** |
||
| 37 | export function quantile(arr, q) { |
||
| 38 | const sorted = arr.sort((a, b) => a - b); |
||
| 39 | const pos = (sorted.length - 1) * q; |
||
| 40 | const base = Math.floor(pos); |
||
| 41 | const rest = pos - base; |
||
| 42 | |||
| 43 | if (sorted[base + 1] !== undefined) { |
||
| 44 | return sorted[base] + rest * (sorted[base + 1] - sorted[base]); |
||
| 45 | } |
||
| 46 | |||
| 47 | return sorted[base]; |
||
| 48 | } |
||
| 49 | |||
| 50 |