Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #387 from rgommers/ticket-1793-geom

BUG: stats: Fix ticket 1793 - geom.logpmf
  • Loading branch information...
commit 89c7f42a374b04e1894115b84c33625eb06c2009 2 parents d0ddf54 + 78da5a6
@pv pv authored
View
10 scipy/stats/distributions.py
@@ -1965,10 +1965,10 @@ class ksone_gen(rv_continuous):
%(default)s
"""
- def _cdf(self,x,n):
- return 1.0-special.smirnov(n,x)
- def _ppf(self,q,n):
- return special.smirnovi(n,1.0-q)
+ def _cdf(self, x, n):
+ return 1.0 - special.smirnov(n, x)
+ def _ppf(self, q, n):
+ return special.smirnovi(n, 1.0 - q)
ksone = ksone_gen(a=0.0, name='ksone', shapes="n")
class kstwobign_gen(rv_continuous):
@@ -6582,7 +6582,7 @@ def _argcheck(self, p):
def _pmf(self, k, p):
return (1-p)**(k-1) * p
def _logpmf(self, k, p):
- return (k-1)*log(1-p) + p
+ return (k-1)*log(1-p) + log(p)
def _cdf(self, x, p):
k = floor(x)
return (1.0-(1.0-p)**k)
View
11 scipy/stats/tests/test_distributions.py
@@ -182,6 +182,12 @@ def test_pmf(self):
vals = stats.geom.pmf([1,2,3],0.5)
assert_array_almost_equal(vals,[0.5,0.25,0.125])
+ def test_logpmf(self):
+ # regression test for ticket 1793
+ vals1 = np.log(stats.geom.pmf([1,2,3], 0.5))
+ vals2 = stats.geom.logpmf([1,2,3], 0.5)
+ assert_allclose(vals1, vals2, rtol=1e-15, atol=0)
+
def test_cdf_sf(self):
vals = stats.geom.cdf([1,2,3],0.5)
vals_sf = stats.geom.sf([1,2,3],0.5)
@@ -885,9 +891,7 @@ def test_powerlaw_stats():
def test_ksone_fit_freeze():
- """Regression test for ticket #1638.
-
- """
+ #Regression test for ticket #1638.
d = np.array(
[-0.18879233, 0.15734249, 0.18695107, 0.27908787, -0.248649,
-0.2171497 , 0.12233512, 0.15126419, 0.03119282, 0.4365294 ,
@@ -905,6 +909,7 @@ def test_ksone_fit_freeze():
warn_ctx.__enter__()
try:
warnings.simplefilter('ignore', UserWarning)
+ warnings.simplefilter('ignore', RuntimeWarning)
stats.ksone.fit(d)
finally:
warn_ctx.__exit__()
Please sign in to comment.
Something went wrong with that request. Please try again.