Re: [R] Decimal Accuracy Loss?

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Wed, 06 Apr 2011 08:45:06 -0700

Confirmed. "Casting" just adds/removes the dim attribute to the numeric vector/matrix.

On Wed, Apr 6, 2011 at 8:33 AM, Brigid Mooney <bkmooney_at_gmail.com> wrote:
> 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.
>
> 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.
>

-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
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.
Received on Wed 06 Apr 2011 - 15:48:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 16:10:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive