scipy/ppf-of-complement
| Rule | ppf-of-complement |
|---|---|
| Pack | SciPy |
| Severity | warning |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
ppf(1 - p) rounds away the digits of a small p, so it loses precision far in the tail. Call isf(p).
crit = stats.norm.ppf(1 - alpha / 2)crit = stats.norm.isf(alpha / 2)What the rule reports
Section titled “What the rule reports”The rule reports dist.ppf(1 - p, ...) and dist.isf(1 - p, ...) for a continuous
scipy.stats distribution from a measured list, and special.ndtri(1 - p). The old form lost 3
or more digits for every p below 5e-7. A probability written as a number, such as 1 - 0.05,
is left alone unless it is below 5e-7.
How to fix it
Section titled “How to fix it”xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.
The unsafe fix writes dist.isf(p, ...), dist.ppf(p, ...), -special.ndtri(p).
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
1 - $P rounds away the digits of a small $P, so this lost at least 3 digits for $P below 5e-7 and gives the end of the support below 1.1e-16, where $R.isf lost less than 1. Write $R.isf($REST).Browse the other rules of the SciPy pack.