I have two matrices. The calculation of the sum over axis=1
. Then I want to transpose the obtained result. The result incorporates in expression. You must be elements of the matrix 1 and 2 calculates the sum, row by row.
Do you need to transpose the array of sum or is there some other way?
matrix1 = [[ 5. 4. 3. 5. 3.]
[ 5. 7. 8. 2. 2.]
[ 8. 2. 4. 0. 3.]
[ 7. 2. 5. 3. 5.]
[ 3. 1. 3. 0. 2.]]
matrix2 = [[ 5. 7. 6. 5. 4.]
[ 3. 45. 2. 3. 4.]
[ 2. 4. 6. 4. 3.]
[ 3. 4. 5. 6. 54.]
[ 4. 3. 6. 7. 5.]]
s_1 = np.array(matrix_1.sum(axis=1))
s_1 = np.array(matrix_2.sum(axis=1))
s_1T = np.transpose(s_1)
s_2T = np.transpose(s_2)
Result:
S_1T
[ 20. 24. 17. 22. 9.]
S_2T
[ 27. 57. 19. 72. 25.]
How to transpose the array?
FROM
[ 20. 24. 17. 22. 9.]
[ 27. 57. 19. 72. 25.]
TO
[20.
24.
17.
22.
9.]
[27.
57.
19.
72.
25.]
Transposed array using in the expression:
result = ((matrix_2 - matrix_1)/matrix_1)/((s_2T-s_1T)/s_1T)