def test_scalar_derivs(self): surrogate = KrigingSurrogate(nugget=0.) x = np.array([[0.], [1.], [2.], [3.]]) y = x.copy() surrogate.train(x, y) jac = surrogate.linearize(np.array([[0.]])) assert_rel_error(self, jac[0][0], 1., 1e-3)
def test_vector_derivs(self): surrogate = KrigingSurrogate() n = 15 x = np.array([[a, b] for a, b in itertools.product(np.linspace(0, 1, n), repeat=2)]) y = np.array([[a+b, a-b, a+2*b] for a, b in x]) surrogate.train(x, y) jac = surrogate.linearize(np.array([[0.5, 0.5]])) assert_near_equal(jac, np.array([[1, 1], [1, -1], [1, 2]]), 5e-4)
def test_scalar_derivs(self): surrogate = KrigingSurrogate() x = array([[0.], [1.], [2.], [3.]]) y = x.copy() surrogate.train(x, y) jac = surrogate.linearize(array([[0.]])) assert_rel_error(self, jac[0][0], 1., 1e-3)
def test_vector_derivs(self): surrogate = KrigingSurrogate() x = array([[a, b] for a, b in itertools.product(linspace(0, 1, 10), repeat=2)]) y = array([[a+b, a-b] for a, b in x]) surrogate.train(x, y) jac = surrogate.linearize(array([[0.5, 0.5]])) assert_rel_error(self, jac, array([[1, 1], [1, -1]]), 1e-5)
def test_vector_derivs(self): surrogate = KrigingSurrogate() n = 15 x = np.array([[a, b] for a, b in itertools.product(np.linspace(0, 1, n), repeat=2)]) y = np.array([[a+b, a-b, a+2*b] for a, b in x]) surrogate.train(x, y) jac = surrogate.linearize(np.array([[0.5, 0.5]])) assert_rel_error(self, jac, np.array([[1, 1], [1, -1], [1, 2]]), 5e-4)