Skip to content

Commit

Permalink
Fix unit_variance_derivative (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtilly authored Apr 13, 2021
1 parent 81e3615 commit 9dabe47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
Changelog
=========

1.3.1 - 2021-04-12
------------------

**Bug fix**:

- :func:`quantcore.glm._distribution.unit_variance_derivative` is
evaluating a proper numexpr expression again (regression in 1.3.0).


1.3.0 - 2021-04-12
------------------

Expand Down
6 changes: 3 additions & 3 deletions src/quantcore/glm/_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ def unit_variance(self, mu: np.ndarray) -> np.ndarray:
return numexpr.evaluate("mu ** p")

def unit_variance_derivative(self, mu: np.ndarray) -> np.ndarray:
"""Compute the derivative of the unit variance of a Tweedie distribution.
r"""Compute the derivative of the unit variance of a Tweedie distribution.
Equation: ``v(mu) = power * mu^(power-1)``.
Equation: :math:`v(\mu) = p \times \mu^{(p-1)}`.
Parameters
----------
Expand All @@ -529,7 +529,7 @@ def unit_variance_derivative(self, mu: np.ndarray) -> np.ndarray:
numpy.ndarray, shape (n_samples,)
"""
p = self.power # noqa: F841
return numexpr.evaluate("p × mu^(p - 1)")
return numexpr.evaluate("p * mu ** (p - 1)")

def unit_deviance(self, y, mu):
"""Get the deviance of each observation."""
Expand Down

0 comments on commit 9dabe47

Please sign in to comment.