-
-
Notifications
You must be signed in to change notification settings - Fork 68
Implement Symmetric and Asymmetric Multivariate Laplace distributions #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c98ff2e
to
b5e1b41
Compare
|
||
|
||
@pytest.mark.xfail(reason="Not sure about equivalence. Test fails") | ||
def test_asymmetric_matches_univariate_logp(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting these to be equivalent. The means and variances match, but not the logp. Either I did something wrong or the equivalence is not real / like this.
from pytensor.tensor.random.utils import normalize_size_param | ||
|
||
|
||
class Kv(BinaryScalarOp): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move this to PyTensor before merging this PR
b5e1b41
to
e3aab90
Compare
e3aab90
to
e1680f0
Compare
Deprecation failures should be fixed by pymc-devs/pymc#7564 |
@ricardoV94 I think this needs to be rebased. There are references to |
Yes it does, but I won't bother if I get no reviews haha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, there seems to be some repetition that could be refactored.
[out] = outputs | ||
[g_out] = output_grads | ||
dx = -(v / x) * out - self.kv(v - 1, x) | ||
return [grad_not_implemented(self, 0, v), g_out * dx] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work without a grad on this Op?
_print_name = ("MultivariateAsymmetricLaplace", "\\operatorname{MultivariateAsymmetricLaplace}") | ||
|
||
@classmethod | ||
def rv_op(cls, mu, cov, *, size=None, rng=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rv_op for MvAsymmetricLaplaceRV
and MvLaplaceRV
seem almost identical. Is it worth abstracting that?
return super().dist([mu, cov], **kwargs) | ||
|
||
|
||
@_logprob.register(MvLaplaceRV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to prefer @_logprob.register
over a logp
method? Or is one just the new way to do this now?
TODO: Bump PyMC dependency