class*, mean_func=< object>, cov_funcs=< object>)[source]#

Latent Gaussian process whose covariance is a tensor product kernel.

The gp.LatentKron class is a direct implementation of a GP with a Kronecker structured covariance, without reference to any noise or specific likelihood. The GP is constructed with the prior method, and the conditional GP over new input locations is constructed with the conditional method. conditional and method. For more information on these methods, see their docstrings. This GP implementation can be used to model a Gaussian process whose inputs cover evenly spaced grids on more than one dimension. LatentKron is relies on the KroneckerNormal distribution, see its docstring for more information.

cov_funcs: list of Covariance objects

The covariance functions that compose the tensor (Kronecker) product. Defaults to [zero].

mean_func: None, instance of Mean

The mean function. Defaults to zero.


# One dimensional column vectors of inputs
X1 = np.linspace(0, 1, 10)[:, None]
X2 = np.linspace(0, 2, 5)[:, None]
Xs = [X1, X2]
with pm.Model() as model:
    # Specify the covariance functions for each Xi
    cov_func1 =, ls=0.1)  # Must accept X1 without error
    cov_func2 =, ls=0.3)  # Must accept X2 without error

    # Specify the GP.  The default mean function is `Zero`.
    gp =[cov_func1, cov_func2])

    # ...

# After fitting or sampling, specify the distribution
# at new points with .conditional
# Xnew need not be on a full grid
Xnew1 = np.linspace(-1, 2, 10)[:, None]
Xnew2 = np.linspace(0, 3, 10)[:, None]
Xnew = np.concatenate((Xnew1, Xnew2), axis=1)  # Not full grid, works
Xnew = pm.math.cartesian(Xnew1, Xnew2)  # Full grid, also works

with model:
    fcond = gp.conditional("fcond", Xnew=Xnew)


LatentKron.__init__(*[, mean_func, cov_funcs])

LatentKron.conditional(name, Xnew[, jitter])

Returns the conditional distribution evaluated over new input locations Xnew.

LatentKron.marginal_likelihood(name, X, ...)

LatentKron.predict(Xnew[, point, given, ...])

LatentKron.prior(name, Xs[, jitter])

Returns the prior distribution evaluated over the input locations Xs.