Skip to content

Commit

Permalink
Merge pull request #115 from jorenham/wakeby-entropy
Browse files Browse the repository at this point in the history
Entropy of the Wakeby distribution
  • Loading branch information
jorenham authored Dec 9, 2023
2 parents 748389e + 4fdf4f9 commit bc51b3b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lmo/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,29 @@ def _l_moment(
cast(_ArrF8, _wakeby_lmo(r, s, t, b, d, f)),
)

def _entropy(self, b: float, d: float, f: float) -> float:
"""
Entropy can be calculated from the QDF (PPF derivative) as the
Integrate[Log[QDF[u]], {u, 0, 1}]. This is the (semi) closed-form
solution in this case.
At the time of writing, this result appears to be novel.
The `f` conditionals are the limiting cases, e.g. for uniform,
exponential, and GPD (genpareto).
"""
if f == 0:
return 1 + d
if f == 1:
return 1 - b

bd = b + d
assert bd > 0

return 1 - b + bd * cast(
float,
sc.hyp2f1(1, 1 / bd, 1 + 1 / bd, -f / (1 - f)), # type: ignore
)


wakeby: RVContinuous[float, float, float] = wakeby_gen(
a=0.0,
Expand Down

0 comments on commit bc51b3b

Please sign in to comment.