def cov_bonilla(X0, Y, theta): #Kx = mk52(np.array(X0)[:, 1:], [theta.l1, theta.l2], theta.sig_m) Kx = squared(np.array(X0)[:, 1:], [theta.l1, theta.l2], theta.sig_m) Kx = Kx + 1E-6 * np.eye(Kx.shape[0]) if unitary is not None: Ks = np.array([[1.0, float(unitary)], [float(unitary), 1.0]]) else: L = np.array([ np.array([theta.rho[str(sorted([i, j]))] if i >= j else 0.0 for j in range(theta.n_IS)]) # Lower triangulary for i in range(theta.n_IS) ]) Ks = L.dot(L.T) e = np.diag(np.array([theta.e1, theta.e2])) Ks = np.matmul(e, np.matmul(Ks, e)) K = np.kron(Ks, Kx) return np.kron(Ks, Kx)
def cov_bonilla(X0, Y, theta): Kx = squared(np.array(X0)[:, 1:], [theta.l1, theta.l2], theta.sig_1) Kx = Kx + 1E-6 * np.eye(Kx.shape[0]) if use_J: Ks = np.ones((theta.n_IS, theta.n_IS)) * (1.0 - 1E-6) + np.eye( theta.n_IS) * 1E-6 elif use_I: Ks = np.eye(theta.n_IS) elif dpc and invert_dpc: Ks = np.array([ np.array([ 1.0 if i != j else theta.rho["[0, %d]" % i]**(-2.0) for j in range(theta.n_IS) ]) for i in range(theta.n_IS) ]) elif dpc: Ks = np.array([ np.array([ theta.rho[str(sorted([i, j]))] for j in range(theta.n_IS) ]) for i in range(theta.n_IS) ]) else: L = np.array([ np.array([ theta.rho[str(sorted([i, j]))] if i >= j else 0.0 for j in range(theta.n_IS) ]) for i in range(theta.n_IS) ]) # Force it to be positive semi-definite Ks = L.dot(L.T) if theta.n_IS == 2: e = np.diag(np.array([theta.e1, theta.e2])) elif theta.n_IS == 3: e = np.diag(np.array([theta.e1, theta.e2, theta.e3])) else: raise Exception("HOW?") Ks = e.dot(Ks.dot(e)) return np.kron(Ks, Kx)
def cov_pricm(X0, Y, theta, split=False): Kx = squared(np.array(X0), [theta.l1], theta.sig_1) Kx = Kx + 1E-6 * np.eye(Kx.shape[0]) if model.lower() == "pricm": Ks = np.array([ np.array([ theta.rho[str(sorted([i, j]))] for j in range(theta.n_IS) ]) for i in range(theta.n_IS) ]) elif model.lower() == "icm": L = np.array([ np.array([ theta.rho[str(sorted([i, j]))] if i >= j else 0.0 for j in range(theta.n_IS) ]) for i in range(theta.n_IS) ]) # Force it to be positive semi-definite Ks = L.dot(L.T) if split: return Ks, Kx else: return np.kron(Ks, Kx)
def cov_miso(X0, Y, theta, split=False): Kx = squared(np.array(X0), [theta.l1], theta.sig_1) Kx_l = squared(np.array(X0), [theta.l2], theta.sig_2) return np.block([[Kx, Kx], [Kx, Kx + Kx_l]])
def cov(X0, Y, theta): return squared(np.array(X0), [theta.l1], theta.sig_1)
def cov(X0, Y, theta): return squared(np.array(X0)[:, 1:], [theta.l1, theta.l2], theta.sig_1)
def cov_miso(X0, Y, theta): Kx = squared(np.array(X0)[:, 1:], [theta.l1, theta.l2], theta.sig_1) Kx_l = squared(np.array(X0)[:, 1:], [theta.l3, theta.l4], theta.sig_2) return np.block([[Kx, Kx], [Kx, Kx + Kx_l]])