Sparse GPs summarise N training points through M≪N inducing inputs Z, cutting the cost from O(N3) to O(NM2). Implement sparse_gp_predict(X, y, Z, X_star, ell, sf, sn, method) for the SE kernel k(x,x′)=σf2exp(−∥x−x′∥2/(2ℓ2)), returning the predictive mean and the latent variance at X_star.
Notation: KZZ (add 10−8I jitter), KXZ, K∗Z, σ2= sn**2, and QAB=KAZKZZ−1KZB.
method="sor" (subset of regressors): Σ=(KZZ+σ−2KZXKXZ)−1; mean σ−2K∗ZΣKZXy; variance diag(K∗ZΣKZ∗).
method="fitc": Λ=diag(diag(KXX)−diag(QXX))+σ2I; Σ=(KZZ+KZXΛ−1KXZ)−1; mean K∗ZΣKZXΛ−1y; variance diag(K∗∗)−diag(Q∗∗)+diag(K∗ZΣKZ∗).
Inputs may be 1-D arrays (one feature). Only M×M systems may be solved; never build an N×N matrix. Return (mean, var).