tensorflow / tensorflow/probability

Performance: Noncentral Chi2 Quantile is painfully slow for certain values

Open
#1,642 1 comment 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

Congratulations and thanks for including the NCX2 quantile function! I've noticed that for certain values, the computation becomes painfully slow. An example to reproduce:

pts = tf.linspace(1e-3, 1 - 1e-3, 10)
ncx2 = tfd.NoncentralChi2(df=df, noncentrality=nc)
For df= 1; nc=1, the computation takes 0.10 to 0.35 seconds per value. For df =1, nc=4, the computation stalls for over 30 minutes when computing small values (say below 0.01). The code stalling is the find_root_secant procedure, up to and including the quant_approx step, the computation runs fine. Changing the tolerance doesn't seem to help.

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 with the Noncentral Chi2 quantile path, especially the named find_root_secant procedure and the preceding quant_approx step. Reproduce the df=1, noncentrality=1 and 4 cases with the provided tf.linspace values, then verify that small quantiles no longer stall while retaining correct results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.