# What does “DistanceMatrix::mlcntinft: The feature type of {List,{1,-1}} cannot be interpreted.” mean?

What does this error message mean?
The following code does work as expected, but it also gives the error message above.

Position[
{{1, -1.1}, {-0, 8, 0.1}, {-1.1, 2}},
_?(Min[DistanceMatrix[{#}, {{-1, 1}}]] > 2 &),
1]

Out:{{2}, {3}}


Google returned nothing except the documentation for DistanceMatrix. The error message only happens when the function is used within the Position function, and when calculating distances to multi-dimensional vectors. The following two lines work without error messages:

Position[{1, -0.8, -1.1}, _?(Min[DistanceMatrix[{#}, {1}]] > 2 &), 1]
Out: {{3}}

(Min[DistanceMatrix[{#}, {{1, -1}}]] > 2 &)[{1, 0}]
Out: False


I'm using DistanceMatrix instead of EuclideanDistance in order to calculate the same thing for multiple vectors. I only used one here for brevity.

• Are you aware of the difference between Position[..., {k}] and Position[..., k]? They are not the same thing for k != 1. – Szabolcs Mar 2 '17 at 17:07
• Yeah I was aware, but I never explicitly made the connection that for k=1 they are equivalent. – ZeitPolizei Mar 3 '17 at 7:48

## First: What does the error message mean?

The error message indicates, that DistanceMatrix doesn't know how it should calculate all the distances, because the list elements don't all have the same number of dimensions. You get the same error in the following two cases:

DistanceMatrix[{{2, 3}, 4}, {{1, 3}, 5}]
DistanceMatrix[{{2, 3}, {4, 2}}, {1, 3, 5}]


## Second: Why does the error message occur?

Position by default also checks the Head of an expression, which is at index 0. For example:

Position[{1, -0.8, -1.1}, _?(Min[DistanceMatrix[{#}, {1}]] < 2 &), 1]
Out: {{0}, {1}, {2}}


…because for some reason the distance between a symbol and and any number is always 1 in DistanceMatrix. See:

DistanceMatrix[{List}, {1, 3, -2, 0}]
Out: {{1, 1, 1, 1}}


So to avoid the error message you can either add the Heads->False Option like so:

Position[
{{1, -1.1}, {-0, 8, 0.1}, {-1.1, 2}},
_?(Min[DistanceMatrix[{#}, {{-1, 1}}]] > 2 &),
1,

Position[