Skip to main content
Became Hot Network Question
added 583 characters in body
Source Link
John Taylor
  • 6k
  • 2
  • 14
  • 35

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.

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.

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.

added 1 character in body
Source Link
John Taylor
  • 6k
  • 2
  • 14
  • 35

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.

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.

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.

Source Link
John Taylor
  • 6k
  • 2
  • 14
  • 35

How to find repeating elements in the following grid?

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.