Skip to content

Commit

Permalink
Implement stopping ratio logistic distribution
Browse files Browse the repository at this point in the history
Hello,

this PR again implements the stopping ratio logistic distribution which was already discussed and reviewed [here](#963).

@srvasude , sorry for closing the other PR. I worked in your requested changes other than the transpose that needs to be done when sampling.

Thanks.

Cheers,
Simon

COPYBARA_INTEGRATE_REVIEW=#990 from dirmeier:stopping_ratio 0743b54
PiperOrigin-RevId: 346376187
  • Loading branch information
dirmeier authored and tensorflower-gardener committed Dec 8, 2020
1 parent 49b6da0 commit 9bcd1f0
Show file tree
Hide file tree
Showing 4 changed files with 567 additions and 30 deletions.
90 changes: 60 additions & 30 deletions tensorflow_probability/python/distributions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ multi_substrate_py_library(
":sinh_arcsinh",
":skellam",
":spherical_uniform",
":stopping_ratio_logistic",
":student_t",
":student_t_process",
":transformed_distribution",
Expand Down Expand Up @@ -587,6 +588,21 @@ multi_substrate_py_library(
],
)

multi_substrate_py_library(
name = "exponentially_modified_gaussian",
srcs = ["exponentially_modified_gaussian.py"],
deps = [
":distribution",
":exponential",
":normal",
# tensorflow dep,
"//tensorflow_probability/python/internal:dtype_util",
"//tensorflow_probability/python/internal:prefer_static",
"//tensorflow_probability/python/internal:reparameterization",
"//tensorflow_probability/python/internal:tensor_util",
],
)

multi_substrate_py_library(
name = "finite_discrete",
srcs = ["finite_discrete.py"],
Expand Down Expand Up @@ -1762,6 +1778,23 @@ multi_substrate_py_library(
],
)

multi_substrate_py_library(
name = "stopping_ratio_logistic",
srcs = ["stopping_ratio_logistic.py"],
deps = [
":distribution",
":kullback_leibler",
# tensorflow dep,
"//tensorflow_probability/python/internal:assert_util",
"//tensorflow_probability/python/internal:distribution_util",
"//tensorflow_probability/python/internal:dtype_util",
"//tensorflow_probability/python/internal:prefer_static",
"//tensorflow_probability/python/internal:reparameterization",
"//tensorflow_probability/python/internal:tensor_util",
"//tensorflow_probability/python/internal:tensorshape_util",
],
)

multi_substrate_py_library(
name = "half_student_t",
srcs = ["half_student_t.py"],
Expand Down Expand Up @@ -2443,6 +2476,21 @@ multi_substrate_py_test(
],
)

multi_substrate_py_test(
name = "exponentially_modified_gaussian_test",
srcs = ["exponentially_modified_gaussian_test.py"],
jax_size = "medium",
# Disable numpy test for now because a bug in the types returned by special_math.ndtr
numpy_tags = ["notap"],
deps = [
# numpy dep,
# scipy dep,
# tensorflow dep,
"//tensorflow_probability",
"//tensorflow_probability/python/internal:test_util",
],
)

multi_substrate_py_test(
name = "finite_discrete_test",
size = "medium",
Expand Down Expand Up @@ -3414,6 +3462,18 @@ multi_substrate_py_test(
],
)

multi_substrate_py_test(
name = "stopping_ratio_logistic_test",
srcs = ["stopping_ratio_logistic_test.py"],
deps = [
# absl/testing:parameterized dep,
# numpy dep,
# tensorflow dep,
"//tensorflow_probability",
"//tensorflow_probability/python/internal:test_util",
],
)

multi_substrate_py_test(
name = "half_student_t_test",
size = "medium",
Expand Down Expand Up @@ -3781,33 +3841,3 @@ py_binary(
"//tensorflow_probability/python/distributions:hypothesis_testlib",
],
)

multi_substrate_py_library(
name = "exponentially_modified_gaussian",
srcs = ["exponentially_modified_gaussian.py"],
deps = [
":distribution",
":exponential",
":normal",
# tensorflow dep,
"//tensorflow_probability/python/internal:dtype_util",
"//tensorflow_probability/python/internal:prefer_static",
"//tensorflow_probability/python/internal:reparameterization",
"//tensorflow_probability/python/internal:tensor_util",
],
)

multi_substrate_py_test(
name = "exponentially_modified_gaussian_test",
srcs = ["exponentially_modified_gaussian_test.py"],
jax_size = "medium",
# Disable numpy test for now because a bug in the types returned by special_math.ndtr
numpy_tags = ["notap"],
deps = [
# numpy dep,
# scipy dep,
# tensorflow dep,
"//tensorflow_probability",
"//tensorflow_probability/python/internal:test_util",
],
)
2 changes: 2 additions & 0 deletions tensorflow_probability/python/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
from tensorflow_probability.python.distributions.sinh_arcsinh import SinhArcsinh
from tensorflow_probability.python.distributions.skellam import Skellam
from tensorflow_probability.python.distributions.spherical_uniform import SphericalUniform
from tensorflow_probability.python.distributions.stopping_ratio_logistic import StoppingRatioLogistic
from tensorflow_probability.python.distributions.student_t import StudentT
from tensorflow_probability.python.distributions.student_t_process import StudentTProcess
from tensorflow_probability.python.distributions.transformed_distribution import TransformedDistribution
Expand Down Expand Up @@ -225,6 +226,7 @@
'SinhArcsinh',
'Skellam',
'SphericalUniform',
'StoppingRatioLogistic',
'StudentT',
'StudentTProcess',
'Triangular',
Expand Down
Loading

0 comments on commit 9bcd1f0

Please sign in to comment.