Skip to content
Back to formatted view

Raw Message

Message-ID: <OFBDAD82BB.1659F58D-ONC125786A.0056192C-C125786A.0056788F@precheza.cz>
Date: 2011-04-06T15:43:48Z
From: PIKAL Petr
Subject: Odp:  Decimal Accuracy Loss?
In-Reply-To: <BANLkTinEr9drmhozA2htH_seu0avWEYfjg@mail.gmail.com>

Hi

r-help-bounces at r-project.org napsal dne 06.04.2011 17:33:48:

> This is hopefully a quick question on decimal accuracy.  Is any
> decimal accuracy lost when casting a numeric vector as a matrix?  And
> then again casting the result back to a numeric?
> 
> I'm finding that my calculation values are different when I run for
> loops that manually calculate matrix multiplication as compared to
> when I cast the vectors as matrices and multiply them using "%*%".
> (The errors are very small, but the process is run iteratively
> thousands of times, at which point the error between the two
> differences becomes noticeable.)
> 
> I've read FAQ # 7.31 "Why doesn't R think these numbers are equal?",
> but just want to confirm that the differences in values are due to
> differences in the matrix multiplication operator and manual
> calculation via for loops, rather than information that is lost when
> casting a numeric as a matrix and back again.

Without some example it is difficult to see the possible sources of 
difference. Clever people may know how %*% operator really works, but only 
those who are able mind reading can know what you do inside your for 
loops.

Regards
Petr


> 
> Thanks in advance for the help,
> Brigid
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.