RE: [R] precision problem

From: John Fox <jfox_at_mcmaster.ca>
Date: Thu 26 May 2005 - 00:27:57 EST


Dear Omar,

Perhaps I'm missing something, but why not just subtract one matrix from the other and test the difference in relation to the precision that you require for the comparison? E.g., to test near equality, something like, abs(A - B) < 1e-13.

I hope this helps,
 John



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Omar Lakkis
> Sent: Wednesday, May 25, 2005 9:09 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] precision problem
>
> I have prices that I am finding difficult to compare with ==,
> > and >, due to precision. For example: the numbers should
> match, with '==', but they differ in the magnitude of 1e-14
> due to bunch of calculations that I run on them. Programming
> with java, I am used to implementing a function that compares
> the difference between the numbers to a pre determined
> precision factor. This could be very slow when I have two
> matrices of numbers that I could otherwise compare with a
> simple '==', '>' or '<' in R.
> What is teh best solution for this problem?
> Can I control the precision of ==, > and < without having to
> reimplement the operations in a slow way?
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 26 00:53:52 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:05 EST