cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
connquest
Level I

How to create a distance matrix in JMP PRO 13

I have a sall data table and I'm trying to figure out if there is a way to have JMP Pro 13 create a distance matx against some raw data and then for the standardized data to see if normalizing the data changes which two records are farthest from each other in termsf Euclidean distance?  Can someone point me in the direction of where I go in the JMP tool to have it generate the distance matrix? 

1 ACCEPTED SOLUTION

Accepted Solutions
cwillden
Super User (Alumni)

Re: How to create a distance matrix in JMP PRO 13

There's a scripting command for that, Distance().  Check out the documentation in the Scripting Index (Help > Scripting Index).

The trick will just be using the same vector or matrix for both arguments.  Here's some examples:

//1-D example
x = [1, 2, 3, 4];
D = sqrt(Distance( x, x )); 

//2-D example
x2 = [1 1, 2 2, 3 3, 4 4];
D = sqrt(Distance( x2, x2 )); 

If your data is in a table, see the commands Get As Matrix (to get an entire data table as a matrix) and Get Values (e.g. col1 << Get Values) to get a specific column as a vector.  You can also find these in the Scripting Index and Spripting Guide (Help > Books).

-- Cameron Willden

View solution in original post

3 REPLIES 3
cwillden
Super User (Alumni)

Re: How to create a distance matrix in JMP PRO 13

There's a scripting command for that, Distance().  Check out the documentation in the Scripting Index (Help > Scripting Index).

The trick will just be using the same vector or matrix for both arguments.  Here's some examples:

//1-D example
x = [1, 2, 3, 4];
D = sqrt(Distance( x, x )); 

//2-D example
x2 = [1 1, 2 2, 3 3, 4 4];
D = sqrt(Distance( x2, x2 )); 

If your data is in a table, see the commands Get As Matrix (to get an entire data table as a matrix) and Get Values (e.g. col1 << Get Values) to get a specific column as a vector.  You can also find these in the Scripting Index and Spripting Guide (Help > Books).

-- Cameron Willden

Re: How to create a distance matrix in JMP PRO 13

This is an older post, but doing some research on some distance based methods, and came across this.  In more recent versions of JMP, you can create a distance matrix table using the Hierarchical Clustering platform, available as a command under the red triangle menu.  Here is a JSL example that does an example.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Birth Death Subset.jmp" );
obj = dt << Hierarchical Cluster(
	Y( :birth, :death ),
	Label( :country ),
	Save Distance Matrix
);
ron_horne
Super User (Alumni)

Re: How to create a distance matrix in JMP PRO 13

hi @connquest ,
in the past we had this discussion:
https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19258... 
which is useful in some application.