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

TruncatedCauchy gives wrong results sometimes #1793

Open
Joshuaalbert opened this issue Mar 5, 2024 · 0 comments
Open

TruncatedCauchy gives wrong results sometimes #1793

Joshuaalbert opened this issue Mar 5, 2024 · 0 comments

Comments

@Joshuaalbert
Copy link
Contributor

Joshuaalbert commented Mar 5, 2024

TruncatedCauchy quantile gives NaN for some parameter combinations. Similar to #1788

Numerical stability should be reinforced or it severely limits to usefulness of the distribution.

MVCE

import jax
import jax.numpy as jnp
import pytest
import tensorflow_probability.substrates.jax as tfp

tfpd = tfp.distributions


@pytest.mark.parametrize("scale", [0.1, 1.])
@pytest.mark.parametrize("low", [0.0])
@pytest.mark.parametrize("high", [1e6])
def test_truncated_cauchy(low, high, scale):
    dist = tfpd.TruncatedCauchy(1.0, scale, low=low, high=high)
    u = jnp.linspace(0., 1., 100)

    samples = jax.vmap(dist.quantile)(u)
    assert jnp.all(jnp.isfinite(samples))
    assert jnp.all(samples >= low)
    assert jnp.all(samples <= high)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant