Spaces:
Running
Running
Download modelling/math_utils.py from PMA-Labs/megadicing: direct link, hf CLI and curl.
- Browser
- Download file 680 Bytes
-
https://huggingface.co/spaces/PMA-Labs/megadicing/resolve/main/modelling/math_utils.py
- Command line
-
hf download hf://spaces/PMA-Labs/megadicing/modelling/math_utils.py
-
curl -L -o math_utils.py https://huggingface.co/spaces/PMA-Labs/megadicing/resolve/main/modelling/math_utils.py
680 Bytes
| import numpy as np | |
| from scipy.stats import norm as _scipy_norm | |
| def natural_log(value): | |
| """Return natural logarithm (base e).""" | |
| return np.log(float(value)) | |
| def normal_quantile_bound(std, q): | |
| """Upper bound of N(0, std²) at one-sided tail probability q. | |
| Returns ppf(1-q) * std so that P(X > result) = q for X ~ N(0, std²). | |
| Examples: | |
| q=0.1 → z≈1.282 → inner shading band (±10% one-sided tails, 80% coverage) | |
| q=0.01 → z≈2.326 → outer shading band (±1% one-sided tails, 98% coverage) | |
| Works element-wise on numpy arrays or plain Python lists. | |
| """ | |
| return float(_scipy_norm.ppf(1.0 - q)) * np.asarray(std, dtype=float) | |