3

I'm trying to reproduce the computations that led to a data set data.ref. I'd like to test how well my current implementation does by comparing the reference data to my computed results, data.my. Since each column of the data should have comparable magnitudes within the column, but not necessarily between columns, I've been looking at

(data.ref - data.my) / data.ref

to put errors on a comparable scale. However, since the data is ultimately going to be rounded off, what I'd really like to do is just run a quick and dirty check of how many significant figures worth of agreement the data has. That is, since I expect data.ref and data.my to be quite close to each other, I'd like the answer the question: what is the first significant figure at which each pair of corresponding entries differs?

Is there an R function that does this?

Empiromancer
  • 3,778
  • 1
  • 22
  • 53

1 Answers1

1

ceiling(log10(abs(data.ref, data.my))) seems to do the trick.

Example:

> data.my <- c(20, 30, 32, 32.01, 32.012)
> data.ref <- rep(32, length(data.my))
> ceiling(log10(abs(data.my - data.ref)))
[1]    2    1 -Inf   -2   -1
Karl Forner
  • 4,175
  • 25
  • 32