[Numpy-discussion] Numpy inverse giving incorrect result

Pauli Virtanen pav at iki.fi
Wed May 23 16:03:59 EDT 2012


23.05.2012 11:22, shbr kirjoitti:
> I am running the following script as a basic input-output model but the
> inverse function is bringing back an incorrect result (I have checked this
> by inputting the data manually).I am very new to python but I assume the
> error occurs in how the data is gathered from the csv but I don’t know how
> to fix this. Any advice would be much appreciated. 

>From your explanation it is unfortunately not clear what actually does
not work, and what you would expect as results. Can you clarify?

The inverse certainly gives the correct result:

>>> conMatrix = numpy.matrix('0.4102 0.0301 0.0257; 0.0624 0.3783 0.1050; 0.1236 0.1588 0.1919') 
>>> eyesee = numpy.eye(3) - conMatrix
>>> eyesee.I
matrix([[ 1.72033888,  0.10060528,  0.06778402],
        [ 0.22456355,  1.67684212,  0.22502129],
        [ 0.30725724,  0.34490452,  1.29205728]])
>>> eyesee.I * eyesee
matrix([[  1.00000000e+00,  -3.46944695e-18,   0.00000000e+00],
        [  2.42861287e-17,   1.00000000e+00,   0.00000000e+00],
        [  2.77555756e-17,   0.00000000e+00,   1.00000000e+00]])




More information about the NumPy-Discussion mailing list