tensorflow / tensorflow/probability
Generalized Pareto Supported Below `loc`?
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Relatively new to TF/TFP so perhaps there is some obvious answer here. The pdf for the Generalized Pareto is typically defined as having support for x >= loc for shape >= 0 and the docs do even say the support of the distribution is always lower bounded by loc, but this isn't so. I compared with scipy below.
Has impacted me as I'm using a hybrid that utilizes Pareto pdf only if x>=loc but I'm getting NaNs (I think) b/c the non-tail portion is being evaluated by the GenPareto at a number much greater than zero (and its alot more challenging to adjust for).
import numpy as np
import scipy.stats as scist
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow_probability import distributions as tfd
x = np.linspace(-.5,2,1000)
x_tf = tf.convert_to_tensor(x, dtype=tf.float32)
loc, scale, conc = .25, 1, .25
gptf = tfd.GeneralizedPareto(loc, scale, conc)
gp = scist.genpareto(conc, loc=loc, scale=scale)
plt.plot(x_tf, gptf.prob(x_tf), label='TFP')
plt.plot(x_tf, gptf.prob(x_tf))
plt.plot(x, gp.pdf(x), label='SCIPY')
plt.legend()
plt.savefig('gpd.png')

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the tfd.GeneralizedPareto entry point and reproduce the supplied TensorFlow Probability versus SciPy comparison, focusing on values below loc. Check the documented support and probability behavior for shape >= 0; done means the implementation agrees with the documented support and the reported NaN behavior is covered by a regression test.
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