Skip to content

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 6, 2024

TODO: Bump PyMC dependency

@ricardoV94 ricardoV94 added the enhancements New feature or request label Nov 6, 2024
@ricardoV94 ricardoV94 force-pushed the mv_laplace branch 2 times, most recently from c98ff2e to b5e1b41 Compare November 7, 2024 12:51


@pytest.mark.xfail(reason="Not sure about equivalence. Test fails")
def test_asymmetric_matches_univariate_logp():
Copy link
Member Author

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):
Copy link
Member Author

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

@ricardoV94
Copy link
Member Author

Deprecation failures should be fixed by pymc-devs/pymc#7564

@zaxtax
Copy link
Contributor

zaxtax commented Jun 24, 2025

@ricardoV94 I think this needs to be rebased. There are references to pymc_experimental still in there

@ricardoV94
Copy link
Member Author

Yes it does, but I won't bother if I get no reviews haha

Copy link
Contributor

@zaxtax zaxtax left a 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]
Copy link
Contributor

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):
Copy link
Contributor

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)
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancements New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants