test_Bayesian.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:F_UNCLE 作者: fraserphysics 项目源码 文件源码
def test_sens(self):
        """Test the sign and magnitude of the sensitivity
        """
        initial_data = {'simple': self.sim1({'simp': self.model})}
        sens_matrix = self.bayes._get_sens(initial_data=initial_data)

        indep = np.arange(10)
        resp_mat = np.array([(1.02 * 2 * indep)**2 + 1 * indep -
                             (2 * indep)**2 - indep,
                             (2 * indep)**2 + 1.02 * indep -
                             (2 * indep)**2 - 1 * indep])
        inp_mat = np.array([[0.02 * 2, 0], [0, 0.02]])
        true_sens = np.linalg.lstsq(inp_mat, resp_mat)[0].T

        npt.assert_array_almost_equal(sens_matrix['simple'], true_sens,
                                      decimal=8,
                                      err_msg='Sens matrix  not as predicted')

        resp_mat2 = resp_mat
        resp_mat2[0, :] /= 0.04
        resp_mat2[1, :] /= 0.02

        npt.assert_array_almost_equal(sens_matrix['simple'], resp_mat2.T,
                                      decimal=8,
                                      err_msg='Sens matrix  not as predicted')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号