Thursday, May 24, 2012

That's no way to kill an elephant

It seemed dreadful to see the great beast Lying there, powerless to move and yet powerless to die, and not even to be able to finish him. I sent back for my small rifle and poured shot after shot into his heart and down his throat. They seemed to make no impression.
wrote George Orwell in Shooting an Elephant

I read Orwell's essay ages ago and figured it pretty much had the elephant execution story covered. Looking back I was amazingly naive about quite how many bizarre possibilities for dispatching pachyderms existed.

1. Hanging. Erwin, Tennessee thought it was a good idea to hang Mary the elephant.

2. Electrocution. In order to show that his DC current was a great idea Edison decided to show AC was really dangerous. So he got Topsy the elephant and electrocuted her. Which is a massively dick move anyway you cut it. He also invented and sold the electric chair to execute criminals as a similar negative publicity campaign against AC current. The video he produced is here

3. Shooting. Tyke (elephant) Police fired 86 shots at Tyke, who eventually collapsed from the wounds onto a blue car and died. This video is of Tyke's attack and later shooting. I am not going to embed it as it is frankly horrifying.

4. Harpooning. Chunee "Kneeling down to the command of his trusted keeper, Chunee was hit by 152 musket balls, but refused to die. Chunee was finished off by a keeper with a harpoon or sword". Having to harpoon an elephant has to be the definition of a hard day at work.

Not execution but still weird

5. Lethal Injection of LSD. Tusko was a 14 year old who weighed 32000kg. Some scientists decided to give him enough LSD to get 3000 people off their mash. This mammoth dose killed him under two hours later. The scientific paper that came out of this mess is "Lysergic Acid Diethylamide: Its effect on a Male Asiatic Elephant."

6. Lightening "Norma Jean, struck by lightning, c. 1972, during a circus parade in Oquawka, Illinois. She was buried where she died, and a marker now lies on this spot."

7. Drowning (ish). Dan Rice was a sort of PT Barnum character. He ran loads of stunts to advertise his various travelling circus events. One of these for one poor elephant was "In August 1860, Rice had Lallah Rookh swim across the Ohio River in Cincinnati, Ohio to drum up publicity for his new "Monster Show." It took her 45 minutes to swim across the river. A month later, Lallah died of a fever brought about by her swim".

While on this elephantine swimming subject my favourite theory about the Loch Ness Monster is that it was a swimming circus elephant. And once the mistake was made the circus owner used the publicity to drum up business 'In 1933 a circus promoter in the area—acting perhaps on inside information that the monster was really a big top beast—offered a rich reward for Nessie's capture'

8. Burning. In 1681 an elephant was burned to death in Dublin. How the poor creature got to Dublin at that time is difficult to imagine. But then to have your crate set on fire is just tragic. The autopsy revealed information that later helped show elephants had evolved from an aquatic animal. "An anatomical account of the elephant accidentally burnt in Dublin on Fryday, June 17 in the year 1681" is Allen Mullen's description of the autopsy

And the weirdest one, and I realise that is saying something, is not an execution of elephants but by elephants. Most of the elephants killed listed above had killed a person. But elephants were once a really common. Apparently death by Nelly was wildly popular from prehistoric times up until the late 1800s. Execution by elephant is an incredible wikipedia page, hard to extract from but worth reading through.

Because elephants are so easy to train and because an elephant standing on your head was such a gruesome way to die most south Asian countries seemed to practice it.

I do not know what the wide an varied history of death of and by elephant tells us. They are all pretty tragic tales. Recently an elephant escaped in Cork . Then later crushed one of the circus workers. It seems the same sort of issues that killed Chunee, Mary, Tyke and many people who have been killed by performing elephants still exist and that more than these historic stories is a tragedy.

Wednesday, May 23, 2012

Birthday Problem

Punk Rock Operations Research has recently been talking about the birthday problem. This problem asks how many people have to be in a room for you to have a 50% chance of two of them sharing a birthday. The usual answer is 23 people.

However as The Birthday Problem and The Birthday Problem with a mating season: A simulation approach post say because Seasons Sway Human Birth Rates the assumption the birthday problem makes of a random sampling of people usually will not hold. This clumping of people births means that the birthday problem could have a lower number than usually supposed. Think of it this way, if everyone was born on January 1st you would only need two people to be sure of having a matched birthday. In the same way if births are clumped and not evenly spread the number of people needed to get a shared birthday should drop.

I found a good dataset at An Analysis of the Distribution of Birthdays of 480,040 birth dates. This is ideal for a simulation. Presumably the US census has even better data but I can't find it. The files used are bday.txt. This is in the form

0101 1482

0102 1213

0103 1220

0104 1319

Also a file with equal numbers of birth each day here This code is to calculate the average number of people you need to add to a set for two to share a birthday. Which is slightly different from the original birthday problem. Knuth studied this variant and came up with a figure of 24.616 people assuming 365 days in a year.


#!/usr/bin/env ruby -w

puts 'Birthday simulation'

#binary search function I stole
def binarySearch(sortedArray, first, last, key) 
   until first > last do
       mid = (first + last)/2
       if (key > sortedArray[mid])
           first = mid + 1;
           binarySearch(sortedArray, first, last, key)
       elsif (key < sortedArray[mid])
           last = mid - 1;
           binarySearch(sortedArray, first, last, key)
       else
           return mid;
      end
   end
   return first;
end

#binarySearch Test
#sorted_array = [1, 5, 6, 10, 5, 25, 40, 78, 100, 130]
#p binarySearch(sorted_array, 0, sorted_array.length-1, 1)

total=0;
matches= Array.new; #array holding how many people so far have this
found= Array.new; #have we seen this day before
tried=0;  #how many people had to be tried 
i=0;

#First load an array with numbers that correspond to days. Day 0 is 1482 people, day 1 1482 upto 1482+1213 etc 

#for the real dataset
File.open('bday.txt', 'r') do |f1|

# and with the everyone born randomly
#File.open('normal', 'r') do |f1|
  while line = f1.gets  
    parts=line.split;#get the second number part of the line
    total=total+parts[1].to_i;
    matches[i]=total;
    i+=1;
  end  
end 

puts total; #sum up all the values

j=0;
matchFound=0;
totalDays=0;

while j<10000#00
where= binarySearch(matches, 0, matches.length-1, rand(total));
tried=tried+1;
 if found[where] ==1
  totalDays=totalDays+tried;
  tried=0;
  found.delete(1);#empty the array for another simulation run
  matchFound=matchFound+1; 
 else
  found[where]=1
 end
 j+=1;
end
ans=(totalDays.to_f/matchFound.to_f)
puts "average birthday number ", ans;
This code with the same number born every day gives a birthday number of 24.0194321675634. And with the real bday.txt dataset from Roy Murphy gets the result of 23.9779163169884.

This code needs a complete rewrite. This code is fugly and wrong. I tried writing this piece a few years ago and failed so I'm just glad to get it out the door. Also I have to make allowances for the dataset size and the number of simulations run.

Other problems with the birthday problem revolve around getting a random sampling of people. About 1 in 80 births are of twins. So an average of one in every 40 people is a twin and twins tend to hang out together.

This dataset comes from life insurance forms. Which could be biased in that Jan 1st seems to be too popular. It could be what a form defaults to. Maybe life insurance selects for people born at a certain time. It could be that rich people buy life insurance more and rich people are more often born in a particular month. Professions seem to clump around certain birth dates. Malcolm Gladwell points out in Outliers that professional athletes tend to have birthdates that make them old when they play under 8,9,10 and 11's sports. Kary Mullis in "dancing naked in the mind field" professes his support for astrology saying “A recent scientific study of the distribution of medical students in birth months discovered that a lot of medical students were born in late June”. If this is right then some other professional groups clump in age.

Mullis is an interesting person, and his book is very entertaining. By the time he describes his meeting with an extra terrestrial glowing raccoon you know he is nuttier than squirrel shit. Partly it is this oddness that helped him win the Nobel prize brilliant "What if I had not taken LSD ever; would I have still invented PCR?" He replied, "I don't know. I doubt it. I seriously doubt it.". PCR is used to amplify DNA fragments and is a major tool in convicting rapists, murderers and other criminals.

While on the subject of doing calculations on peoples births. Laplace did a calculation showing more baby boys were born in France than girls. Which is one of the founding calculations of probability theory.

The birthday problem turns out to be lower than people claim. It also has enough weirdness involved in the randomness assumption that it is a good illustration that people just aren't random.