# Re: Probability related question and arrays

*From*: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>*Date*: Tue, 13 Jun 2006 07:03:24 +0000

placid said:

Thanks for the replies eveyone, but i think i need to explain my

scenario and question again and this time il use a different theme

(World Cup!)

I have three lists, one list contains 24 World Cup teams (teams),

another contains 8 favourite teams to win the world cup (fav_teams) and

the last list contains 8 players (players). So now the fav_teams list

should be equal or divisible by the length of the players list.

For each player in the players list, choose one favourite team from the

from fav_teams and three teams from the teams lists, remove the

selected teams from the list.

My question is the same, for the first element/player in the players

list that i iterate through does this player have a greater chance of

getting a better favourite team from fav_teams (this team being Brazil)

then the other players?

No, because without loss of generality you can do this without there being a

"first" player. All you have to do is randomly perturb one of the arrays

("shuffle the cards"), and then match each element of one array to the

corresponding element of the other array.

Here's a cut down example, with two arrays:

Argentina

Brazil

Cameroon

Denmark

England

France

Grace

Helen

Isabel

Janet

Karen

Lois

We now randomly perturb the first array (or the second, it doesn't matter,

but I'll do the first) as follows:

For each position in turn (1-6), pick a random number between that number

and 6.

Pos 1. Current occupier: Argentina. Random number: 4

Swap Argentina with Pos 4, Denmark.

Denmark

Brazil

Cameroon

Argentina

England

France

Pos 2. Current occupier: Brazil. Random number between 2 and 6: 5

Swap Brazil with Pos 5, England.

Denmark

England

Cameroon

Argentina

Brazil

France

Pos 3. Current occupier: Cameroon. Random number between 3 and 6: 3

Swap Cameroon with Cameroon.

Denmark

England

Cameroon

Argentina

Brazil

France

Pos 4. Current occupier: Argentina. Random number between 4 and 6: 4

Swap Argentina with Argentina.

Denmark

England

Cameroon

Argentina

Brazil

France

Pos 5. Current occupier: Brazil. Random number between 5 and 6: 6

Swap Brazil with France.

Denmark

England

Cameroon

Argentina

France

Brazil

And now we just pair them off:

Denmark Grace

England Helen

Cameroon Isabel

Argentina Janet

France Karen

Brazil Lois

This shuffling algorithm is known to give a very fair distribution.

But it's no different in principle to just going through the players in

order, and picking one team for each player, at random, from those teams

that are so far unpicked. In fact, it's the same algorithm, just expressed

in a different way.

So no, the first player does not gain an advantage.

--

Richard Heathfield

"Usenet is a strange place" - dmr 29/7/1999

http://www.cpax.org.uk

email: rjh at above domain (but drop the www, obviously)

.

**References**:**Probability related question and arrays***From:*placid

**Re: Probability related question and arrays***From:*ophidian

**Re: Probability related question and arrays***From:*placid

- Prev by Date:
**Re: Probability related question and arrays** - Next by Date:
**Re: Is my CS instructor nuts?** - Previous by thread:
**Re: Probability related question and arrays** - Next by thread:
**Help using pty** - Index(es):