Skip to content

Commit

Permalink
MAINT: logistic accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrc committed Jun 10, 2016
1 parent a21d69c commit 6707aa1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scipy/stats/_continuous_distns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2967,7 +2967,13 @@ def _cdf(self, x):
return special.expit(x)

def _ppf(self, q):
return -log(1.0/q-1)
return special.logit(q)

def _sf(self, x):
return special.expit(-x)

def _isf(self, q):
return -special.logit(q)

def _stats(self):
return 0, pi*pi/3.0, 0, 6.0/5.0
Expand Down
22 changes: 22 additions & 0 deletions scipy/stats/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,28 @@ def test_stats(self):
decimal=4)


class TestLogistic(TestCase):
# gh-6226
def test_cdf_ppf(self):
x = np.linspace(-20, 20)
y = stats.logistic.cdf(x)
xx = stats.logistic.ppf(y)
assert_allclose(x, xx)

def test_sf_isf(self):
x = np.linspace(-20, 20)
y = stats.logistic.sf(x)
xx = stats.logistic.isf(y)
assert_allclose(x, xx)

def test_extreme_values(self):
# p is chosen so that 1 - (1 - p) == p in double precision
p = 9.992007221626409e-16
desired = 34.53957599234088
assert_allclose(stats.logistic.ppf(1 - p), desired)
assert_allclose(stats.logistic.isf(p), desired)


class TestLogser(TestCase):
def test_rvs(self):
vals = stats.logser.rvs(0.75, size=(2, 50))
Expand Down

0 comments on commit 6707aa1

Please sign in to comment.