Skip to content

Commit 44a6876

Browse files
authored
Merge pull request #5 from FINRAOS/hotfix-credibility
Hotfix credibility
2 parents f9b31f8 + fb3505d commit 44a6876

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

mvtk/credibility.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ def credible_interval(positive, negative, credibility=0.5, prior=(1, 1)):
2222
"""
2323
positive += prior[0]
2424
negative += prior[1]
25+
if not (positive > 1 or negative > 1):
26+
raise ValueError(
27+
"Credible intervals are only defined when at least one count + psueocount"
28+
" is greater than 1"
29+
)
2530
distribution = beta(positive, negative)
26-
if positive + negative <= 0:
27-
raise ValueError("Counts plus pseudocounts must be positive")
2831
mode = positive / (positive + negative)
2932
cdf_mode = distribution.cdf(mode)
3033
cred_2 = credibility / 2

mvtk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.2"
1+
__version__ = "0.1.3"

tests/credibility/test_credibility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_value_error():
1414

1515

1616
def test_equivalence():
17-
assert credibility.credible_interval(0, 0) == credibility.credible_interval(
18-
1, 1, prior=(0, 0)
17+
assert credibility.credible_interval(0, 1) == credibility.credible_interval(
18+
1, 2, prior=(0, 0)
1919
)
2020

2121

0 commit comments

Comments
 (0)