What is the optimal way to match list entries after rounding in Mathematica?

You may want to use something like this: {Round{#, #2}, #3} & @@@ Joinlist1, list2; % ~GatherBy~ First ~Select~ (Length@# > 1 &) This will group all data points that having matching coordinates after rounding. You can use a second argument to Round to specify the fraction to round by. This assumes that there are not duplicated points within a single list.

If there are, you will need to remove those to get useful pairs. Tell me if this is the case and I will update my answer. Here is another method using Sow and Reap.

The same caveats apply. Both of these examples are simply guidelines for how you may implement your functionality. Reap Sow#3, {Round{#, #2}} & @@@ Joinlist1, list2, _, List 2 ~Cases~ {_, {_, __}} To deal with duplicate-after-round elements within each list, you may use Round and GatherBy on each list as follows.

NewList1 = GatherBy{Round{#, #2}, #3} & @@@ list1, FirstAll, 1; newList2 = GatherBy{Round{#, #2}, #3} & @@@ list2, FirstAll, 1; and then proceed with: newList1 ~Join~ newList2 ~GatherBy~ First ~Select~ (Length@# > 1 &).

Mr.Wizard - yes, this looks promising but as you said, after rounding there may be elements in each list with duplicate coordinates in which case a single representative element would suffice. – gpap Nov 16 at 15:02 +1, for the most ingenious (insidious? ) use of infix form I've seen.

– rcollyer Nov 16 at 15:05 @gpap if that is the case we will need to filter each list first. I will amend my answer. – Mr.Wizard Nov 16 at 15:12 @rcollyer I hope it is not hard to read.

I decided recently to start posting code with infix notation as I would write it for my own use. – Mr.Wizard Nov 16 at 15:13 1 It's a tad confusing at first sight, especially as it doesn't emphasize the grouping ((#1 ~GatherBy~ #2) ~Select~ #3) :D I usually use infix for associative functions only such as Join (which implies that all arguments are of the same type). – Szabolcs Nov 16 at 15:24.

Here's my approach, relying on Nearest to match the points. Let's assume that list1 doesn't have fewer elements than list2. (Otherwise you can swap them using {list1, list2} = {list2, list1}) (* extract points *) points1=list1All,{1,2}; points2=list2All,{1,2}; (* build a "nearest-function" for matching them *) nf=Nearestpoints1 (* two points match only if they're closer than threshold *) threshold=100; (* This function will find the match of a point from points2 in points1.

If there's no match, the point is discarded using Sequence. *) matchpoint_:= With{m=First@nfpoint}, IfNormm-pointNote: How complicated the implementation needs to be really depends on your particular dataset. Does each point from the first set have a match in the second one?

Are there any duplicates? How close can points from the same dataset be? Etc.

I tried to provide something which can be tweaked to be relatively robust, at the cost of having longer code.

Thanks a lot - that's the approach I'd have used myself I think.. – gpap Nov 16 at 15:45.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions