Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9e5d54

Browse files
committed
Closed-form for _parabolic_invcdf().
1 parent 630d942 commit e9e5d54

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

Lib/statistics.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,18 +1729,13 @@ def _simple_s_curve(power):
17291729
if p <= 1/2 else
17301730
1 - (2 - 2*p) ** power)
17311731

1732-
_parabolic_invcdf = _newton_raphson(
1733-
f_inv_estimate = _simple_s_curve(0.583367470424302), # (7/12)
1734-
f = lambda t: -1/4 * t**3 + 3/4 * t + 1/2,
1735-
f_prime = lambda t: 3/4 * (1.0 - t * t))
1736-
17371732
_quartic_invcdf = _newton_raphson(
17381733
f_inv_estimate = _simple_s_curve(0.4258865685331), # (204/479)
17391734
f = lambda t: 3/16 * t**5 - 5/8 * t**3 + 15/16 * t + 1/2,
17401735
f_prime = lambda t: 15/16 * (1.0 - t * t) ** 2)
17411736

17421737
_triweight_invcdf = _newton_raphson(
1743-
f_inv_estimate = _simple_s_curve(0.3400218741872791), (17/50)
1738+
f_inv_estimate = _simple_s_curve(0.3400218741872791), # (17/50)
17441739
f = lambda t: 35/32 * (-1/7*t**7 + 3/5*t**5 - t**3 + t) + 1/2,
17451740
f_prime = lambda t: 35/32 * (1.0 - t * t) ** 3)
17461741

@@ -1749,7 +1744,7 @@ def _simple_s_curve(power):
17491744
'logistic': lambda p: log(p / (1 - p)),
17501745
'sigmoid': lambda p: log(tan(p * pi/2)),
17511746
'rectangular': lambda p: 2*p - 1,
1752-
'parabolic': _parabolic_invcdf,
1747+
'parabolic': lambda p: 2 * cos((acos(2*p-1) + pi) / 3),
17531748
'quartic': _quartic_invcdf,
17541749
'triweight': _triweight_invcdf,
17551750
'triangular': lambda p: sqrt(2*p) - 1 if p < 1/2 else 1 - sqrt(2 - 2*p),

0 commit comments

Comments
 (0)