tensorflow / tensorflow/probability
Feature request to implement ~.cdf() method in MultivariateNormalTriL class
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 21.04
TensorFlow installed from (source or binary): binary
TensorFlow versions:
$ python -c "import tensorflow as tf; import tensorflow_probability as tfp; print(tf.version.GIT_VERSION, tf.version.VERSION, tfp.__version__)"
v2.5.0-rc3-213-ga4dfb8d1a71 2.5.0 0.13.0
Issue
I am trying to get the cumulative distribution function for a bivariate normal distribution, here is the code:
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
tf.compat.v1.enable_eager_execution()
mvn = tfd.MultivariateNormalTriL(loc=[0,0], scale_tril=tf.linalg.cholesky([[1,0.5],[0.5,1]]))
mvn.cdf([0,0])
And here is the error that I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/distributions/distribution.py", line 1438, in cdf
return self._call_cdf(value, name, **kwargs)
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/distributions/distribution.py", line 1414, in _call_cdf
return self._cdf(value, **kwargs)
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/distributions/transformed_distribution.py", line 407, in _cdf
self.bijector._internal_is_increasing(**bijector_kwargs), # pylint: disable=protected-access
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/bijector.py", line 1171, in _internal_is_increasing
return self._call_is_increasing(name, **kwargs)
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/bijector.py", line 1155, in _call_is_increasing
return tf.identity(self._is_increasing(**kwargs))
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/chain.py", line 147, in _is_increasing
is_increasing, b._internal_is_increasing(**kwargs.get(b.name, {}))) # pylint: disable=protected-access
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/bijector.py", line 1171, in _internal_is_increasing
return self._call_is_increasing(name, **kwargs)
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/bijector.py", line 1155, in _call_is_increasing
return tf.identity(self._is_increasing(**kwargs))
File "/home/alexlembcke/.local/lib/python3.9/site-packages/tensorflow_probability/python/bijectors/bijector.py", line 1150, in _is_increasing
raise NotImplementedError('`_is_increasing` not implemented.')
NotImplementedError: `_is_increasing` not implemented.
If I adapt the code to use scipy, like so:
from scipy.stats import multivariate_normal
mvn = multivariate_normal(mean=[0,0], cov=[[1,0.5],[0.5,1]])
mvn.cdf([0, 0])
Then everything works fine. Is this a bug or am I doing something wrong in my tensorflow code?
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 MultivariateNormalTriL cdf entry point and reproduce the supplied TensorFlow example, comparing its expected behavior with the SciPy example. Done means the bivariate normal CDF request works and the behavior is covered by regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100