Absolute value between all pointsI was wondering if there is an easy way to aggregate the absolute value of all points in a column to one another. I have written some scripts which will give me the stage location data for a tool, but I want to see how the locations measure up relative to themselves rather than the absolute locations of the machine.
For example:
If I have 3 points, I want to know the distance between 1-2, 1-3, and 2-3.
If I have 4 points, I want to know the distance between 1-2, 1-3, 1-4, 2-3, 2-4, and 3-4.
And so on...
For small data sets this can easily be done, but I have data sets ranging from 20-100 points. I am looking for something built in or possibly an idea to script the solution. Any help is much appreciated.
Re: Absolute value between all pointsPerfect! Thank you, this was indeed easy for my application.
I have a python script running that extracts and then reads the location data from an XML file into a CSV. Then I am using JMP to analyze the stage locations from the CSV. So, I don't have any other jsl for what I'm trying to do...yet.
Re: Absolute value between all pointsI guess that 'easier' depends on what else your code does, and how. But if you want teh matrix to be lower triangular you could use:
Names Default To Here( 1 );
// Data
v = [1, 2, 3, 4];
// Compute Euclidean distance between all pairs of points
dm = Sqrt(Distance(v, v));
// Make matrix dm lower triangular
dm2 = J(NRow(dm), NCol(dm), .);
for (r=1, r<=NRow(dm), r++,
dm2[r, 1::r] = dm[r, 1::r];
);
dt = AsTable(dm2);
Re: Absolute value between all pointsAwesome solutions! Both work really well for what I'm doing. I like the 'Distance()' function, I'll have to look into it more.
I have a follow up question:
Both these solutions essentially produce a matrix with the distance between each point in the cell. I was wondering if there is an easy way to remove either the lower or upper triangle of the matrix? I don't need both sides and it will make analysis easier.
Re: Absolute value between all pointsNice
Re: Absolute value between all pointsYou might also use the 'Distance()' function (see 'Help > Scripting Guide'):
Names Default To Here( 1 );
// Data
v = [1, 2, 3, 4];
// Compute Euclidean distance between all pairs of points
dm = Sqrt(Distance(v, v));
dt = AsTable(dm);
Re: Absolute value between all pointsI think this might do what you want:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
a = dt:weight << get values;
b = a;
c = [];
For( i = 1, i <= N Rows( a ), i++,
c = c || abs( a[i] - b);
dt << New Column( "col" || Char( i ), values( c[0, i] ) );
);