def test_quadratic_misfit_model(self): num_dims = 10 rank = 3 num_qoi = 3 obs = np.random.normal(0., 1., (num_qoi)) model = QuadraticMisfitModel(num_dims, rank, num_qoi, obs) sample = np.random.normal(0., 1., (num_dims)) helper_gradient(model.value, model.gradient, sample)
def test_neg_log_posterior(self): num_dims = 10 rank = 3 num_qoi = 3 obs = np.random.normal(0., 1., (num_qoi)) noise_covariance = np.eye(num_qoi)*0.1 misfit_model = QuadraticMisfitModel( num_dims, rank, num_qoi, obs, noise_covariance=noise_covariance) prior_mean = np.ones((num_dims), float) prior_covariance = np.eye(num_dims)*0.25 prior_density = NormalDensity(prior_mean, covariance=prior_covariance) objective = LogUnormalizedPosterior( misfit_model, misfit_model.gradient_set, prior_density.pdf, prior_density.log_pdf, prior_density.log_pdf_gradient) sample = np.random.normal(0., 1., (num_dims)) helper_gradient(misfit_model.value, misfit_model.gradient, sample)