Function
percentile
(values: list[float], pct: int)
Source from the content-addressed store, hash-verified
| 423 | |
| 424 | |
| 425 | def percentile(values: list[float], pct: int) -> float | None: |
| 426 | if not values: |
| 427 | return None |
| 428 | k = (len(values) - 1) * (pct / 100.0) |
| 429 | lower = math.floor(k) |
| 430 | upper = math.ceil(k) |
| 431 | if lower == upper: |
| 432 | return values[lower] |
| 433 | return values[lower] + (values[upper] - values[lower]) * (k - lower) |
| 434 | |
| 435 | |
| 436 | def compute_apdex(values: list[float], threshold: float = 300.0) -> float | None: |
Tested by
no test coverage detected