Drawing Straws

The other night we were watching the movie Armageddon with Bruce Willis and Liv Tyler. Near the end of the movie the crew picks straws to determine who stays behind. Thus, being the Buzzkillington that I am, I posed a question to everyone…

If you could pick your turn, would you go first, last, or some where in between?

Not everyone could agree. Some said first, others said it didn’t matter. The answer is that it really shouldn’t matter which order you pick your straw in - given that the straws are put in a uniformly distributed random order.

This means you should receive no favor by picking first or last. This might seem like common sense, however, statistics can be tricky sometimes, (i.e. the Monty Hall problem) so I’m never too quick to brush statistical problems off with common sense. Thus I wrote a simulation to show myself that order doesn’t matter.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {
$scope.number_of_sticks = 4;
$scope.iterations = 1000000;

$scope.winners = [];
$scope.stats = [];
$scope.deviation= [];
$scope.average = 0;

$scope.getSticks = function(size)
{
var sticks = [];
var loser = Math.floor((Math.random()*size));
for(var i = 0; i < size; i++) sticks[i] = 0;
sticks[loser] = 1;
return sticks;
};

$scope.play = function(size)
{
var sticks = $scope.getSticks(size);
for(var i = 0; i < sticks.length; i++)
if(typeof $scope.winners[i] === 'undefined')
$scope.winners[i] = sticks[i];
else
$scope.winners[i] = $scope.winners[i] + sticks[i];
};

for(var i = 0; i < $scope.iterations; i++)
$scope.play($scope.number_of_sticks);


for(var i = 0; i < $scope.number_of_sticks; i++) {
$scope.stats[i] = $scope.winners[i] / $scope.iterations;
$scope.average += $scope.stats[i];
}

$scope.average = $scope.average / $scope.number_of_sticks;

for(var i = 0; i < $scope.number_of_sticks; i++)
$scope.deviation[i] = Math.round(($scope.average - $scope.stats[i]) * 100);

}

Below if you click Result you can run a straw picking game one million times over with four people and as expected… no participant has a clear advantage (meaning they loose 25% of the time).