def test_pq(self):
"""Tests that the experiment can generate the p and q matrix
"""
exp = SimpleExperiment()
# Generate some simulation data
sim_data = self.simSimp(self.models)
# Align the data so that it is evaluated at the same time steps as
# the experiment
aligned_data = exp.align(sim_data)
# Get the sensitivity matrix
sens_matrix = self.simSimp.get_sens(self.models, ['simp'], aligned_data)
# Get the error between the sim and experiment
epsilon = exp.compare(sim_data)
p_mat, q_vec = exp.get_pq(self.models, ['simp'], sim_data, sens_matrix,
scale=False)
sigma_mat = exp.get_sigma()
p_mat_hat = np.dot(np.dot(sens_matrix.T, np.linalg.inv(sigma_mat)),
sens_matrix)
npt.assert_array_equal(p_mat, p_mat_hat,
err_msg="P matrix calculated incorrectly")
q_vec_hat = -np.dot(np.dot(epsilon, np.linalg.inv(sigma_mat)),
sens_matrix)
npt.assert_array_equal(q_vec, q_vec_hat,
err_msg="q vector calculated incorrectly")
评论列表
文章目录