Ejemplo n.º 1
0
def gaussian(x,u,C):
    res=(1/sqrt(2*math.pi*abs(Matrix.determinant(C))))
    temp=Matrix.transpose(Matrix.minus(x, u))
    temp=Matrix.multiply(temp, Matrix.inverse(C))
    temp=Matrix.multiply(temp,Matrix.minus(x, u))
    try:
        res*=exp(-0.5*temp[0][0])
    except:
        print(temp[0][0])
        print(x)
        print(u)
        print(C)
    return res
Ejemplo n.º 2
0
 def test_determinant(self):
     A=[[1,-9,13,7],[-2,5,-1,3],[3,-1,5,-5],[2,8,-7,-10]]
     expected_result=-312
     actual_result=Matrix.determinant(A)
     self.assertEqual(expected_result, actual_result)