Distance Between Points In Five Dimensions

You can compute the distance between points in one dimension by just subtracting their coordinates and taking the absolute value of the result. Here is the formula for the distance between two points 'a' and 'b' on a line.

$$distance( a,b ) = \sqrt{ (a-b)^2 }$$

This formula generalizes to multiple dimensions. In two dimensions it is the famous Pythagorean Theorem if you think of a line connecting the two points as the hypotenuse of a right triangle. Here is the formula for the distance between two points in the plane:

$$distance\left( \left( { a }_{ 1 },{ a }_{ 2 } \right) ,\left( { b }_{ 1 },{ b }_{ 2 } \right) \right) \quad =\quad \sqrt { { \left( { a }_{ 1 }-{ b }_{ 1 } \right) }^{ 2 }+{ { \left( { a }_{ 2 }-{ b }_{ 2 } \right) } }^{ 2 } } $$

For purposes of going beyond two dimensions I am going to drop the square root and instead write it as distance squared. This is the general formula that we get:

$${ d }^{ 2 }\left( \left( { a }_{ 1 },a_{ 2 },\quad ...\quad a_{ n } \right) ,\left( { b }_{ 1 },b_{ 2 },\quad ...\quad b_{ n } \right) \right) \quad =\quad \sum _{ i=1 }^{ n }{ { \left( { a }_{ i }-b_{ i } \right) }^{ 2 } } $$

The above formula is just the sum of the differences between the individual coordinats squared.

On to five dimensions:

Suppose you and your friend each pick five numbers at random. Also suppose once you pick a number you may not pick it again. Additionally suppose that you do not pay attention to the order that the numbers were picked.

One way to make sense of far apart the two picks are is to think of each group of five numbers as a "5-Tuple" or a point in five dimensional space and then figure out how far apart the two points are.

There is a problem with this idea if you did not pay attention to the order that the numbers were picked. To see this consider the two '5-Tuples' (1,2,3,4,5) and (4,2,3,4,5). These are different points in five dimensional space and their distance apart depens on the order you assign the numbers from the set {1,2,3,4,5}.

One way to deal with this is to consider all the possible choices for the value of the 5-Tuple. This amounts to all the permutations of five objects. There are 120 such values. To figure out how far apart the two picks are you could consider pairing up each of the 120 different values of one of the picks with each of the 120 different values of the other pick. This gives 120x120 or 14400 different pairs. If you add all these up and divide by 14400 you get the average distance between any two pairs of 5-Tuples.

So here is a python program that will compute this. In this program I call one of the 5-Tuples the "drawList" and the other 5-Tuple the "pickList". Also you need to include the library named 'itertools' in order to get the function that creates a list of the various permuatations of a list.

Don't Forget To "import itertools" |

You could also take the square roots of these numbers to see numbers that are the same scale as the original values.

## No comments:

## Post a Comment