Tuesday, June 19, 2012

The Fairest Way to Pick a Team

What is the best way to pick a team? As kids we would always strictly alternate between teams so team 1 had first team 2 the second pick and then team 1 again etc.

Most things you can measure about people are on a bell curve. A small number of people are bad, most are in the middle and a few are good. There are a few good known metrics of ability. None are perfect, there is no one number that can sum up ability. The simpler the sport the more one metric can tell you, in cycling VO2 max is a very good indicator. Whereas in soccer VO2 max, kicking speed, vertical leap, number of keep me ups you can do etc could all measure some part of football ability.

So say there was one good metric for a task and teams were picked based on this. Is the standard strict alteration, where Team 1 picks then Team 2 alternating, fair? Fair here meaning both teams end up with a similar quality.

I wrote a program in R Package. Not because I know it but because it is perfect for this sort of problem. If you are picking 5 a side and the best player left is always picked by a team how much better is the first picker?

Strict Alteration the code is

players<-10
#create a vector
z <-0
#run 10000 simulations
for(i in 1:10000)
{
#rnorm generates a normally distributed dataset
# this one has 10 elements. A mean of 100 and a std of 12
#sort puts the biggest at the end
x <- c(sort(rnorm(players, mean=100, sd=12)))
# for each simulation take every second one and put it into a different team. 
# Give one team even and one odd 
z <- append(z, sum(x[c(1,3,5,7,9)]-x[c(2,4,6,8,10)]))
}
print(sd(z))
#get the average difference between the two teams
print(mean(z))

> print(sd(z))

[1] 8.794016

> print(mean(z))

[1] -22.59786

IQ has an average of 100 and a standard deviation of 12. IQ isn't used much to pick soccer teams but many things follow a similar pattern. In software development IQ wouldn't be the worst metric to pick a team on and agile teams are supposed to have between 5 and 9 members. So think of this as people picking teams of developers.

In this simulation Team 1 ends up with .225 of a person advantage. The more people on the team the greater advantage the first picker gets.

18 players

> print(sd(z))

[1] 8.287164

> print(mean(z))

[1] -25.52077

16 players

> print(sd(z))

[1] 8.20681

> print(mean(z))

[1] -25.00685

Would another way of picking the teams be fairer?

Balanced Alteration from the Win Win Solution by Brams and Taylor 'strict alteration can give a big boost to the first chooser when there are only two parties. What we need to do is reduce this advantage of the first chooser by amending strict alternation.'

The balanced alteration allows the captains to be first chooser in turn.

This is

Team 1 Team 2 Team 2 Team 1 Team 1 Team 2 Team 2 Team 1....

the code is

players<-10
#create a vector
z <-0
#run 10000 simulations
for(i in 1:10000)
{
#rnorm generates a normally distributed dataset
# this one has 10 elements. A mean of 100 and a std of 12
#sort puts the biggest at the end
x <- c(sort(rnorm(players, mean=100, sd=12)))
# for each simulation take every second one and put it into a different team. 
# Give one team even and one odd 
z <- append(z, sum(x[c(1,4,5,8,9)]-x[c(2,3,6,7,10)]))
}
print(sd(z))
print(mean(z))

> print(sd(z))

[1] 9.757417

> print(mean(z))

[1] -9.04198

This method looks better than the standard strict alteration.

Thinking about the bell curve though is would make sense if the team that got the best player got the worst, and the second best the second worst etc. This should even up the teams well. The code for this is

players<-10

#create a vector
z <-0
#run 10000 simulations
for(i in 1:10000)
{
#rnorm generates a normally distributed dataset
# this one has 10 elements. A mean of 100 and a std of 12
#sort puts the biggest at the end
x <- c(sort(rnorm(players, mean=100, sd=12)))
# for each simulation take every second one and put it into a different team. 
# Give one team even and one odd 
z <- append(z, sum(x[c(2,4,6,7,9)]-x[c(1,3,5,8,10)]))
}
print(sd(z))
print(mean(z))

> print(sd(z))

[1] 9.3498

> print(mean(z))

[1] 3.027536

This has a better average difference. The fact the difference is as high as it is makes me think I may have a bug in my code.

Kids to implement this method would have to alternate picking a player until they were about to pick the middle player in their team Then Team 2 would get a second pick. This sounds almost practical.

When you played a sport (particularly soccer) as a kid what rules did you pick teams by? Can you think of a better algorithm now?

Monday, June 18, 2012

Baby's First Hack

Maternity hospitals put these security bracelets on your baby. The thing is because the baby loses so much weight and generally changes so much after their birth they keep falling off. The nurses get annoyed by them because they fall off so often but they generally seem not to mind them too much. My video below shows how easy they are to remove

And that is without trying to cut off the tag or shield it from the radio receiver in some way. Schneier has a good post on how these tags just because they don't actually reduce risk of harm much are still valuable. I'll quote it at length because it is so good.

'While visiting some friends and their new baby in the hospital last week, I noticed an interesting bit of security. To prevent infant abduction, all babies had RFID tags attached to their ankles by a bracelet. There are sensors on the doors to the maternity ward, and if a baby passes through, an alarm goes off.

Infant abduction is rare, but still a risk. In the last 22 years, about 233 such abductions have occurred in the United States. About 4 million babies are born each year, which means that a baby has a 1-in-375,000 chance of being abducted. Compare this with the infant mortality rate in the U.S. -- one in 145 -- and it becomes clear where the real risks are.

And the 1-in-375,000 chance is not today's risk. Infant abduction rates have plummeted in recent years, mostly due to education programs at hospitals. So why are hospitals bothering with RFID bracelets? I think they're primarily to reassure the mothers. Many times during my friends' stay at the hospital the doctors had to take the baby away for this or that test. Millions of years of evolution have forged a strong bond between new parents and new baby; the RFID bracelets are a low-cost way to ensure that the parents are more relaxed when their baby was out of their sight.

Security is both a reality and a feeling. The reality of security is mathematical, based on the probability of different risks and the effectiveness of different countermeasures. We know the infant abduction rates and how well the bracelets reduce those rates. We also know the cost of the bracelets, and can thus calculate whether they're a cost-effective security measure or not. But security is also a feeling, based on individual psychological reactions to both the risks and the countermeasures. And the two things are different: You can be secure even though you don't feel secure, and you can feel secure even though you're not really secure.

The RFID bracelets are what I've come to call security theater: security primarily designed to make you feel more secure. I've regularly maligned security theater as a waste, but it's not always, and not entirely, so.'

In Praise of Security Theater

I agree with his description. The tags from a rational measurable security point of view silly, everyone if they think about it can tell their silly. But they reassure new parents of a non rational but still present fear. And that means the tags probably are not silly.