def test_evaluate_hessian_respect_point(self): point = np.array([[4.5, 7.5]]) inputs = np.array([[5.0, 6.0], [8.0, 9.0]]) params = np.array([1.0, 5.0]) result = Matern52.evaluate_hessian_respect_point( params, point, inputs, 2) dh = 0.00001 finite_diff = FiniteDifferences.second_order_central( lambda x: Matern52.evaluate_cross_cov_defined_by_params( params, x.reshape((1, len(x))), inputs, 2), point[0, :], np.array([dh])) for i in xrange(2): for j in xrange(2): print i, j npt.assert_almost_equal( finite_diff[i, j], np.array([[result[0, i, j], result[1, i, j]]]), decimal=5)
def test_evaluate_hessian_respect_point(self): type_kernel = [MATERN52_NAME] training_data = { "evaluations": [42.2851784656, 72.3121248508, 1.0113231069, 30.9309246906, 15.5288331909], "points": [ [42.2851784656], [72.3121248508], [1.0113231069], [30.9309246906], [15.5288331909]], "var_noise": []} dimensions = [1] gp = GPFittingGaussian(type_kernel, training_data, dimensions) value = gp.evaluate_hessian_cross_cov_respect_point(np.array([[40.0]]), np.array([[39.0], [38.0]]), np.array([1.0])) value_2 = Matern52.evaluate_hessian_respect_point(np.array([1.0]), np.array([[40.0]]), np.array([[39.0], [38.0]]), 1) assert np.all(value == value_2)