Skip to content

Commit

Permalink
MAINT: bradford distribution accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrc committed Jun 10, 2016
1 parent a21d69c commit 9c513f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scipy/stats/_continuous_distns.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,13 @@ class bradford_gen(rv_continuous):
"""
def _pdf(self, x, c):
return c / (c*x + 1.0) / log(1.0+c)
return c / (c*x + 1.0) / special.log1p(c)

def _cdf(self, x, c):
return log(1.0+c*x) / log(c+1.0)
return special.log1p(c * x) / special.log1p(c)

def _ppf(self, q, c):
return ((1.0+c)**q-1)/c
return special.expm1(q * special.log1p(c)) / c

def _stats(self, c, moments='mv'):
k = log(1.0+c)
Expand Down
10 changes: 10 additions & 0 deletions scipy/stats/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ def test_entropy(self):
assert_equal(h, 0.0)


class TestBradford(TestCase):
# gh-6216
def test_cdf_ppf(self):
c = 0.1
x = np.logspace(-20, -4)
q = stats.bradford.cdf(x, c)
xx = stats.bradford.ppf(q, c)
assert_allclose(x, xx)


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

0 comments on commit 9c513f7

Please sign in to comment.