tensorflow / tensorflow/probability

TruncatedCauchy gives wrong results sometimes

Open
#1,793 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the MVCE for TruncatedCauchy.quantile with the listed low, high, scale, and parameterized inputs. Reproduce the NaN results, then inspect the quantile implementation for numerical stability; done means all mapped samples are finite and remain between low and high.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.