Use Nearest
. For example, with the data:
SeedRandom[1]
list1 = RandomReal[1, {10^4, 4}];
list2 = RandomReal[1, {10^4, 4}];
You can define a NearestFunction
:
nf = Nearest[list1->"Index", DistanceFunction->ChessboardDistance];
ChessboardDistance
measures the distance between 2 points assuming the distance is covered by a Queen (or King). Now, with 10^4 random points it is extremely unlikely that any 2 points have a ChessboardDistance
of 10^-5 or less. For the above data, a distance that produces "identical" points is something on the order of 10^-2:
res = nf[list2, {All, 10^-2}];
identical = Pick[list2, Length /@ res, Except[0, _Integer]]
{{0.685292, 0.397605, 0.475159, 0.328691}, {0.335736, 0.280756, 0.407469,
0.533887}, {0.912073, 0.685974, 0.952897, 0.271151}, {0.326838, 0.504337,
0.125602, 0.314291}, {0.676946, 0.110687, 0.939404, 0.492283}, {0.747907,
0.385783, 0.230076, 0.198834}, {0.440763, 0.351743, 0.492735,
0.207811}, {0.539763, 0.309531, 0.115746, 0.700582}, {0.935517, 0.227098,
0.640445, 0.400848}, {0.400585, 0.0229188, 0.652013, 0.652141}, {0.335365,
0.111325, 0.664795, 0.17639}, {0.43019, 0.163319, 0.075704,
0.67404}, {0.661021, 0.03022, 0.20255, 0.372881}}
Let's compare the identical elements:
Thread[{list1[[#]]& /@ DeleteCases[res, {}], identical}]
{{{{0.689472, 0.40506, 0.473408, 0.332559}}, {0.685292, 0.397605, 0.475159,
0.328691}}, {{{0.342825, 0.276343, 0.408599, 0.525442}}, {0.335736,
0.280756, 0.407469,
0.533887}}, {{{0.902177, 0.68945, 0.94329, 0.265362}}, {0.912073, 0.685974,
0.952897,
0.271151}}, {{{0.323412, 0.510421, 0.121472, 0.317904}}, {0.326838,
0.504337, 0.125602,
0.314291}}, {{{0.679234, 0.120186, 0.933942, 0.490366}}, {0.676946,
0.110687, 0.939404,
0.492283}}, {{{0.748489, 0.393792, 0.232312, 0.198016}}, {0.747907,
0.385783, 0.230076,
0.198834}}, {{{0.447516, 0.350137, 0.49212, 0.211425}}, {0.440763,
0.351743, 0.492735,
0.207811}}, {{{0.549304, 0.318568, 0.108417, 0.702578}}, {0.539763,
0.309531, 0.115746,
0.700582}}, {{{0.93924, 0.224546, 0.635966, 0.398112}}, {0.935517,
0.227098, 0.640445,
0.400848}}, {{{0.409333, 0.0203513, 0.644093, 0.654824}}, {0.400585,
0.0229188, 0.652013,
0.652141}}, {{{0.342227, 0.111995, 0.663345, 0.178174}}, {0.335365,
0.111325, 0.664795,
0.17639}}, {{{0.424369, 0.157971, 0.0763675, 0.678569}}, {0.43019,
0.163319, 0.075704,
0.67404}}, {{{0.663532, 0.0398141, 0.193906, 0.369557}}, {0.661021,
0.03022, 0.20255, 0.372881}}}
Looks identical based on the distance measure .01
.
RandomReal[{-1, 1}, {1000, 6}]
will generate your fake data a bit more compactly. $\endgroup$