Consider the following table:
grid1 = {0.1, 0.2, 0.2, 0.3, 0.4, 0.5};
grid2 = {0.2, 0.3, 0.7, 0.8, 1.1, 1.2};
grid3 = {0.17, 0.25, 0.35, 0.35, 0.4};
tuples = Join[Tuples[{grid1, grid2, grid3}],RandomReal[{1, 2}, {6*6*5, 1}],2];
I do not have grid1, grid2, grid3
, only the resulting tuples
, but I want to find them. If they did not contain duplicating points, it would be, e.g., simply
grid1 = DeleteDuplicates[tuples[[All,1]]]
but it would remove the extra 0.2 and make things wrong:
{0.1, 0.2, 0.3, 0.4, 0.5}
Is there any quick approach to the extraction of these grids?
Actually, I simply need to find the duplicates in each of the grids.
Edit
An ugly way would be like this:
grid1 = tuples[[All, 1]] // DeleteDuplicates
tableoccurences=Table[Length[Select[tuples, #[[1]] == grid1[[i]] &]], {i, 1, Length[grid1], 1}]
occmin = tableoccurences // Min
grid1 = Table[
Table[grid1[[i]], tableoccurences[[i]]/occmin], {i, 1,
Length[grid1], 1}] // Flatten
and so on. tableoccurences
counts the number of times each element of the grid is present in tuples
. The main problem is that the approach assumes that occmin
corresponds to the element that is present only once.
tuples
? And can you clarify what "Actually, I simply need to find the duplicates in each of the grids." means? $\endgroup$