tensorflow / tensorflow/probability

hypergeometric 2F1 undefined for legitimate inputs

Open
#2,001 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

In my research on Gaussian Processes I needed hypergeometric function2F1 for small arguments (less than 1 in absolute value).

I have found that the current implementation of hyp2f1_small_argument is incomplete:

To reproduce, run this in Colab and compare against Scipy or Mathematica

import tensorflow_probability as tfp
hyp2f1 = tfp.math.hypergeometric.hyp2f1_small_argument

H = 1
a = tf.constant(1.0)
b = tf.constant(0.5 - H)
c = tf.constant(H + 1.5)
x = tf.constant(0.9901961)
hyp2f1(a,b,c,x) # nan, should be ~ 0.753603 

Tested under tfp==0.25.0 and tf==2.18.0 on Google Colab.

Here is the problematic code:
https://github.com/tensorflow/probability/blob/65f265c62bb1e2d15ef3e25104afb245a6d52429/tensorflow_probability/python/math/hypergeometric.py#L524-L681

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 in tensorflow_probability/python/math/hypergeometric.py, especially hyp2f1_small_argument and the referenced lines 524-681. Reproduce the provided inputs in Colab and compare the result with SciPy or Mathematica. Done means the legitimate small-argument case returns a finite value near 0.753603 rather than NaN, with regression coverage for the example.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.