python / python/cpython

statistics module NormalDist.quantiles(0) should raise statistics error instead of returning empty list and makes redundant checks

Aperta
#154,945 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@rhettinger ci sta già lavorando.

Dal 6/8/2026.

pending stdlib
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:
import statistics

d = statistics.NormalDist()

print(d.quantiles(0))

output:
[]
  1. 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.