Assign data point to n-Dimensional grid [message #80599] |
Fri, 22 June 2012 07:46  |
antar3s86
Messages: 8 Registered: June 2012
|
Junior Member |
|
|
Hi
I face a serious problem in the development of my algorithm.In principle it is very simple:
I have a data point in a 9-dimensional parameter space (say, x1,x2,x3,y1,y2,y3,z1,z2,z3) with x,y,z being physical quantities with different units. Furthermore, I have an unequally spaced 9-dimensional reference grid and all i have to do is to compute which grid point is closest to my data point with respect to all 9 dimensions.
I have to do this several billion times, so I really want to make sure to do it as fast as possible.
Any help with that?
cheers
|
|
|
Re: Assign data point to n-Dimensional grid [message #80691 is a reply to message #80599] |
Tue, 26 June 2012 00:43  |
antar3s86
Messages: 8 Registered: June 2012
|
Junior Member |
|
|
Hi
I have manages to find the nearest neighbor for one parameter using something like that
ii = VALUE_LOCATE(grid, x)
wh = WHERE((grid[ii+1] - x) LT (x-grid[ii]), ct)
if ct GT 0 then ii[wh] = ii[wh]+1
nn = grid(ii)
but I discovered that not all of my parameters are independent. So I split the problem up and located the independent parameters with the procedure above and the dependent ones with a 2-D search using nearestn (http://www.ifa.hawaii.edu/~beaumont/code/nearestn.html). This is a pure coincidence and if I ever have to face a problem with more dependent parameters I will have to think of something else.
Now I face a different problem which I want to describe with an example:
Suppose my grid consists of three parameters, so e.g. gridx = [2,5,10], gridy = [10,40,50], and gridz = [100,101,102]. I need to fit my data point to the first two which can be done with the nearest neighbor method I solved for now. So for two test data points, say, x = [3,11], y = [8,47] they will snap to xs = [2,10], ys = [10,50] which is the 0th and 2nd position in the grid. From that I want to know which z-value and the third grid is assigned to them.
Any ideas how to solve that, meaning how to know at which position the test data points lie in the grid?
|
|
|