-->

Tuesday, 27 August 2013

Not The Mean Value Theorem

The following question was mentioned in the comments on Hacker News the other day.
If the side of a cube comes from a uniform distribution between 1 and 5 inches, what's the expected volume of the cube ?
The answer is to get the integral of x^3 at 5 minus the integral at one divided by 5-1. The integral is (x^4)/4 so we get 1/4(625/4-1/4) = 39.

But what if we are dealing with a cuboid and the sides are independent random variable. Well its E(length) * E(breadth) * E(width) or 3*3*3. But I wasn't sure if I was correct so I went to one of the newer tools in my mathematical toolbox - that's right I went triple integral.

It's the same as the integral above except we need to remember to divide by 64 because we are working against three axes.


Finally we divide by 64 to get 27. Basically each integral evaluates to 12 (area under the curve) and is divided by four to get the mean.

Yay maths works!

Wednesday, 31 July 2013

Stepping Stone of Thunder

This hand is from the recent European Open Championship pairs championship. The hand needs to be viewed as a 3NT hand by West (sorry about that but the table closed down while I was still analysing it.) The play potentially involves two spectacular plays:

  1. Days of Thunder: coined by Eric Rodwell it involves switching to an opponents long suit to hamper communications
  2. Stepping-Stone Squeze: first analysed by Terence Reese in his classic "The Expert Game" and involves overcoming a blockage by throwing in a n opponent


North opens diamonds and West has a pretty obvious duck after the A and J - fair play to south if this is from AKJ. Now we see play one. If South can imagine a club blockage then switching to a spade creates a blockage in that suit.

This is not the end of the story if West can put South with 4+ clubs with the AH. He runs six spades and has now played 8 tricks. South must come down to either 4 clubs and the AH or 3 clubs and AQ hearts. In the latter scenario the clubs will run but in the former West can unblock the clubs and exit in hearts - thus using South as a stepping stone to the clubs.


Monday, 8 July 2013

Champagne-Bottle Sizes and Acronym

I was recently skeptical when a friend used the term  Jeroboam in a game of eye-spy recently. I had never considered the size of champagne and bottles and to use a bit of foreshadowing the word really sounded like a splendid belching noise. Anyway a bottle of champagne is 75cl and is the standard measuring unit we will use. 2 bottle is a magnum and I would imagine most people, like me, would have hear about this far.

Next at 4 bottles we have Jeroboam and at 6 bottles the similar sounding Rehoboam. The latter was a son of Solomon and thus a grandson of David. For some reason the 10 northern tribes were not happy with Rehoboam's ascension and invited Jeroboam to become King of a new state and is thus the first King of Isreal. Rehoboam is the first King of Judah and the last King of the United Kingdom of Isreal.

At 8 bottles we have Methusaleh, who may have been the oldest person to live at 969 years* - his Grandson Noah also lived to 950 years. Methusaleh died 7 days before the great flood. Apparently he is a direct descendant of Adam but then isn't everyone - interestingly it was Adam's third son Seth who got the whole populating the world ball rolling.

* although the Guinness Book of World Record does not recognise him.


Friday, 21 June 2013

Ricco Van Prooijen's Unusal 5NT

You'll have to go Board 29 (after the jump)

The 5NT bid by Rico Van Prooijen of the Ned Aut team definitely drew a reaction from me as I was watching.

The 1NT bid is one I have come to favour over recent months. A strong NT should be a 6-7 loser hand. It should be your hands in the point range. Here you have a bit too much stuffing and prime cards but then you have no good rebid over 1♠ - except maybe with a nebulous diamond?

Marion Michielson then excellently and fortunately judges her hand worth a quantitative raise. Now there are three conventional ways to respond to this:

  1. Plain Vanilla: pass or bid 6NT
  2. Ace Ask: pass or show number of Aces (0,1,2..)
  3. Baron: bid 4-cd suits upwards
Option number two would probably be the most sensible as with number three you are opening your self to a bad trump split and defensive ruffs. For this reason you would only use three when the bulk of your points are in two suits - which may have the advantage of making partner declarer and protecting their holding in the other suits. For example:

Kx
AKxx
AJxx
Jxx

xx
QTx
KQxx
AKQx

This could produce the reverse auction.

Anyway Marion eventually made the sensible decision that this could not be one or two and thus must be three and helped win her side a deserved 16 imps.



Thursday, 20 June 2013

Ipython Notebook: Leaving Cert Hypothesis Testing Question

* The whole thing is embedded after the jump.
This is my attempt to explain 2-Sided Hypothesis Testing by answering a Leaving Cert question. You can try it on my Wakari page by clicking here. If you decide to download and run it you can  go to 'Cell' followed by 'Run All'. Then if you change any values you can use CTRL + ALT to run an individual cell.



Here is where you can change the variables* for the question. What is even cooler are the local variables, explained after the jump.

* I know confidence interval isn't the right term

Monday, 4 March 2013

Finding Hand Distributions with Scala

It's a good thing for a language to get out of your way and let you solve problems. It is even better when it helps you solve problems.

I was recently thinking about how many different hand distributions there are in bridge. This can be restated as dividing thirteen elements between four groups. My first thought was that you should make the condition that the any group should receive at least as many cards as the group before it. This meant that if you gave the first group three cards then all the other groups have at least three. With only one card left to distribute it has to go to the fourth group.

I was about to reach for pen and paper when I realized that scala will actually solve this problem for me and I quickly scratched out the following code:

for {

  i <- 0 to 3

  j <- i to (13-i)/3

  k <- j to (13-i-j)/2

} yield (i,j,k,13-i-j-k)

-

So here are your 39 results:

(0,0,0,13), (0,0,1,12), (0,0,2,11), (0,0,3,10), (0,0,4,9), (0,0,5,8),(0,0,6,7), (0,1,1,11), (0,1,2,10), (0,1,3,9), (0,1,4,8), (0,1,5,7), (0,1,6,6), (0,2,2,9), (0,2,3,8), (0,2,4,7), (0,2,5,6), (0,3,3,7), (0,3,4,6), (0,3,5,5), (0,4,4,5), (1,1,1,10), (1,1,2,9), (1,1,3,8), (1,1,4,7), (1,1,5,6), (1,2,2,8), (1,2,3,7), (1,2,4,6), (1,2,5,5), (1,3,3,6), (1,3,4,5), (1,4,4,4), (2,2,2,7), (2,2,3,6), (2,2,4,5), (2,3,3,5), (2,3,4,4), (3,3,3,4)

The distribution ordered by cards in the lowest group is 1, 5,12 and 21. According to the Online Encyclopedia of Integer Sequences this coincides with the rounded partial sum of the atomic weights of the first n elements. It's probably just a coincidence.

Sunday, 24 February 2013

Simple O.D.E.'s Part 2

In part 1 I The simple form are those where dx/dt = kx. We can integrate these with a result with of form X0e^(-kt). The next thing to deal with is the relativity in a system. In the first question the ambient temperature of the water is given as 32 degrees and so this should be treated as zero. Questions are from the Calculus: Single Variable course on Coursera.



On a cold day you want to brew a nice hot cup of tea. You pour boiling water (at a temperature of 212oF) into a mug and drop a tea bag in it. The water cools down in contact with the cold air according to Newton's law of cooling:
dTdt=κ(A−T)
where T is the temperature of the water, A=32oF the ambient temperature, and κ=0.36 min−1.
The threshold for human beings to feel pain when entering in contact with something hot is around 107oF. How many seconds do you have to wait until you can safely take a sip? Round your answer to the nearest integer.

Instead of 212 and 107 degrees we should be dealing with 180 and 75 respectively. This gives us:
75 = 180 e^(-0.36t) or 5/12 = e^(-0.36t)

Now take the logs of both sides

ln (5/12) = -0.36t giving us t = 2.432 which when multiplied by 60 (converting from minutes to seconds) and rounding gives us 146 seconds



On the night of April 14, 1912, the British passenger liner RMS Titanic collided with an iceberg and sank in the North Atlantic Ocean. The ship lacked enough lifeboats to accommodate all of the passengers, and many of them died from hypothermia in the cold sea waters. Hypothermia is the condition in which the temperature of a human body drops below normal operating levels (around 36oC). When the core body temperature drops below 28oC, the hypothermia is said to have become severe: major organs shut down and eventually the heart stops.
If the water temperature that night was −2oC, how long did it take for passengers of the Titanic to enter severe hypothermia? Recall from lecture that heat transfer is described by Newton's law of cooling:
dTdt=κ(A−T)
where T is the body temperature of a passenger, A the water temperature, and κ=0.016 min−1. Give your answer in minutes and round it to the nearest integer.


This is very much like the last question except it uses a negative ambient temperature so we must increase our figures by two degrees. This gives us:


30 = 38 e^(-0.016t) 

Now take the logs of both sides

ln (30/38) = -0.016t giving us t = 14.77  rounding gives us 15 minutes.


The next question is on the Malthusian Trap. Part 1 is given a population of 6bn in 2002 and a growth rate of 1.1% what will the population be in 2030.

P(2030) = P(2002)e^(growth rate * (2030-2002)) = 6bne^(0.011*28) = 8.16bn

Part 2 attempts to estiamte the Malthusian Catastrophe but that probably needs a post of its own.





Arrow Key Nav