statistics module NormalDist.quantiles(0) should raise statistics error instead of returning empty list and makes redundant checks
Abierto
@rhettinger ya está trabajando en esto.
Desde el 6/8/2026.
pending
stdlib
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
import statistics
d = statistics.NormalDist()
print(d.quantiles(0))
output:
[]
- The called function inv_cdf checks for p <= 0 or .. during every iteration of the loop rather than once, even though all values of p are guaranteed to be in the range through the way they are generated as i / n.
self.inv_cdf(i / n) for i in range(1, n)
inv_cdf(self, p)
...
if p <= 0.0 or p >= 1.0
It makes more sense to call the implementation _normal_dist_inv_cdf(p, self._mu, self._sigma) directly.
CPython versions tested on:
3.13
Operating systems tested on:
Other
Linked PRs
- gh-155015
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.