MCPcopy Index your code
hub / github.com/python/cpython / _normal_dist_inv_cdf

Function _normal_dist_inv_cdf

Lib/statistics.py:1797–1872  ·  view source on GitHub ↗
(p, mu, sigma)

Source from the content-addressed store, hash-verified

1795
1796
1797def _normal_dist_inv_cdf(p, mu, sigma):
1798 # There is no closed-form solution to the inverse CDF for the normal
1799 # distribution, so we use a rational approximation instead:
1800 # Wichura, M.J. (1988). "Algorithm AS241: The Percentage Points of the
1801 # Normal Distribution". Applied Statistics. Blackwell Publishing. 37
1802 # (3): 477–484. doi:10.2307/2347330. JSTOR 2347330.
1803 q = p - 0.5
1804
1805 if fabs(q) <= 0.425:
1806 r = 0.180625 - q * q
1807 # Hash sum: 55.88319_28806_14901_4439
1808 num = (((((((2.50908_09287_30122_6727e+3 * r +
1809 3.34305_75583_58812_8105e+4) * r +
1810 6.72657_70927_00870_0853e+4) * r +
1811 4.59219_53931_54987_1457e+4) * r +
1812 1.37316_93765_50946_1125e+4) * r +
1813 1.97159_09503_06551_4427e+3) * r +
1814 1.33141_66789_17843_7745e+2) * r +
1815 3.38713_28727_96366_6080e+0) * q
1816 den = (((((((5.22649_52788_52854_5610e+3 * r +
1817 2.87290_85735_72194_2674e+4) * r +
1818 3.93078_95800_09271_0610e+4) * r +
1819 2.12137_94301_58659_5867e+4) * r +
1820 5.39419_60214_24751_1077e+3) * r +
1821 6.87187_00749_20579_0830e+2) * r +
1822 4.23133_30701_60091_1252e+1) * r +
1823 1.0)
1824 x = num / den
1825 return mu + (x * sigma)
1826
1827 r = p if q <= 0.0 else 1.0 - p
1828 r = sqrt(-log(r))
1829 if r <= 5.0:
1830 r = r - 1.6
1831 # Hash sum: 49.33206_50330_16102_89036
1832 num = (((((((7.74545_01427_83414_07640e-4 * r +
1833 2.27238_44989_26918_45833e-2) * r +
1834 2.41780_72517_74506_11770e-1) * r +
1835 1.27045_82524_52368_38258e+0) * r +
1836 3.64784_83247_63204_60504e+0) * r +
1837 5.76949_72214_60691_40550e+0) * r +
1838 4.63033_78461_56545_29590e+0) * r +
1839 1.42343_71107_49683_57734e+0)
1840 den = (((((((1.05075_00716_44416_84324e-9 * r +
1841 5.47593_80849_95344_94600e-4) * r +
1842 1.51986_66563_61645_71966e-2) * r +
1843 1.48103_97642_74800_74590e-1) * r +
1844 6.89767_33498_51000_04550e-1) * r +
1845 1.67638_48301_83803_84940e+0) * r +
1846 2.05319_16266_37758_82187e+0) * r +
1847 1.0)
1848 else:
1849 r = r - 5.0
1850 # Hash sum: 47.52583_31754_92896_71629
1851 num = (((((((2.01033_43992_92288_13265e-7 * r +
1852 2.71155_55687_43487_57815e-5) * r +
1853 1.24266_09473_88078_43860e-3) * r +
1854 2.65321_89526_57612_30930e-2) * r +

Callers 2

normal_kernelFunction · 0.85
inv_cdfMethod · 0.85

Calls 1

logFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…