I have the following data array m:
import numpy as np
a = [[1],[0],[1],[0],[0]]
b = [[1],[0],[1],[0],[0]]
c = d = [[1],[0],[1],[0],[0]]
m = np.hstack((a,b,c,d))
m
array([[1, 0, 1, 1],
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0],
[0, 1, 0, 0]])
I have the following vector prior
prior = [0.1,0.2,0.3,0.4]
I now want to create a new vector of length 5, where each row of m is summed according to this scheme
if 1 then add 1/prior
if 0 then add 0.1*1/prior
so for the first row in m we would get
(1/0.1)+(0.1*1/0.2)+(1/0.3)+(1/0.4) = 16.33
the second row is
(0.1*1/0.1)+(0.1*1/0.2)+(0.1*1/0.3)+(0.1*1/0.4) = 2.083
m should be the basis and numpy may be used (perhaps .sum(axis=1)) ?
Aucun commentaire:
Enregistrer un commentaire