Skip to content

Commit

Permalink
Merge pull request #5 from FINRAOS/hotfix-credibility
Browse files Browse the repository at this point in the history
Hotfix credibility
  • Loading branch information
aeftimia authored Aug 17, 2022
2 parents f9b31f8 + fb3505d commit 44a6876
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions mvtk/credibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def credible_interval(positive, negative, credibility=0.5, prior=(1, 1)):
"""
positive += prior[0]
negative += prior[1]
if not (positive > 1 or negative > 1):
raise ValueError(
"Credible intervals are only defined when at least one count + psueocount"
" is greater than 1"
)
distribution = beta(positive, negative)
if positive + negative <= 0:
raise ValueError("Counts plus pseudocounts must be positive")
mode = positive / (positive + negative)
cdf_mode = distribution.cdf(mode)
cred_2 = credibility / 2
Expand Down
2 changes: 1 addition & 1 deletion mvtk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.2"
__version__ = "0.1.3"
4 changes: 2 additions & 2 deletions tests/credibility/test_credibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def test_value_error():


def test_equivalence():
assert credibility.credible_interval(0, 0) == credibility.credible_interval(
1, 1, prior=(0, 0)
assert credibility.credible_interval(0, 1) == credibility.credible_interval(
1, 2, prior=(0, 0)
)


Expand Down

0 comments on commit 44a6876

Please sign in to comment.