meslas.covariance package

Submodules

meslas.covariance.cross_covariances module

Cross-covariance models.

class meslas.covariance.cross_covariances.LinearTrendCrossCov(gamma0, sigma0s, betas, s0)

Bases: object

Create a linear trend cross-covariance.

Parameters:
gamma0: Tensor

Coupling parameter.

sigma0s: (p) Tensor

Vector of individual standard deviation (constant part) for each to the p components.

betas: (p, n_dim) Tensor

List of vectors of linear trends for each of the p components. The final model is sigma_i(s) = sigma0s[i] + betas[i, :] * s.

Returns:
function(L1, L2)

Methods

__call__(S1, L1, S2, L2)

class meslas.covariance.cross_covariances.ParabolicTrendCrossCov(gamma0, sigma0s, betas, s0)

Bases: object

Create a parabolic trend cross-covariance.

Parameters:
gamma0: Tensor

Coupling parameter.

sigma0s: (p) Tensor

Vector of individual standard deviation (constant part) for each to the p components.

betas: (p, n_dim, n_dim) Tensor

Parabolic trend defined by a quadratic form for each component. The final model is

sigma_i(s) = sigma0s[i] + (s - s0)**2 * betas[i, :, :] * (s - s0)**2.

Returns:
function(L1, L2)

Methods

__call__(S1, L1, S2, L2)

class meslas.covariance.cross_covariances.UniformMixing(gamma0, sigmas)

Bases: object

Create a uniform mixing cross-covariance.

Parameters:
gamma0: Tensor

Coupling parameter.

sigmas: (p) Tensor

Vector of individual standard deviation for each to the p components.

Returns:
function(L1, L2)

Methods

__call__(S1, L1, S2, L2)

meslas.covariance.heterotopic module

Code for multidimensional sampling. We will be considering multivariate random fields Z=(Z^1, …, Z^p). The term response index denotes the index of the component of the field we ate considering.

We will sometime use the word measurement point to denote a (location, response index) pair.

We will be using the notation conventions from the papers.

x’s will denote a location j’s will denote reponse a index

Uppercase for concatenated quantities, i.e. a big X is a vector of x’s.

First dimension of tensors represent the different samples/locations (batch dimension). Other dimensions are for the “dimensions” of the repsonse (or input domain).

THIS IS FOR HETEROTOPIC SAMPLING (most general form).

# TODO: Inmplement convenience methods for full sampling (all indices).

Conventions

Spatial locations will be denoted by s, capital letters for bunches. Response indices denoted by l. Couple of (locations, response indices) denoted by x.

class meslas.covariance.heterotopic.FactorCovariance(spatial_cov, cross_cov, n_out)

Bases: object

General (not necessarily stationary) separable covariance function.

Parameters:
spatial_cov: function(H)

Spatial covariance function.

cross_cov: function(L1, L2)

Cross-covariance function.

n_out: int

Number of output dimensions.

Methods

K(S1, S2, L1, L2)

Same as above, but for vector of measurements.

K(S1, S2, L1, L2)

Same as above, but for vector of measurements.

Parameters:
S1: (M, d) Tensor

Spatial location vector. Note if d=1, should still have two dimensions.

S2: (N, d) Tensor

Spatial location vector.

L1: (M) Tensor

Response indices vector.

L2: (N) Tensor

Response indices vector.

Returns:
K: (M, N) Tensor

Covariane matrix between the two sets of measurements.

class meslas.covariance.heterotopic.FactorStationaryCovariance(spatial_cov, cross_cov, n_out)

Bases: StationaryCovariance

Convenience class for specifiying a factor model.

Parameters:
spatial_cov: function(H)

Spatial covariance function.

cross_cov: function(L1, L2)

Cross-covariance function.

n_out: int

Number of output dimensions.

class meslas.covariance.heterotopic.StationaryCovariance(factor_stationary_cov)

Bases: object

Stationary covariance function.

Parameters:
factor_stationary_cov: function(H, L1, L2)

Covariance function. Only allow covariances that factor into a stationary spatial part that only depends on the euclidean distance matrix H and a purely response index component. L1 and L2 are the index matrix.

n_out: int

Number of output dimensions.

Methods

K(S1, S2, L1, L2)

Same as above, but for vector of measurements.

K(S1, S2, L1, L2)

Same as above, but for vector of measurements.

Parameters:
S1: (M, d) Tensor

Spatial location vector. Note if d=1, should still have two dimensions.

S2: (N, d) Tensor

Spatial location vector.

L1: (M) Tensor

Response indices vector.

L2: (N) Tensor

Response indices vector.

Returns:
K: (M, N) Tensor

Covariane matrix between the two sets of measurements.

meslas.covariance.old module

Saving ideas from the first reflections about implementation.

meslas.covariance.old.K_isotopic(X1, X2, J_full)

Compute the covariance matrices between all components of X1 and X2. Saves time since distance between each point are only computed once (would need to compute once for each response index otherwise.

meslas.covariance.old.k(x1, x2, j1, j2)

Computes (cross)-covariance between a set of measures.

TODO: We only consider stationary, so maybe get rid of x1, x2 and just consider h.

Parameters:
x1: Tensor

Locations of first measurement.

j1: Tensor

Response index of first measurement.

x2: Tensor

Locations of second measurement.

j2: Tensor

Response index of second measurement.

Returns:
Scalar Tensor

Cross-covariance between Z^j1(x1) and Z^j2(x2).

meslas.covariance.old.mu(X, J)

computes mean vector for given set of locations/response indices.

meslas.covariance.old.sample(X, J, seed=0)

Sample a multivariate random field at measurement points (X,J).

Returns:
Tensor

Shape (X.shape[0]), sampled values.

meslas.covariance.old.sample_isotopic(X)

Sample all response components at given locations.

meslas.covariance.spatial_covariance_functions module

Basic covariance functions.

meslas.covariance.spatial_covariance_functions.Matern32(lmbda, sigma=1.0)

Create a Matern32 covariance function.

Note that in the multivariate case, we usually set sigma to 1 and define the variances in the cross-covariance function.

Parameters:
lmbda: Tensor

Lengthscale parameter.

sigma: Tensor

Standard deviation.

Returns:
function(H)

Matern32 covariance function.Take matrix of euclidean distances as input.

Module contents