-1

I am trying to reverse the process presented here. Specifically, I need to go back to the original vector that generated a matrix of absolute distances between elements.

For example I have a NxN matrix named A (with people names on rows and columns), where each cell Aij has the value of |age_i-age_j|, representing the absolute difference in age between the two people i and j. I need to convert this matrix into a vector which reports the age of this N people.

The matrix could be:

A = matrix( c(0, 5, 42, 5, 0, 37, 42, 37, 0), nrow=3, ncol=3, byrow = TRUE) 

and i want to transform it into this vector:

tmp <- c(18, 23, 60) 

To go from the vector to the matrix I would have used this command:

A <- abs(outer(tmp, tmp, "-"))

what I'm trying to do is to reverse the process.

Forinstance
  • 413
  • 4
  • 17
  • This is mathematically not possible. If you just add any positive integer to your 'tmp' example, you would still get your A matrix. – EugenR Nov 04 '17 at 09:58
  • Then the problem would be getting to any of the possible vectors which could generate the matrix. – Forinstance Nov 04 '17 at 10:19

1 Answers1

0

Ok, then I will try to answer it. I suggest you first initiate possible vector with any integer

seed <- 18

then you create your answer

answer <- seed + A[,1]

HTH

EugenR
  • 176
  • 6
  • Thank you. However, this does not seem to work on large matrices where starting values are not integers.. Any idea of why? – Forinstance Nov 06 '17 at 09:40