Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ticket 1793 - geom.logpmf #387

Merged
merged 2 commits into from

2 participants

@rgommers
Owner

Fixes a simple bug, and also an annoying warning message that has been printing for a while.

rgommers added some commits
@rgommers rgommers BUG: fix stats.distributions.geom.logpmf bug. Closes #1793.
Thanks to Jonathan Scholz.
ef85190
@rgommers rgommers TST: filter warning message from stats test.
Introduced by recent change in warning mechanism in special module.
Leaving the test unchanged, because it's a regression test.
Fitting with n=1 fixed would be better, but doesn't seem to be supported yet.
78da5a6
@pv
Owner
pv commented

Looks good to me.

@pv pv merged commit 89c7f42 into from
@ClemensFMN ClemensFMN referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. @rgommers

    BUG: fix stats.distributions.geom.logpmf bug. Closes #1793.

    rgommers authored
    Thanks to Jonathan Scholz.
  2. @rgommers

    TST: filter warning message from stats test.

    rgommers authored
    Introduced by recent change in warning mechanism in special module.
    Leaving the test unchanged, because it's a regression test.
    Fitting with n=1 fixed would be better, but doesn't seem to be supported yet.
This page is out of date. Refresh to see the latest.
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__()
Something went wrong with that request. Please try again.