[BioC] poor precision of matrix inverse?

Misha Kapushesky ostolop at ebi.ac.uk
Mon Nov 22 18:16:38 CET 2010


Try solve(b) %*% b.

--Misha

On Mon, 22 Nov 2010, zack liu wrote:

> Dear members,
>
> I am using "solve" to compute the inverse of a 5 by 5 matrix using R and
> matlab.  The results are quite interesting..  It seems that R has very poor
> precision in terms of calculating inverse of a matrix.
>
> Can someone tell me if I should use other functions to computer matrix
> inverse?
>
>
> R Code
>
> ------------
>
>> b
>            [,1]       [,2]        [,3]        [,4]        [,5]
> [1,]  1.00000000 0.02522892 -0.09181110  0.03656846 -0.01403095
> [2,]  0.02522892 1.00000000  0.12764892  0.05252468  0.05174332
> [3,] -0.09181110 0.12764892  1.00000000 -0.01334807  0.02270218
> [4,]  0.03656846 0.05252468 -0.01334807  1.00000000 -0.08303199
> [5,] -0.01403095 0.05174332  0.02270218 -0.08303199  1.00000000
>> solve(b)
>            [,1]        [,2]        [,3]        [,4]        [,5]
> [1,]  1.01117403 -0.03672483  0.09683324 -0.03282862  0.01116385
> [2,] -0.03672483  1.02393425 -0.13360444 -0.05881784 -0.05534769
> [3,]  0.09683324 -0.13360444  1.02646994  0.01604039 -0.01369944
> [4,] -0.03282862 -0.05881784  0.01604039  1.01166293  0.08621905
> [5,]  0.01116385 -0.05534769 -0.01369944  0.08621905  1.01049046
>> solve(b) *b
>              [,1]          [,2]          [,3]          [,4]          [,5]
> [1,]  1.0111740259 -0.0009265279 -0.0088903666 -0.0012004920 -0.0001566394
> [2,] -0.0009265279  1.0239342521 -0.0170544622 -0.0030893886 -0.0028638734
> [3,] -0.0088903666 -0.0170544622  1.0264699443 -0.0002141082 -0.0003110073
> [4,] -0.0012004920 -0.0030893886 -0.0002141082  1.0116629287 -0.0071589398
> [5,] -0.0001566394 -0.0028638734 -0.0003110073 -0.0071589398  1.0104904599
>
>
> Matlab Code
> ___________________
>
>>> b
>
> b =
>
>    1.0000    0.0252   -0.0918    0.0366   -0.0140
>    0.0252    1.0000    0.1276    0.0525    0.0517
>   -0.0918    0.1276    1.0000   -0.0133    0.0227
>    0.0366    0.0525   -0.0133    1.0000   -0.0830
>   -0.0140    0.0517    0.0227   -0.0830    1.0000
>
>>> b^-1
>
> ans =
>
>    1.0112   -0.0367    0.0968   -0.0328    0.0112
>   -0.0367    1.0239   -0.1336   -0.0588   -0.0553
>    0.0968   -0.1336    1.0265    0.0160   -0.0137
>   -0.0328   -0.0588    0.0160    1.0117    0.0862
>    0.0112   -0.0553   -0.0137    0.0862    1.0105
>
>>> b^-1 *b
>
> ans =
>
>    1.0000   -0.0000   -0.0000   -0.0000    0.0000
>   -0.0000    1.0000   -0.0000   -0.0000   -0.0000
>   -0.0000   -0.0000    1.0000    0.0000   -0.0000
>   -0.0000   -0.0000    0.0000    1.0000   -0.0000
>         0   -0.0000    0.0000    0.0000    1.0000
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>



More information about the Bioconductor mailing list