Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Measure distance between all points

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Measure distance between all points

Mar 1, 2019 12:54 PM
(178 views)

I am trying to determine a meausre of how distance from a point effects measurements to find a minimum / maximum point within range of points.

I tried to do this in the attached files but I cannot find a way to do this programatically. I tried to do this by concatenating a table of N rows, N times, copying the XY coulmn, sorting Y then X then pastingn this sorted column into the NxN table.

I tried to do this with EVAL / SUBSTITUTION but cannot get it to successfuly execute.

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Measure distance between all points

Did you see the Distance() function? Here is an example from the Scripting Index of a script using it:

```
Names Default To Here( 1 );
/*1-D example*/
exX1 = [1, 2, 3, 4];
exX2 = [2, 4, 6, 8];
/*Compute squared Euclidean distance*/
exD = Distance( exX1, exX2 );
/*Verify result*/
exDm = J( 4, 4, . );
For( exi = 1, exi <= 4, exi++,
For( exj = 1, exj <= 4, exj++,
exDm[exi, exj] =
Sum( (exX1[exi, 0] - exX2[exj, 0]) ^ 2 )
)
);
Show( exDm == exD );
/*2-D example*/
exX1 = [1 1, 2 2, 3 3, 4 4];
exX2 = [2 1, 4 2, 6 0, 8 7];
/*Compute squared Euclidean distance*/
exD = Distance( exX1, exX2 );
/*Verify result*/
exDm = J( 4, 4, . );
For( exi = 1, exi <= 4, exi++,
For( exj = 1, exj <= 4, exj++,
exDm[exi, exj] =
Sum( (exX1[exi, 0] - exX2[exj, 0]) ^ 2 )
)
);
Show( exDm == exD );
/*2-D example*/
exX1 = [1 1, 2 2, 3 3, 4 4];
exX2 = [2 1, 4 2, 6 0, 8 7];
/*Compute squared Euclidean distance, with a scaler [0.5 2.0]*/
exD = Distance( exX1, exX2, [0.5 2.0] );
/*Verify result*/
exDm = J( 4, 4, . );
For( exi = 1, exi <= 4, exi++,
For( exj = 1, exj <= 4, exj++,
exDm[exi, exj] =
Sum(
[0.5 2.0] :* (
Abs( exX1[exi, 0] - exX2[exj, 0] ) ^ 2)
)
)
);
Show( exDm == exD );
/*2-D example*/
exX1 = [1 1, 2 2, 3 3, 4 4];
exX2 = [2 1, 4 2, 6 0, 8 7];
/*Compute squared Euclidean distance, with scalers [0.5 2.0] and powers [1.5 2.0]*/
exD = Distance( exX1, exX2, [0.5 2.0], [1.5 2.0] );
/*Verify result*/
exDm = J( 4, 4, . );
For( exi = 1, exi <= 4, exi++,
For( exj = 1, exj <= 4, exj++,
exDm[exi, exj] =
Sum(
[0.5 2.0] :* (
Abs( exX1[exi, 0] - exX2[exj, 0] ) :^ [
1.5 2.0])
)
)
);
Show( exDm == exD );
```

Learn it once, use it forever!