Skip to content
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

Implement AsymmetricLaplace distribution #2850

Merged
merged 4 commits into from
May 27, 2021
Merged

Implement AsymmetricLaplace distribution #2850

merged 4 commits into from
May 27, 2021

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented May 18, 2021

Tested

  • add to tests/distributions/conftest.py

@fritzo fritzo added the WIP label May 18, 2021
@fritzo fritzo requested a review from fehiepsi May 25, 2021 18:29
self._validate_sample(value)
z = value - self.loc
z = -z.abs() / torch.where(z < 0, self.left_scale, self.right_scale)
return z - (self.left_scale + self.right_scale).log()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a bit of time to see the continuity here (haha my mind is not working these days :D )

  • z -> 0- : -|z| / left_scale - log(left_scale + right_scale)
  • z -> 0+ : -|z| / right_scale - log(self_scale + right_scale)
    both converges to - log(self_scale + right_scale)

pyro/distributions/asymmetriclaplace.py Outdated Show resolved Hide resolved
Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fehiepsi fehiepsi merged commit 4a61ef2 into dev May 27, 2021
@fritzo fritzo deleted the asymmetric-laplace branch September 27, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants