1

Is there a formula for a possible number of permutations of a set of numbers that returns all unique outcomes for example:

[1,2]=(1,2) (as (2,1)==(1,2))

[1,2,3]= (1,2),(1,3),(2,3) (as (3,1)==(1,3) etc)

such that the order is not important so that instead of n! combinations, we have 3 rather than 6 for the 2nd example?

Thankyou.

PM.
  • 5,249
R.Smith
  • 11

1 Answers1

2

You seem to be selecting subsets of size 2 from sets of size $n$ so the number of subsets is $$n \choose 2$$ which is read "n choose 2". It is a binomial coefficient. There are other notations for it.

For your first example this would be $2 \choose 2$ and ${3}\choose{2} $ for your second example.

However, if you want to know the total number of subsets then it is $$2^n$$ where again $n$ is the size of your set.

EDIT:

I don't write Matlab but to do it by hand in Python, for subsets of size 2:

x = [1,2,3] for i in range(len(x)): j = i + 1 while j < len(x): print(x[i], x[j]) j += 1

with output

(1, 2) (1, 3) (2, 3)

PM.
  • 5,249
  • Thankyou. This is interesting for some code i am writing (matlab). For the second example, we know that there are 6 total combinations but 3 in my subset. Is there a way to export the three subset values, i.e. a matrix such as : M=[1,2; 1,3; 2,3] – R.Smith Mar 08 '17 at 11:12
  • @R.Smith I updated my answer which you should be able to port to Matlab. I would also use 'subset' instead of 'total combination'. – PM. Mar 08 '17 at 12:23