Cython module: bq_c

The functions in this module are called by the BQ object, and in most cases shouldn’t need to be called directly by user code. However, they are provided here for reference.

bayesian_quadrature.bq_c.Z_mean(__Pyx_memviewslice x_sc, __Pyx_memviewslice alpha_l, float64_t h_l, __Pyx_memviewslice w_l, __Pyx_memviewslice mu, __Pyx_memviewslice cov)

Compute the mean of the integral:

\[Z = \int \ell(x)\mathcal{N}(x \big\vert \mu, \Sigma)\ \mathrm{d}x\]

where the mean is defined as:

\[m(Z) = E[Z \big\vert \bar{\ell}(x_sc)]\]
Parameters :

x_sc : float64_t[::1, :]

\(d\times n\) vector of observed and candidate locations

alpha_l : float64_t[::1]

\(K_\ell(x_{sc}, x_{sc})^{-1}\bar{\ell}(x_{sc})\)

h_l : float64_t

output scale parameter for kernel \(K_\ell\)

w_l : float64_t[::1]

\(d\) vector of lengthscales for kernel \(K_\ell\)

mu : float64_t[::1]

\(d\) prior mean

cov : float64_t[::1, :]

\(d\times d\) prior covariance

Returns :

out : mean of \(Z\)

bayesian_quadrature.bq_c.Z_var(__Pyx_memviewslice x_s, __Pyx_memviewslice x_sc, __Pyx_memviewslice alpha_l, __Pyx_memviewslice L_tl, float64_t h_l, __Pyx_memviewslice w_l, float64_t h_tl, __Pyx_memviewslice w_tl, __Pyx_memviewslice mu, __Pyx_memviewslice cov)

Compute the variance of the integral:

\[Z = \int \ell(x)\mathcal{N}(x \big\vert \mu, \Sigma)\ \mathrm{d}x\]

where the variance is defined as:

\[V(Z) = \int\int m_\ell(x) C_{\log\ell}(x, x^\prime) m_\ell(x^\prime) p(x)p(x^\prime)\ \mathrm{d}x\ \mathrm{d}x^\prime\]
Parameters :

x_s : float64_t[::1, :]

\(d\times n_s\) vector of observed locations

x_sc : float64_t[::1, :]

\(d\times n_{sc}\) vector of observed and candidate locations

alpha_l : float64_t[::1]

\(K_\ell(x_{sc}, x_{sc})^{-1}\bar{\ell}(x_{sc})\)

L_tl : float64_t[::1, :]

lower-triangular Cholesky factor of \(K_{\log\ell}(x_{s}, x_{s})\)

h_l : float64_t

output scale parameter for kernel \(K_\ell\)

w_l : float64_t[::1]

\(d\) vector of lengthscales for kernel \(K_\ell\)

h_tl : float64_t

output scale parameter for kernel \(K_{\log\ell}\)

w_tl : float64_t[::1]

\(d\) vector of lengthscales for kernel \(K_{\log\ell}\)

mu : float64_t[::1]

\(d\) prior mean

cov : float64_t[::1, :]

\(d\times d\) prior covariance

Returns :

out : variance of \(Z\)

bayesian_quadrature.bq_c.approx_Z_mean(__Pyx_memviewslice xo, __Pyx_memviewslice p_xo, __Pyx_memviewslice l)

Approximate the mean of the integral:

\[Z = \int \ell(x)p(x)\ \mathrm{d}x\]
Parameters :

xo : float64_t[::1, :]

\(d\times n\) vector of approximation locations

p_xo : float64_t[::1]

\(n\) vector prior probabilities at approximation locations

l : float64_t[::1]

\(n\) vector of likelihood evaluated at approximation locations

Returns :

out : approximate mean of \(Z\)

bayesian_quadrature.bq_c.approx_Z_var(__Pyx_memviewslice xo, __Pyx_memviewslice p_xo, __Pyx_memviewslice m_l, __Pyx_memviewslice C_tl)

Approximate the variance of the integral:

\[Z = \int \ell(x)p(x)\ \mathrm{d}x\]

where the variance is defined as:

\[V(Z) = \int\int m_\ell(x) C_{\log\ell}(x, x^\prime) m_\ell(x^\prime) p(x)p(x^\prime)\ \mathrm{d}x\ \mathrm{d}x^\prime\]
Parameters :

xo : float64_t[::1, :]

\(d\times n\) vector of approximation locations

p_xo : float64_t[::1]

\(n\) vector prior probabilities at approximation locations

m_l : float64_t[::1]

\(n\) vector of likelihoods evaluated at approximation locations

C_tl : float64_t[::1, :]

\(n\times n\) covariance matrix for \(\log\ell\) evaluated at approximation locations

Returns :

out : approximate variance of \(Z\)

bayesian_quadrature.bq_c.approx_expected_squared_mean_and_mean(__Pyx_memviewslice l_sc, __Pyx_memviewslice K_l, float64_t tm_a, float64_t tC_a, __Pyx_memviewslice xo, __Pyx_memviewslice p_xo, __Pyx_memviewslice Kxxo)

Approximates the expected squared mean and expected mean of \(Z\) given a new observation at \(x_a\).

\[E[m(Z)^2 \big\vert x_a] = \int m(Z | \ell_s, \ell_a)^2 \mathcal{N}(\log\ell_a | \hat{m}_a, \hat{C}_a)\ \mathrm{d}\log\ell_a\]
Parameters :

l_sc : float64_t[::1]

\(n_{sc}\) vector of observed and candidate locations

K_l : float64_t[::1, :]

\(n_{sca}\times n_{sca}\) kernel matrix \(K_{\ell}(x_{sca}, x_{sca})\)

tm_a : float64_t

prior mean of \(\log\ell_a\)

tC_a : float64_t

prior variance of \(\log\ell_a\)

xo : float64_t[::1, :]

\(d\times m\) vector of approximation locations

Kxxo : float64_t[::1, :]

\(n_{sca}\times m\) kernel matrix

mu : float64_t[::1]

\(d\) mean

cov : float64_t[::1, :]

\(d\times d\) covariance

Returns :

out : approximate expected squared mean and expected mean of \(Z\)

bayesian_quadrature.bq_c.expected_squared_mean_and_mean(__Pyx_memviewslice l_sc, __Pyx_memviewslice K_l, float64_t tm_a, float64_t tC_a, __Pyx_memviewslice x_sca, float64_t h_l, __Pyx_memviewslice w_l, __Pyx_memviewslice mu, __Pyx_memviewslice cov)

Computes the expected squared mean and expected mean of \(Z\) given a new observation at \(x_a\).

\[E[m(Z)^2 \big\vert x_a] = \int m(Z | \ell_s, \ell_a)^2 \mathcal{N}(\log\ell_a | \hat{m}_a, \hat{C}_a)\ \mathrm{d}\log\ell_a\]
Parameters :

l_sc : float64_t[::1]

\(n_{sc}\) vector of observed and candidate locations

K_l : float64_t[::1, :]

\(n_{sca}\times n_{sca}\) kernel matrix \(K_{\ell}(x_{sca}, x_{sca})\)

tm_a : float64_t

prior mean of \(\log\ell_a\)

tC_a : float64_t

prior variance of \(\log\ell_a\)

x_sca : float64_t[::1, :]

\(d\times n_{sca}\) input vector

h_l : float64_t

output scale kernel parameter for \(K_\ell\)

w_l : float64_t[::1]

\(d\) vector of lengthscales for \(K_\ell\)

mu : float64_t[::1]

\(d\) mean

cov : float64_t[::1, :]

\(d\times d\) covariance

Returns :

out : expected squared mean and expected mean of \(Z\)

bayesian_quadrature.bq_c.filter_candidates(__Pyx_memviewslice x_c, __Pyx_memviewslice x_s, float64_t thresh)

Given a vector of possible candidate locations, \(x_c\), filter out locations which are close to one or more observations \(x_s\), or to other candidate locations.

Parameters :

x_c : float64_t[::1]

potential candidate locations

x_s : float64_t[::1]

observed locations

thresh : float64_t

minimum allowed distance

bayesian_quadrature.bq_c.improve_covariance_conditioning(__Pyx_memviewslice M, __Pyx_memviewslice jitters, __Pyx_memviewslice idx)

Add noise to the indices idx along the diagonal of M. Update the corresponding locations in the jitters vector to include this new noise.

bayesian_quadrature.bq_c.p_x_gaussian(__Pyx_memviewslice p_x, __Pyx_memviewslice x, __Pyx_memviewslice mu, __Pyx_memviewslice cov)

Computes the Gaussian PDF of input locations \(x\).

Parameters :

p_x : float64_t[::1]

\(n\) output vector of probabilities

x : float64_t[::1, :]

\(d\times n\) input locations

mu : float64_t[::1]

\(d\) mean vector

cov : float64_t[::1, :]

\(d\times d\) covariance matrix

bayesian_quadrature.bq_c.p_x_vonmises(__Pyx_memviewslice p_x, __Pyx_memviewslice x, float64_t mu, float64_t kappa)

Computes the Von Mises PDF of input locations \(x\).

Parameters :

p_x : float64_t[::1]

\(n\) output vector of probabilities

x : float64_t[::1, :]

\(n\) input vector of locations

mu : float64_t[::1]

mean parameter

kappa : float64_t[::1, :]

spread parameter

bayesian_quadrature.bq_c.remove_jitter(__Pyx_memviewslice M, __Pyx_memviewslice jitters, __Pyx_memviewslice idx)

Remove noise from the indices idx along the diagonal of M. Set the corresponding locations in the jitters vector to zero.

bayesian_quadrature.bq_c.vonmises_logpdf(float64_t x, float64_t mu, float64_t kappa) → float64_t

Computes the log-PDF for the Von Mises distribution at location \(x\):

\[p(x | \mu, \kappa) = \frac{\exp(\kappa\cos(x-\mu))}{2\pi I_0(\kappa)}\]

Where \(I_0\) is the Bessel function of order 0.

Parameters :

x : float64_t

Input angle (radians)

mu : float64_t

Mean angle (radians)

kappa : float64_t

Spread parameter

Returns :

out : value of the log-PDF

Previous topic

Utilities

Next topic

Cython module: gauss_c

This Page