(values, p)
| 431 | } |
| 432 | |
| 433 | function percentile(values, p) { |
| 434 | if (values.length === 0) return 0 |
| 435 | const sorted = [...values].sort((a, b) => a - b) |
| 436 | const index = Math.min(sorted.length - 1, Math.max(0, Math.ceil((p / 100) * sorted.length) - 1)) |
| 437 | return sorted[index] |
| 438 | } |
| 439 | |
| 440 | function round(value) { |
| 441 | return Math.round(value * 100) / 100 |
no outgoing calls
no test coverage detected