I have two arrays of variables I am comparing,
arr1 = [1,2,3]
arr2 = [1,2,3]
I would like to get each unique, non-redundant combination of variables. The initial unique combinations are:
(1,1), (1,2), (1,3)
(2,1), (2,2), (2,3)
(3,1), (3,2), (3,3)
But this set is further reduced, since comparing variable 1 with itself (and 2 with itself, etc.) is meaningless. Removing these, the set reduces to:
(1,2), (1,3)
(2,1), (2,3)
(3,1), (3,2)
Furthermore, there are redundant pairs since comparing variable 1 to variable 2 is the same as comparing variable 2 to variable 1. So the end result I'm looking for would be:
(1,2), (1,3), (2,3)
I can reason through the first bit:
# Generate combination arrays
sets = []
sy = 3
for i in 1:size(ellipseX)[2]
set1 = repeat([i],sy)
set2 = range(1,sy)
newsets = cat(set1,set2,dims=2)
sets = cat(sets,newsets,dims=1)
end
# Remove rows with same column values
for N in 0:sy-1
rownum = 1+sy*N
sets = sets[setdiff(1:end, rownum), :]
end
but removing the redundant pairs is a bit more tricky. Is there a much easier way to do this?