assertnp.all(np.isclose(m2.numerical_parameter_hessian(),np.array([[2,0],[0,2]]))),"Numerical approximation to Hessian doesn't match. Error in numerical_parameter_hessian()."
assertnp.isclose(m2.param0,1,atol=0.01),"Failed to find likelihood maximum of test model's param0 while testing CCD"
assertnp.isclose(m2.param1,2,atol=0.01),"Failed to find likelihood maximum of test model's param1 while testing CCD"
ccdpos,ccdres=m2.CCD()
m2.optimize()
assertnp.all(np.isclose(np.sum((ccdpos-np.array([1,2]))**2,1)[1:],1.21,atol=0.01)),"CCD placement error - should be 1.21 from mode"
assertnp.all(np.isclose(m1.numerical_parameter_hessian(),np.eye(dims)*2)),"Numerical approximation to Hessian doesn't match. Error in numerical_parameter_hessian()."
peak_loc=range(1,dims+1)
fordinrange(dims):
assertnp.isclose(m1.params[d],d+1,atol=0.01),"Failed to find likelihood maximum of test model's parameter while testing CCD"
assertnp.all(np.isclose(dists,np.mean(dists),atol=0.01)),"CCD placement error - should be 1.21 from mode, for nd symmetrical Quadratic test case"
assertnp.all(np.isclose(np.sum(ccdres[1:]/ccdres[0]),4.7619,atol=0.1)),"CCD placement error - off-centre locations should have log likelihood ratios to central point summing to 4.76 times the centre, for nd symmetrical Quadratic test case"
fordimsinrange(1,5):
stepsize=0.3*dims#make step size bigger as dims goes up so this isn't too slow
assertnp.isclose(hessum,numsum,atol=0.2),"Laplace approximation using numerical_parameter_hessian()=%0.4f not equal to numerical grid sum=%0.4f"%(hessum,numsum)
#Test numerical_parameter_hessian gives us the right integral for a more complex GP model