Ejemplo n.º 1
0
def test_contruct_c_matrix_7d_with_xi():
    """Test if 7d second derivative matrix with x=0.1 is constructed correctly"""
    c_matrix = np.array([[-0.9, 1, 0, 0, 0, 0, 0], [1, -1.9, 1, 0, 0, 0, 0],
                         [0, 1, -1.9, 1, 0, 0, 0], [0, 0, 1, -1.9, 1, 0, 0],
                         [0, 0, 0, 1, -1.9, 1, 0], [0, 0, 0, 0, 1, -1.9, 1],
                         [0, 0, 0, 0, 0, 1, -0.9]])
    assert np.array_equal(c_matrix, helpers.calc_second_deriv_matrix(7, 0.1))
Ejemplo n.º 2
0
 def __init__(self, x_ini, b, A, cov):
     """
     x_ini: numpy histogram with the initial Monte Carlo distribution
     used to build the response matrix
     b: numpy histogram with the measured data distribution that we want to unfold
     A: 2d numpy array with the response matrix (n_b x n_x)
     cov: 2d numpy array with the covariance matrix
     """
     self._b_measured = b
     self._x_ini = x_ini
     self._response_matrix = A
     self._covariance_matrix = cov
     self._X_inv = None
     self._S = None
     self._d = None
     n_bins_b = len(self._b_measured[0])
     n_bins_x = len(self._x_ini[0])
     self._C = helpers.calc_second_deriv_matrix(n_bins_x, 0.01)
     self._C_inv = helpers.calc_inverse_second_deriv_matrix(self._C)
     assert(self._response_matrix.shape[0] == n_bins_b),\
         "Wrong dimensions: bins in b != rows in response matrix"
     assert(self._response_matrix.shape[1] == n_bins_x),\
         "Wrong dimensions: bins in x_ini != columns in response matrix"
     assert helpers.check_symmetric(self._covariance_matrix), \
         "Covariance matrix is not symmetric"
     assert(n_bins_b > 1 and n_bins_x > 1),\
         "Bins should be at least 2"
Ejemplo n.º 3
0
def test_contruct_c_matrix_7d():
    """Test if 7d second derivative matrix is constructed correctly"""
    c_matrix = np.array([[-1, 1, 0, 0, 0, 0, 0], [1, -2, 1, 0, 0, 0, 0],
                         [0, 1, -2, 1, 0, 0, 0], [0, 0, 1, -2, 1, 0, 0],
                         [0, 0, 0, 1, -2, 1, 0], [0, 0, 0, 0, 1, -2, 1],
                         [0, 0, 0, 0, 0, 1, -1]])
    assert np.array_equal(c_matrix, helpers.calc_second_deriv_matrix(7, 0))