diff --git a/docs/source/contrib.rst b/docs/source/contrib.rst index f4d80113e..abedf8dd7 100644 --- a/docs/source/contrib.rst +++ b/docs/source/contrib.rst @@ -251,7 +251,8 @@ approximate Bayesian Gaussian processes for probabilistic programming. Stat Comp 5. `Gelman, Vehtari, Simpson, et al., Bayesian workflow book - Birthdays `_. .. note:: - The code of this module is based on the code of the example `Example: Hilbert space approximation for Gaussian processes `_. + The code of this module is based on the code of the example + `Example: Hilbert space approximation for Gaussian processes `_ by `Omar Sosa Rodríguez `_. sqrt_eigenvalues ---------------- @@ -285,14 +286,14 @@ diag_spectral_density_periodic ------------------------------ .. autofunction:: numpyro.contrib.hsgp.spectral_densities.diag_spectral_density_periodic -hsgp_approximation_squared_exponential --------------------------------------- -.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_squared_exponential +hsgp_squared_exponential +------------------------ +.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_squared_exponential -hsgp_approximation_matern -------------------------- -.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_matern +hsgp_matern +----------- +.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_matern -hsgp_approximation_periodic_non_centered ------------------------------------------ -.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_periodic_non_centered +hsgp_periodic_non_centered +-------------------------- +.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_periodic_non_centered diff --git a/notebooks/source/hsgp_example.ipynb b/notebooks/source/hsgp_example.ipynb index 006810079..8d9a2dbba 100644 --- a/notebooks/source/hsgp_example.ipynb +++ b/notebooks/source/hsgp_example.ipynb @@ -44,7 +44,7 @@ "import jax.numpy as jnp\n", "\n", "import numpyro\n", - "from numpyro.contrib.hsgp.approximation import hsgp_approximation_squared_exponential\n", + "from numpyro.contrib.hsgp.approximation import hsgp_squared_exponential\n", "from numpyro.contrib.hsgp.laplacian import eigenfunctions\n", "from numpyro.contrib.hsgp.spectral_densities import (\n", " diag_spectral_density_squared_exponential,\n", @@ -187,7 +187,7 @@ " length = numpyro.sample(\"length\", dist.InverseGamma(concentration=6, rate=1))\n", " noise = numpyro.sample(\"noise\", dist.InverseGamma(concentration=12, rate=10))\n", " # --- Parametrization ---\n", - " f = hsgp_approximation_squared_exponential(\n", + " f = hsgp_squared_exponential(\n", " x=x, alpha=alpha, length=length, ell=ell, m=m, non_centered=non_centered\n", " )\n", " # --- Likelihood ---\n", diff --git a/numpyro/contrib/hsgp/approximation.py b/numpyro/contrib/hsgp/approximation.py index 57230389a..c119fdf9c 100644 --- a/numpyro/contrib/hsgp/approximation.py +++ b/numpyro/contrib/hsgp/approximation.py @@ -58,7 +58,7 @@ def linear_approximation( return _centered_approximation(phi, spd, m) -def hsgp_approximation_squared_exponential( +def hsgp_squared_exponential( x: ArrayImpl, alpha: float, length: float, @@ -99,7 +99,7 @@ def hsgp_approximation_squared_exponential( return linear_approximation(phi=phi, spd=spd, m=m, non_centered=non_centered) -def hsgp_approximation_matern( +def hsgp_matern( x: ArrayImpl, nu: float, alpha: float, @@ -140,7 +140,7 @@ def hsgp_approximation_matern( return linear_approximation(phi=phi, spd=spd, m=m, non_centered=non_centered) -def hsgp_approximation_periodic_non_centered( +def hsgp_periodic_non_centered( x: ArrayImpl, alpha: float, length: float, w0: float, m: int ) -> ArrayImpl: """ diff --git a/test/contrib/hsgp/test_approximation.py b/test/contrib/hsgp/test_approximation.py index 45ca135e1..6476454b6 100644 --- a/test/contrib/hsgp/test_approximation.py +++ b/test/contrib/hsgp/test_approximation.py @@ -8,9 +8,9 @@ import numpyro from numpyro.contrib.hsgp.approximation import ( - hsgp_approximation_matern, - hsgp_approximation_periodic_non_centered, - hsgp_approximation_squared_exponential, + hsgp_matern, + hsgp_periodic_non_centered, + hsgp_squared_exponential, ) import numpyro.distributions as dist from numpyro.handlers import scope, seed, trace @@ -48,9 +48,7 @@ def test_approximation_squared_exponential(x, alpha, length, ell, m, non_centere def model(x, alpha, length, ell, m, non_centered): numpyro.deterministic( "f", - hsgp_approximation_squared_exponential( - x, alpha, length, ell, m, non_centered - ), + hsgp_squared_exponential(x, alpha, length, ell, m, non_centered), ) rng_key = random.PRNGKey(0) @@ -74,7 +72,7 @@ def model(x, alpha, length, ell, m, non_centered): def test_approximation_matern(x, nu, alpha, length, ell, m, non_centered): def model(x, nu, alpha, length, ell, m, non_centered): numpyro.deterministic( - "f", hsgp_approximation_matern(x, nu, alpha, length, ell, m, non_centered) + "f", hsgp_matern(x, nu, alpha, length, ell, m, non_centered) ) rng_key = random.PRNGKey(0) @@ -102,7 +100,7 @@ def test_squared_exponential_gp_one_dim_model( def latent_gp(x, alpha, length, ell, m, non_centered): return numpyro.deterministic( "f", - hsgp_approximation_squared_exponential( + hsgp_squared_exponential( x=x, alpha=alpha, length=length, ell=ell, m=m, non_centered=non_centered ), ) @@ -141,7 +139,7 @@ def test_matern_gp_one_dim_model(synthetic_one_dim_data, nu, ell, m, non_centere def latent_gp(x, nu, alpha, length, ell, m, non_centered): return numpyro.deterministic( "f", - hsgp_approximation_matern( + hsgp_matern( x=x, nu=nu, alpha=alpha, @@ -191,7 +189,7 @@ def test_periodic_gp_one_dim_model(synthetic_one_dim_data, w0, m): def latent_gp(x, alpha, length, w0, m): return numpyro.deterministic( "f", - hsgp_approximation_periodic_non_centered( + hsgp_periodic_non_centered( x=x, alpha=alpha, length=length,