Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motivation for allowing zero rate in Poisson in v0.11.0? #1025

Closed
matthewfeickert opened this issue Jul 28, 2020 · 3 comments · Fixed by scikit-hep/pyhf#1657
Closed

Motivation for allowing zero rate in Poisson in v0.11.0? #1025

matthewfeickert opened this issue Jul 28, 2020 · 3 comments · Fixed by scikit-hep/pyhf#1657

Comments

@matthewfeickert
Copy link
Contributor

matthewfeickert commented Jul 28, 2020

Hi. 👋 As part of TensorFlow Probability v0.11.0 0b66e74 allowed for zero rates in the Poisson distribution, which is a pretty important change. It has a direct impact on our library and it also now diverges from all other major tensor libraries in behavior as

Python virtual environment used

(in a fresh Python virtual environment called tfp-issue)

(tfp-issue) $ pip install -q pyhf[backends]==0.5.0
(tfp-issue) $ pip list | grep tensorflow
tensorflow             2.3.0
tensorflow-estimator   2.3.0
tensorflow-probability 0.11.0

the following example

import pyhf


def main():
    backends = ["numpy", "pytorch", "tensorflow", "jax"]

    for backend in backends:
        pyhf.set_backend(backend, precision="64b")
        tb = pyhf.tensorlib
        values = tb.astensor([0, 0, 1, 1])
        rates = tb.astensor([0, 1, 0, 1])
        poisson_results = tb.tolist(tb.poisson(values, rates))
        print(f"{backend} backend gives: {poisson_results}")


if __name__ == "__main__":
    main()

gives

numpy backend gives: [nan, 0.36787944117144233, 0.0, 0.36787944117144233]
pytorch backend gives: [nan, 0.36787944117144233, 0.0, 0.36787944117144233]
tensorflow backend gives: [1.0, 0.3678794411714423, 0.0, 0.3678794411714423]
jax backend gives: [nan, 0.367879441171442, 0.0, 0.367879441171442

(The above is using pyhf to call down to the backends, but I can write a pure NumPy, TensorFlow, JAX, and PyTorch example if that would be helpful/of interest.)

As this change was explicitly made we understand that there was a reason for it, but it would be helpful for us to understand what that was so we can appropriately expect and alter TensorFlow Probability's behavior if necessary. Can the TFP dev team comment on the motivations for this change?

Also thank you for developing TensorFlow Probability — we really appreciate that we can use it.

Related Issue/PR

cc @lukasheinrich @kratsg

@matthewfeickert matthewfeickert changed the title Motivation for allowing zero rate in Poisson? Motivation for allowing zero rate in Poisson in v0.11.0? Jul 28, 2020
@brianwa84
Copy link
Contributor

I think the comment in scikit-hep/pyhf#293 (comment) explains the reasoning well. In general in TFP we try to consider measure-zero boundaries as in-support if possible. It seems in this case like the poisson is well defined, i.e. when rate is 0 the number of events observed over any given interval is always zero.

@kratsg
Copy link

kratsg commented Jul 28, 2020

I think the comment in scikit-hep/pyhf#293 (comment) explains the reasoning well. In general in TFP we try to consider measure-zero boundaries as in-support if possible.

This is a fine justification, however, it would certainly deviate from all other libraries.

It seems in this case like the poisson is well defined, i.e. when rate is 0 the number of events observed over any given interval is always zero.

The Poisson for rate parameter 0 is never well-defined (e.g. https://en.wikipedia.org/wiki/Poisson_distribution). Note that if you are going to use this reasoning, you would justify having P(0|0)=0, instead of P(0|0)=1. It would have to be somewhat of a degenerate distribution. Does this mean tensorflow_probability is defining 0^0 = 1 [because this is the only way to allow it for the Poisson]?

@matthewfeickert
Copy link
Contributor Author

Closing as was resolved in pyhf by scikit-hep/pyhf#1657.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants