Wednesday 30 June 2010

Unraveling the Bayesian knot: the magic of probability

There is a wonderful maths problem called "the two children problem" invented by Martin Gardner and it runs like this:
you meet a friend in the street, you know he has two children but not their sexes. As you are talking a boy runs up who is introduced as your friend's son: what is the probability that the other child is also boy?
Intuition would say 50%, in this case intuition is wrong; I will now try to explain why before giving the answer.

First I want to explain some fundamentals of statistics. First and foremost is the concept of probability, this is intuitively easy to describe: "the likelihood of an event occurring" the actual calculation is also deceptively simple:
\[ \frac{\text{desired outcome}}{\text{all outcomes}} \]
where  desired outcome is all the ways of achieving the outcome you're interested in (for example a boy in the above problem) and all outcomes are all the possible outcomes (eg boy or girl) so for the sex of a child the result, as you would expect, is:
\[\frac{\text{boy}}{\text{boy}+\text{girl}} = \frac{1}{2} = 50\%\]

The above of calculation is very simple but problems arise when you start looking at adding probabilities. For example the probability of having 2 sons is $\frac{1}{4}$ there are 4 possible combinations of 2 children (2 sons, 2 girls, 1 (eldest) son 1 daughter, 1 (eldest) daughter 1 son) while  the probability of having a son or a daughter remains $\frac{1}{2}$ the probability of a particular number of sons or daughters changes. While this may not make immediate sense it is easier to understand by going to an extreme: instead of 2 sons what are the odds of 200 sons? (answer below, it's very unlikely; even without considering the physical problems). A series of trials like this is where the 'Gambler's fallacy' comes from, each trial is independent, it has no effect on the outcome of any of the other trials, but any particular combination has a different chance: having 199 sons then a daughter is as likely as 199 sons then another son. The chance of having just 199 sons and daughter is more likely as the order of birth doesn't matter. There is only one way to have 199 sons then a daughter but there are 200 ways to have 199 sons and a daughter.

This is the one of the big pit-falls of probability (hence the fallacy) at each trial (in this case birth) the probability is the same, any one of those 200 children has a 50-50 chance of being a son or a daughter but any particular combination of children will have its own probability. At this point the essence of the 2 children problem should start to become apparent.

So what the answer to the 'two children problem'? It's not actually $\frac{1}{2}$ or  $\frac{1}{4}$ , it's $\frac{1}{3}$. To understand this think back to the definition of probability, we know that for 2 trials with each trial having one of two outcomes we have 4 possible outcomes:
2 sons, 2 daughters, 1 son 1 daughter and 1 daughter 1 son
Now we know that one of those options, 2 daughters, is impossible because we already have already met one son so that leaves us 3 options: 2 sons, a daughter or a different daughter (say, an older or younger daughter). The two options for a daughter may seem needless but it is vital: we know that there were 4 states and only one of those states is removed (2 daughters). We know at least one child is a boy but nothing more, if we knew the eldest child was a son the probability of the other child being a son would be $\frac{1}{2}$  but unless we know that this is a similar case to having 199 sons and a daughter: more likely because there are more possible 'desired' outcomes.

This sort of calculations relies on a branch of probability known as Bayesian statistics which concerns itself with the combination of different probabilities. This example is among the simplest and already it clashes against classical intuition, the most impressive part is that the probabilities are exactly what we see when we go and test these systems (you can do it yourself with two coins instead of children).

Of course one other reason the two children problem causes such confusion is the utterly artificial way in which it is presented but real world examples do exist, for example: given the probability of a disease test giving the correct result and the probability of having that disease how likely are you to have the disease if you test positive? Just so you know the answer is not $\frac{1}{4}, it is different as each outcome is not equally likely (for example you might have a 0.2% chance of having the disease and a 1% chance of a the wrong result from the test). For those that want an even more mind-bending problem I direct you to the Monte-hall problem, or the inspiration for this post: the Tuesday two children problem (if you know the son you meet was born on a Tuesday how likely is it your friend has another son).



200 heads from 200 flips? its:
\[ \left( \frac{1}{2}\right)^{200} = \frac{1}{1606938044258990275541962092341162602522202993782792835301376}\]

Monday 28 June 2010

Science: the other bit

I've been working in Japan for 2 weeks now and I've spent most of that time working on an experiment. Of that time about 1 day was spent taking data, the rest was spent working on analysis. Analysis is the bit of science that most people forget. People look at the LHC and expect it to run for a while and then spit out an answer. Does the Higgs exist? yes or no. Are there extra-spatial dimensions, how many? Can lepton flavour be violated? maximally or only in rare cases?

These are all questions that the LHC may answer, but not immediately, not even quickly in anything other than a scientific time frame and the reason for this is analysis. Analysis probably accounts for most of the time spent on an experiment. Before the LHC was even finished being built people had been running analysis for years and will run it for many more years once it shuts down. The reason for this is that every last bit of data has to be accounted for.

The experiment I have been working on for the last 2 weeks has been the calibration of a scintillation detector, to do this a radioactive source is placed near the detector and the detectors response is measured. This measurement then produces a plot that looks a little like this:
The big peak on the right is caused by Cesium 137. This peak lies at 662keV,  and is used to calibrate devices because the position of this spectral line can be calculated from what we know about the nuclear make up of cesium.

In this case it would seem to be a fairly simple analysis but it isn't a complete analysis, what about the two smaller peaks to the left of the big 662KeV peak, what is the huge peak near zero? The smaller two are called the backscatter peak and the Compton edge respectively, both are caused by scattering processes that the gamma ray (the source of the big peak) can undergo and ultimately mean not all the energy is accounted for hence the lower energy peaks. This leaves only the big left hand peak, caused by hard x-rays emitted when electrons move in their orbits (de-excite), gamma rays are caused by entire nuclei de-exciting hence their higher energy.

The above paragraph is a reasonable, qualitative analysis of the above graph but by no means is a full, rigorous analysis. For that the position of each peak would have to be calculated (for several other sources as well as cesium), carefully modelled using the expected curve which is then fitted to the data, the parameters produced can then be inspected and checked against the initial assumptions to see that there were no obvious differences from the expected.

The process above is what I did over the last two weeks. Two weeks of analysis for less than 2 days of data taking.

The LHC has orders of magnitude more complexity and a nearly unimaginably large amount of data taken every second (at the raw data rate it produces several thousand times more data than can be written to hard drive using current technology). The analysis of its data has been planned meticulously for the last decade, in fact the entire LHC has been modelled and simulated many times for various different possible physics scenarios (even black holes) over the last decade just so we'll have an idea of how it would look. These simulations have produced analysis procedures that can be applied to the data as soon as it exists. 

Once the initial data analysis is done it may be revisited several times: there are people in my lab working on data taken at the Zeus experiment (an smaller version of the LHC based in Hamburg, Germany). Zeus stopped taking data in 2007, 3 years later it is still being looked at and depending on what gets discovered at the LHC another round of analysis may begin: signals that were too weak to be noticed may be looked for with different techniques or better initial parameters.

Analysis is where the real science happens: experiments just make something to analyse. Already people are analysing the LHC: checking its calibration, looking for early signs of the Higgs. But the data taken now may be revisited a hundred times before it's fully understood, the meaning of ever last wrinkle, dimple and bump fully understood by which time the next set of experiments will be firing, fusing and flickering towards the next data set.

The weekend that was (very wet and misty)

As the title says: the weekend was blurry misty. Saturday it rained, a lot, Sunday was sunny, a lot. That's my obligation as British national disposed of I can now actually talk about what I did. Which to be fair wasn't much either.

Friday night I managed to sort myself out so that I could go out with some of the guys from the lab. Unlike typical trip to the local pub (certainly for my department anyway) here it meant we went to a bar which served good food as well, frankly this was a double wammy of win that was improved by the fact it was pretty cheap. About 5 rounds of drinks as well as about 15 different dishes worked out as about ¥3,000 each (about £25) given that in London 5 drinks alone will set you back most of that I consider it a good evening.

The food was really good, mainly small bits but it mounted up and by the end I was full(ish). Some interesting things I tried included: chicken cartilage (chewy but nice when deep fried in batter) octopus and squid in various forms (all of them dead) as well as something that was a called 'mountain potatoe' and when cooked had something close to the consistency of mucus, that being said it still tasted awesome as it absorbed pretty much any flavour put in it.

Saturday was a lot wetter than I was hoping for but I'd planned to be inside so no real loss: I went to the Osaka Aquarium (Kaiyuken) which like the biggest aquarium in any country instantly makes it something not to miss (according to the guidebooks and most likely the money given to the guidebook's authors). In this case it was reasonably justified as I doubt it'll be many years before I see sunfish, finless porpose or whalesharks in the same place (or at all given their survival chances).

From Osaka Aquarium

From Osaka Aquarium

I felt a little bad as a lot of the tanks there seemed small (especially for things like dolphins, sea lions and the whale sharks) but nothing seemed actively insane so hopefully they're ok. Obviously I saw more than those listed but a lot of what I saw were fishes: interesting to me but I'm not going to list them here (although I have to say the Jellyfish were awesome... but maybe that's just me).

After my pseudo-aquatic adventure (and negotiating all those children and people without GBH was something of a trial) I tried to take in the sights of Osaka through the medium of Ferris wheel (apparently the Tempozan was the largest wheel until 1997 when it lost to a rival within Japan, which lost to the London eye before several others successively claimed the title). Unsurprisingly this ended as mainly an exercise in watching the mist, and the clouds, and the rain but was nice and on a good day must be stunning (or terrifying depending on your love for heights).

After my trip I returned to the bar I'd eaten at the week before in Shinsaibashi and had more octopus (I really like it, ok?) and it's at this point the mist really rolls in. Japan is pretty easy to drink in for less than I'm used to in London and the people are very friendly: I made an friend at the bar and several hours were spent trying to understand each-other (phrase book = most useful thing ever). The excitement left me a little stranded at the end of the night when I managed to get the last subway home but missed the connection to the last monorail (pretty much all public transport bar taxis shut down at about 12:30, which is when I arrived in Senri-chou for the connection).

According to some of the people in the hostel it's traditional, upon getting stranded, to find an internet café where you can get all you can drink drinks and 'net time for a fixed fee that will cover several hours kip, unfortunately I was stranded away from a café so had the pleasure of walking home in the rain. It was actually quiet nice: my umbrella kept me dry enough (lesson the second as well as a phrase book carry an umbrella) and it was interesting (in a torrential kind of way) although any longer and I may have enjoyed it less (2 hours was more than enough time to sober up).

Home safe I slept it off on Sunday and have a coffee and reading day back in Senri-chou in the sun shine.

and now it's back to another week of poking circuits and science!


I think the heat has gotten to me .... this is a disturbingly chipper upbeat post... ah well maybe its tiredness.

Friday 25 June 2010

Stuff wot I found....

It's raining and I've not got up properly so before I go and enjoy the aquarium I thought I'd leave some links to some of the odder things I've found online in the last while:

Country hip-hop dancing (stampa med leyroy has competition)


And zombie pirates in love



Enjoy!

Friday 18 June 2010

first visit to MUSIC


Well I finally got to see what I'm working on today: MUSIC. Housed in the RCNP (Research Centre for Nuclear Physics) at Osaka University it is a FFAG (Fixed Field Alternating Gradient) that will be used to accelerate muons (a heavier version of the electron) these will then be studied and used to probe matter as well as generally make people go 'oooooh' (and then hopefully give us money to make us go away).

Like any good student while I was there I maintained complete decorum, for about 2 minutes. The whole facility was intensely cool, very much like something out of Half-life. As a building it is not made for humans, it's made for machines, humans just occasionally have to move around it: you're constantly ducking under piping stepping over cables, there are rooms full of boxes each controlling enough power to keep the average home going for month, the corridors are half shared with massive (utterly massive) bundles of high voltage cabling and most of the doors have fail safes on (and are generally about 50cm thick iron).

One of the strangest things about the whole site is that it's old, the first cyclotron was finished in 1973, so the whole place is well established and worryingly organic in feel at times this feeling strongest when comparing the equipment: on one hand is MUSIC, built less than a year ago consisting of finely polished metal shaped to incredible precision; on the other hand are the sections of proton beam pipe, lengths of well used metal held aloft by metal segments, controlled with magnets that are chipped and bruised.

Anyway, rather than ramble further I will leave you this link to my picasa album, it has several pictures of the experiment hall and control room - hopefully the captions will give some idea of what's going on feel free to leave questions in the comments though. 

PS feel free to look at the other albums with photos from my trip so far

Thursday 17 June 2010

Email death?

This is an interesting blog post on the BBC's dot.maggie discussing the recent proclamation from Chief Operating Officer at Facebook, Sheryl Sandberg, that the humble '@' is doomed. Her logic seems reasonable: that if you look at teenagers few of them use email compared to facebook and similar.

She may be right on that count but I think she's over looked one fatal flaw. Ubiquity, everyone has email (well everyone online) fewer have facebook, you need an email account to set up facebook, and buy things, and sign on to many websites. While the good 'ole boys at facebook would love to replace email it's not imminent and frankly I think their track record isn't good enough to convince enough people to use them such that they become all encompassing enough to remove email, I certainly hope they don't.

I think we'll have email for a while yet if for no other reason than it's a standard not controlled by any one group, it's by no means perfect but equally if you dislike your provider you can switch and lose very little, you don't need to convince all your friends to jump ship with you, or set up ghost accounts (like I'm thinking of doing with FB), or fake things you can simply change you email: gmail boring you? try hotmail, or yahoo, or just use a gorilla mail account that goes after 1 hour.

I think there is a secondary element she has forgetten as well which is that the Internet is no longer just about the up-and-coming teens its about everyone; email may be old but it's known,  it's used a by professionals, O.A.Ps, primary school kids and teenagers. Yes, lots of people chat on facebook but I doubt many people use it or twitter to distribute minutes for a meeting or arrange how a problem is going to be tackled, and even if they did what happens if they need to leaise with someone on bebo?

I'm sure she's right, that in the long run email will die, but I expect that will only happen when something completely replaces it. Google tried with wave but failed at the same fatal flaw she missed - everyone has to use it and not realise they are using it, it has to be ubiquitous. What ever replaces email needs to be the next phone number, the next email - most likely a universal id you can pick up and put down but will always find you be it email, phone call, video call or what ever; this is not an advocacy for ID card style thing, I'm talking of a phone number (or email address or what ever) that everything is routed through. We're nearly there as this already happens on most smart phones but using a variety of different addresses (your email, your twitter, your facebook your phone all have separate accounts) the next big thing will be a combination account for at least phone, email, and probably video calls. The problem with this is that it will probably require a big chance: tele companies giving up and becoming purely supply of data while people move themselves around separately to their distributor within the Internet (I won't call it the cloud because I don't think that's what it'll be, maybe cloud 2).

Monday 14 June 2010

The day the work began

Today was my first day working in at the Osaka University physics dept. it was a bit messy. After running late (combination of late start and missing the bus) we managed to meet our supervisor out here at about 10, we then got a tour and proceeded to wow him with our lack of knowledge (seriously he looked shocked). The up shot is that I now have about 100 pages of a book to read and a 2nd year undergrad experiment, calibrate a scintillator, to do by tomorrow afternoon (can't use the lab tomorrow afternoon so some analysis can be done but we also have to give a presentation at the weekly group meeting at 6). In short it's a bit stressful, especially as the experiment doesn't seem to be working as expected.

That was pretty much my day, the weather has been clearer today (at least no rain) and hot again.

Hopefully tomorrow will be better and I can get on with some proper work, until then I leave you with an explanation for the platypus...



UPDATE: In addition to platypus I think people should read this essay on the Burqa. It explains concisely and clearly why banning the burqa is pants-on-head stupid.

Sunday 13 June 2010

Travelling in Japan (or why staying up till 6 isn't clever)

Well I'm now in my base of operations for the next two months: Osaka. I started off in Tsukuba where the KEK centre in and travelled down this afternoon, and what have I learnt? That despite the assurances of my Australian flat mate travelling hungover is not a good thing.

Last night was our collaboration dinner in which our hosts took us all out for a traditional Japanese meal. It was excellent, we had our own small room and as much beer and food as we could eat in 2 hours for ¥5,000 (about £35). The food was delicious and much more than sushi: there was lots of tempura, meat and veg cooked on table top hot plates (each person had their own little burner upon which they could cook their food) lots of sashimi and all sorts of other odds and ends (giant Japanese radish for example). After this we had 3 hours of Kareoke which once you're drunk enough is a lot of fun (and after all that free beer we certainly were), a very sore throat and several bleeding ears (I can't sing) we moved to the other end of town to watch the England - USA game. By the time we finished it was 6am and the sun was up.

Four hours of 'sleep' later is was time to get up again to get down here. I have no idea how I managed this. I was supposed to be travelling with a fellow PhD student but he'd got up, checked out and then gone to sleep in his supervisor's room for the afternoon as of writing he's still not here and in an hour and a half they close reception so he's cutting it fine (I've heard he left at 6 - its a 5 hour journey). The journey itself was several parts: first a train from Tsukuba to Ahkibara (I nearly forgot my rucksack with my laptop in it luckily someone got it to me this was the same person who woke me up at the station as well people are lovely!) After this first train was a second to get me to the main Tokyo station (Akhibara is a suburb) then 2 hours on the bullet train to Osaka then another train and a monorail to where I'm staying (which is right on the outskirts).

I passed some amazing scenery on the journey and I have one photo to prove it, unfortunately for most of the time I was passed out with only intermittent bouts of paranoia induced wakefulness when my brain remembered that I may actually need to get off the train at some point.

One thing this journey taught me is how amazingly useful it is that most people know at least a little English without it I would have been stuffed, the second super useful thing is that most signs here have an English translation, that being said I'm certainly going to have to try and learn Japanese.

Anyway this will probably be revised soon once I'm actually feeling better (still a little hungover and very tired) also I'm getting kicked off the public PC I'm using (the wifi here is bricked).

Thursday 10 June 2010

First Missive from Japan

Right this is an attempt at a travel log.

I've now been in Japan a day and a half having arrived late afternoon on Wednesday and it is now early morning (ie 6am) Friday.

I've not done too much so far: after arriving the four of us travelling (all of us from my group @ uni) had the joy of a further 1.75 hour bus ride to top off our 10 hour flight before we arrived at Tsukuba. A huge meal and a lot of beer later I think (I think we ordered pretty much everything off the menu) it was time for a restless night. Thursday (the first full day here) consisted of the workshop I'm attending so another bus ride followed by 10 hours of conference in a sweltering lecture theatre.  We finished the day with a traditional (or so I'm told) Japanese meal which had a minimal amount of sushi but was lovely none-the-less: several small courses and a bowl of fish and vegetables on a burner.

Anyway I'm now running late if I want to get some photos taken before breakfast and another 10 hours of conference so I'm off