Skip to content
Prev 303701 / 398502 Next

moving distance between two sets of data

On Aug 19, 2012, at 4:34 PM, White, William Patrick wrote:

            
The phrase "a moving absolute deviation" admits of several  
interpretations. I suggest you post the correct answer for some simple  
cases or that you be more mathematical in your description (as is  
suggested in the Posting Guide.)

set.seed(123)
  X <- sample(-5:5, 10)
  Y <- sample(-5:5, 10);

 > X
  [1] -2  2  5  4  1 -5 -3  3 -4  0
 > Y
  [1]  5 -1  1  4 -5  0 -4  3 -2  2
 > abs( tail(X,9) - head(Y,9) )
[1] 3 6 3 3 0 3 7 7 2

So this is c( abs(X[2] -Y[1]), abs( X[3]-Y[2], .....)
Again. Not a clear description (of what you do do not want), given  
that the problem involves two vectors.
David Winsemius, MD
Alameda, CA, USA