Function
percentile
(values: List[float], p: float)
Source from the content-addressed store, hash-verified
| 17 | |
| 18 | |
| 19 | def percentile(values: List[float], p: float) -> float: |
| 20 | if not values: |
| 21 | return 0.0 |
| 22 | if len(values) == 1: |
| 23 | return values[0] |
| 24 | sorted_values = sorted(values) |
| 25 | rank = (len(sorted_values) - 1) * p |
| 26 | low = int(rank) |
| 27 | high = min(low + 1, len(sorted_values) - 1) |
| 28 | weight = rank - low |
| 29 | return sorted_values[low] * (1 - weight) + sorted_values[high] * weight |
| 30 | |
| 31 | |
| 32 | def build_s3_client(args: argparse.Namespace): |
Tested by
no test coverage detected