Skip to content

Commit

Permalink
Adds the VonMisesFisher distribution over points on the unit hypersph…
Browse files Browse the repository at this point in the history
…ere.

The sampling algorithm is due to Wood'94.
The pdf currently uses a recurrence for bessel_iN which isn't great for large N (WIP on better bessel_ive).

Tests are based on importance sampling the surface area of a [hyper]spherical cap.

Fixes tensorflow/tensorflow#6141

PiperOrigin-RevId: 205891121
  • Loading branch information
brianwa84 authored and Copybara-Service committed Jul 24, 2018
1 parent ae307bf commit 4a6cc02
Show file tree
Hide file tree
Showing 4 changed files with 787 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tensorflow_probability/python/distributions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ py_library(
":vector_laplace_linear_operator",
":vector_sinh_arcsinh_diag",
":vector_student_t",
":von_mises_fisher",
":wishart",
# numpy dep,
# tensorflow dep,
Expand Down Expand Up @@ -497,6 +498,15 @@ py_library(
],
)

py_library(
name = "von_mises_fisher",
srcs = ["von_mises_fisher.py"],
deps = [
# numpy dep,
# tensorflow dep,
],
)

py_library(
name = "wishart",
srcs = ["wishart.py"],
Expand Down Expand Up @@ -1026,6 +1036,19 @@ py_test(
],
)

py_test(
name = "von_mises_fisher_test",
size = "medium",
srcs = ["von_mises_fisher_test.py"],
deps = [
":distributions",
# numpy dep,
# tensorflow dep,
"//tensorflow_probability",
"//tensorflow_probability/python/internal:test_util",
],
)

py_test(
name = "vector_student_t_test",
size = "medium",
Expand Down
2 changes: 2 additions & 0 deletions tensorflow_probability/python/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
from tensorflow_probability.python.distributions.vector_exponential_diag import VectorExponentialDiag
from tensorflow_probability.python.distributions.vector_laplace_diag import VectorLaplaceDiag
from tensorflow_probability.python.distributions.vector_sinh_arcsinh_diag import VectorSinhArcsinhDiag
from tensorflow_probability.python.distributions.von_mises_fisher import VonMisesFisher
from tensorflow_probability.python.distributions.wishart import Wishart

from tensorflow_probability.python.internal.distribution_util import fill_triangular
Expand Down Expand Up @@ -174,6 +175,7 @@
'VectorDiffeomixture',
'VectorLaplaceDiag',
'VectorSinhArcsinhDiag',
'VonMisesFisher',
'Wishart',
'TransformedDistribution',
'QuantizedDistribution',
Expand Down
Loading

0 comments on commit 4a6cc02

Please sign in to comment.