Re: Probability related question and arrays
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 07:03:24 +0000
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
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:
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
Pos 1. Current occupier: Argentina. Random number: 4
Swap Argentina with Pos 4, Denmark.
Pos 2. Current occupier: Brazil. Random number between 2 and 6: 5
Swap Brazil with Pos 5, England.
Pos 3. Current occupier: Cameroon. Random number between 3 and 6: 3
Swap Cameroon with Cameroon.
Pos 4. Current occupier: Argentina. Random number between 4 and 6: 4
Swap Argentina with Argentina.
Pos 5. Current occupier: Brazil. Random number between 5 and 6: 6
Swap Brazil with France.
And now we just pair them off:
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.
"Usenet is a strange place" - dmr 29/7/1999
email: rjh at above domain (but drop the www, obviously)
- 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