Re: [R] Precision in R

2018-02-26 Thread William Dunlap via R-help
In the R expression x[1] + x[2] the result must be stored as a double precision number, because that is what R "numerics" are. sum() does not have to keep its intermediate results as doubles, but can use quad precision or Kahan's summation algorithm (both methods involve more than a simple doub

Re: [R] Precision in R

2018-02-26 Thread Thierry Onkelinx
This is described in R FAQ 7.31 ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkel...@inbo.

Re: [R] Precision in R

2018-02-26 Thread Jeff Newmiller
On Sun, 25 Feb 2018, Iuri Gavronski wrote: Hi, Why sum() on a 10-item vector produces a different value than its counterpart on a 2-item vector? I understand the problems related to the arithmetic precision in storing decimal numbers in binary format, but shouldn't the errors be equal regardles

[R] Precision in R

2018-02-25 Thread Iuri Gavronski
Hi, Why sum() on a 10-item vector produces a different value than its counterpart on a 2-item vector? I understand the problems related to the arithmetic precision in storing decimal numbers in binary format, but shouldn't the errors be equal regardless of the method used? See my example: > opti

Re: [R] Precision in R

2009-01-15 Thread David Winsemius
On Jan 15, 2009, at 12:25 PM, Charles C. Berry wrote: This is what I get on windows XP: tcp1-tcp2 [,1] [,2] [,3] [1,] -2.861023e-06 -4.768372e-07 -4.768372e-07 [2,] -4.768372e-07 -3.814697e-06 2.622604e-06 [3,] -4.768372e-07 2.622604e-06 -5.960464e-08 bu

Re: [R] Precision in R

2009-01-15 Thread Duncan Murdoch
On 1/15/2009 1:32 PM, David Winsemius wrote: On Jan 15, 2009, at 12:25 PM, Charles C. Berry wrote: This is what I get on windows XP: tcp1-tcp2 [,1] [,2] [,3] [1,] -2.861023e-06 -4.768372e-07 -4.768372e-07 [2,] -4.768372e-07 -3.814697e-06 2.622604e-06 [3,] -4.

Re: [R] Precision in R

2009-01-15 Thread dos Reis, Marlon
Hi there, Thanks for the help. I see now where my results are coming from. Marlon. -Original Message- From: Charles C. Berry [mailto:cbe...@tajo.ucsd.edu] Sent: Friday, 16 January 2009 6:26 a.m. To: dos Reis, Marlon Cc: David Winsemius; r-help@r-project.org Subject: RE: [R] Precision in

Re: [R] Precision in R

2009-01-15 Thread Charles C. Berry
ited accuracy of floating point calcs on the system used. HTH, Chuck Marlon. -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, 15 January 2009 6:04 p.m. To: Charles C. Berry Cc: dos Reis, Marlon; r-help@r-project.org Subject: Re: [R] Precision in R I

Re: [R] Precision in R

2009-01-15 Thread David Winsemius
81608.66 109642.09 [3,] -78368.17 109642.09 -147305.32 solve(tcp2) Error in solve.default(tcp2) : system is computationally singular: reciprocal condition number = 2.17737e-17 Marlon. -Original Message- From: Charles C. Berry [mailto:cbe...@tajo.ucsd.edu] Sent: Thursday, 15 January 2009 5:16

Re: [R] Precision in R

2009-01-14 Thread dos Reis, Marlon
ent: Thursday, 15 January 2009 5:16 p.m. To: dos Reis, Marlon Cc: r-help@r-project.org Subject: Re: [R] Precision in R Marlon, Are you using a current version of R? sessionInfo()? It would help if you had something we could _fully_ reproduce. Taking the _printed_ values you have below (WBtWB)

Re: [R] Precision in R

2009-01-14 Thread dos Reis, Marlon
age- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, 15 January 2009 6:04 p.m. To: Charles C. Berry Cc: dos Reis, Marlon; r-help@r-project.org Subject: Re: [R] Precision in R I am seeing different behavior than don Reis on my installation as well: mtx is the same as his WBtW

Re: [R] Precision in R

2009-01-14 Thread David Winsemius
I am seeing different behavior than don Reis on my installation as well: mtx is the same as his WBtWB > mtx <- matrix(c(1916061939, 2281366606, 678696067, 2281366606, 3098975504, 1092911209, 678696067, 1092911209, 452399849), ncol=3) > > mtx [,1] [,2] [,3] [1,] 1916061

Re: [R] Precision in R

2009-01-14 Thread Charles C. Berry
Marlon, Are you using a current version of R? sessionInfo()? It would help if you had something we could _fully_ reproduce. Taking the _printed_ values you have below (WBtWB) and adding or subtracting what you have printed as the difference of the two visually equal matrices ( say Delta ) ,

Re: [R] Precision in R

2009-01-14 Thread dos Reis, Marlon
rom: Nathan S. Watson-Haigh [mailto:nathan.watson-ha...@csiro.au] Sent: Thursday, 15 January 2009 3:25 p.m. To: dos Reis, Marlon Cc: r-help@r-project.org Subject: Re: [R] Precision in R -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've recently been working with cross products etc. You should try the follow

Re: [R] Precision in R

2009-01-14 Thread Albyn Jones
Yes, computing WB.%*%t(WB) may be the problem, by either method. if the goal is to compute the inverse of WB%*%t(WB), you should consider computing the singular value or QR decomposition for the matrix WB. If WB = Q%*%R, where Q is orthogonal, then WB %*% t(WB) =R %*%t(R), and the inverse of

Re: [R] Precision in R

2009-01-14 Thread Nathan S. Watson-Haigh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've recently been working with cross products etc. You should try the following function: tcp1 <- tcrossprod(WB) or tcp2 <- crossprod(t(WB)) Both should be the same (check for equality accounting for some floating point imprecision): all.equal(tcp1

[R] Precision in R

2009-01-14 Thread dos Reis, Marlon
Dear All, I'm preparing a simple algorithm for matrix multiplication for a specific purpose, but I'm getting some unexpected results. If anyone could give a clue, I would really appreciate. Basically what I want to do is a simple matrix multiplication: (WB) %*% t(WB). The WB is in the disk so I com