Spaces:
Build error
Build error
Download experiments/exp4_compose/aggregate_lib.py from dmontgomery40/plastic: direct link, hf CLI and curl.
- Browser
- Download file 305 Bytes
-
https://huggingface.co/spaces/dmontgomery40/plastic/resolve/main/experiments/exp4_compose/aggregate_lib.py
- Command line
-
hf download hf://spaces/dmontgomery40/plastic/experiments/exp4_compose/aggregate_lib.py
-
curl -L -o aggregate_lib.py https://huggingface.co/spaces/dmontgomery40/plastic/resolve/main/experiments/exp4_compose/aggregate_lib.py
305 Bytes
| import math | |
| def wilson(k: int, n: int, z: float = 1.96): | |
| if n == 0: | |
| return (float("nan"), float("nan")) | |
| p = k / n | |
| den = 1 + z * z / n | |
| c = (p + z * z / (2 * n)) / den | |
| h = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / den | |
| return (max(0.0, c - h), min(1.0, c + h)) | |