The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 simple nearest neighbor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ifsmithy

USA
Posts

Posted - 06/27/2013 :  2:01:39 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9
Operating System:XP

I was wondering how I go about a simple nearest neighbor analysis.

I have a pretty long column of x and y coordinates and I would like to be able to calculate the distance each coordinate is to it's nearest neighbor.

Is there a simple way to do this in origin?

Many Thanks!

Sam Fang

291 Posts

Posted - 06/28/2013 :  02:43:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can try Origin's Hierarchical Cluster Analysis tool. Select Statistics: Multivariate Analysis: Hierarchical Cluster Analysis from Origin menu. Choose Dissimilar Matrix in Quantities branch of the dialog. It will create the distance matrix. And replace the diagonal element of the distance matrix 0 with missing value to exclude itself. You can use LabTalk script to do it. (Recalculate set None.)

int nc = wks.ncols;
for( int ii=2; ii<=nc; ii++ )
{
  wcol(ii)[ii-1]=0/0;
}


Then you can choose Statistics: Descriptive Statistics: Statistics on Columns from menu. And select all columns of distance matrix as input, and check Index of Minimum in Quantities to Compute: Quantities from the dialog.

Index of Minimum in the report is the point which corresponds to the nearest neighbor.

Note that if number of points n is too large, then the distance matrix with size of n*n may be out of memory. In that case, you have to use LabTalk code or Origin C code to avoid the size limit of distance matrix.



Sam
OriginLab Technical Services

Edited by - Sam Fang on 06/28/2013 10:44:24 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000