1

Background:

On this combinatorics question, the issue is how to determine the sample space: the ways 8 different soccer teams can be paired up for the next round of competition. Two different answers have been advanced for that part of the problem: 28 (see comments OP) and 105 (see edit within OP and answer).

I'd like to do this manually to try to hone down on the mistake in whichever answer is incorrect.


What I have tried:

teams = 1:8
names(teams) = c("RM", "BCN", "SEV", "JUV", "ROM", "MC", "LIV", "BYN")
split(sample(teams), rep(1:(length(teams)/2), each=2))

Unfortunately, the output is a list, and I wanted a vector to be able to run something like:

unique(...,MARGIN=2)

Is there a way of doing this in an elegant manner?


After a now erased answer (thank you), I would go with

a <- replicate(1e5, unlist(split(sample(teams), rep(1:(length(teams)/2), each=2))))

to simulate 100,000 random samples, and later run

unique(a, MARGIN = 2).

But how can I account for the fact that the order of the 4 pairings of opponents doesn't matter, and that LIV-BYN and BYN-LIV, for example, is the same pairing (field advantage notwithstanding)?

1
  • 1
    Will 'unlist' work for your question? Commented Mar 17, 2018 at 16:02

1 Answer 1

0
> u = ncol(unique(replicate(1e6, unlist(split(sample(teams), rep(1:(length(teams)/2), each=2)))), MARGIN = 2))
> u / (factorial(4) * 2^4)
[1] 105

The idea of unlist is from @Song Zhengyi, and if his answer is un-deleted, I'll accept it. The complete answer is in the lines above.

u needs to be divided by 4! because

BCN-RM, BYN-SEV, JUV-ROM, LIV-MC

is exactly the same as

LIV-MC, BCN-RM, BYN-SEV, JUV-ROM

or

BCN-RM, LIV-MC, BYN-SEV, JUV-ROM

etc.

The term 2^4 is to avoid over-counting since for every possible unique draw, each one of the pairings can be flipped without loss (discarding field advantage): BCN-RM is the same as RM-BCN, and there are 4 pairs in each draw.


If field advantage is a consideration (real life)...

> u/factorial(4)
[1] 1680

we end up with 1,680 possible draws.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.