The Samovar

My mathematical genealogy
February 16, 2009, 7:58 pm
Filed under: Academia, Frivolity, Mathematics

The Mathematics Genealogy Project has a huge database of mathematicians, showing who was supervised by whom, and what students everyone had. If you’re a mathematician, you can use this to trace back who your mathematical ancestors were and it can be quite fun. Below is a chart I made of my own mathematical genealogy. It’s nice to see exciting names from the history of mathematics and science there, such as Poisson, Laplace, Lagrange, d’Alembert, Euler, the Bernoullis, Leibniz,  and Huygens (I stopped at that point). The dates are when they finished their doctorate, or if they didn’t do one, when they lived.


Best. Scrabble. Ever.
October 30, 2008, 9:26 pm
Filed under: Scrabble | Tags: ,

I finally broke the 500 barrier in Scrabble! Getting 3 words using all my tiles in the first 6 goes was certainly a good start (amorous, annealer and torrents). And the combined total was 933 – not too shabby.

Stupid holiday pictures

So I’ve been on holiday in the US for a couple of weeks, and I don’t have much to say about it so here are some photos for those who might be interested.

This place was useful when our rental car tyre burst:

My own version of shock and awe:

OK, maybe mild surprise and amusement is more accurate.

One of the first things we did was to visit The French Laundry restaurant. For those who don’t know, FL is one of the three restaurants that keep getting voted as the best restaurant in the world year after year. The other two are The Fat Duck (in the UK) and El Bulli (in Spain). It’s my goal to have been to all three. So far then I’ve managed The Fat Duck and FL. For what it’s worth, my opinion is that Fat Duck is far, far better than FL – it’s really in a whole different league. The meal I had at FL was good, amazing in fact, but it was just a very well executed version of classic Michelin three star cuisine (places like Gordon Ramsay in London).

Anyway, here’s a picture of me enjoying Moulard duck foie gras en terrine with royal blenheim apricots, jacobsen’s farm green almonds, baby leeks, frisée and toasted brioche, with three different salts. One nice feature of this was that as you ate it, they kept coming to replace your brioche so that it was always warm. Click it for a larger version.

You can also take a look at the menu:

And “our vegetarian friends” as the waiter rather patronisingly called them are also catered for:

To be honest, in many ways The Cedars Restaurant in Detroit, Oregon (that’s right, not the big detroit, the one with a population of 262) was more exciting. Only $7 for a Gourmet Burger, $3.50 for a malt shake and $3.25 for a cherry pie.

And if you look closely, you’ll see that none other than Yogi bear recommends it, and how could I argue with that?

Yep, that was one heck of a malt shake.

Maybe the most exciting part of the holiday was almost getting caught in a forest fire. The sky in California was dense with smoke the whole time we were there, and this fire that we drove past was part of a complex of 30,000 acres. They shut the road shortly after we drove past here. You could also buy fire t-shirts at the fire fighting headquarters about a mile down the road.

I also had some fun playing around with high dynamic range photography like I talked about in my last post, but they weren’t particularly exciting. More fun was using Photoshop’s Image Merge tool to automatically combine lots of overlapping photos into one single image to make panoramas like this one (you have to click to see the whole thing):

That was right near the unlikely named Bumpass Hell in Lassen National Volcanic Park.

Quite a contrast to Wales where we went on our return. It must be quite a hoot for Americans to come and visit Europe with buildings several times older than their country.

This church at Partrishow had a fantastic medieval wall painting of Death:

And this nearby church at Cwmyoy was fun too (recently restored, although it looks to me like it’s about to fall over):

Oh, and this also happened while I was in California, but I managed to escape OK.

HDR with a crappy mobile phone camera
June 16, 2008, 10:26 pm
Filed under: Frivolity | Tags: , , ,

I can’t be bothered to carry a camera around with me wherever I go, but my mobile phone camera produces pretty shitty images, especially in low light levels. Here’s an example of my living room with normal indoor lights:

You can probably see the noisy image at this reduced size, but if we zoom into the full resolution it gets much worse. Take a look at the teapot:

A couple of days ago it struck me that it ought to be possible, in principle, to take multiple photos of the same scene and have some software align them as best as possible, do some sort of averaging process and eliminate the noise. I’d heard about high dynamic range imaging (HDRI) before and it seemed like the sort of software techniques you’d need for that would be similar to the problem I’m set myself. And sure enough, they are, and it turns out Adobe Photoshop CS3 has some tools for this built in. So what I did was to take 13 pictures from the same place, each one with a different brightness level (to try to capture details at all the different light levels), and merge them together using Photoshop’s “Merge to HDR” tool. Once the image is merged into HDR, you show it to someone on a standard dynamic range monitor (i.e. everyone), you need to convert it to a normal dynamic range image, and there are various ways to do this. I just tried Photoshop’s default setting, and it’s “highlight compression” setting, and here are the results:

As you can probably see, the detail is much clearer and there’s much less noise. This is even clearer on a close up, take a look at the teapot in the new version:


If you have Photoshop, it’s only a matter of a few minutes to load these pictures in to do this, and there may well be free software out there that does the same thing. The biggest problem with this way of getting decent pictures out of a mobile phone camera is that you have to take the same picture from roughly the same angle lots of times. Sometimes you can do this, but sometimes it’s a bit more difficult. Fortunately, my phone has a ‘burst mode’, which takes 4 pictures in very quick succession. It’s still not going to be any good for a scene with moving objects in it (because they will just blur), but it takes the hassle out of taking the same picture over and over.

Anyway, for future food and cake pictures on this blog (always taken with my phone because I don’t own a camera), expect the quality to be much better now that I know about this HDR technique.

Does anyone else have any tips for getting the best out of a mobile phone camera? Mine’s a Sony Ericsson K750i incidentally. And just to finish up with, here’s a gallery including the full 1600x1200ish photos so you can look at the detail close up.

Update. I just added three new pics to the gallery, two of books and tea where I took 16 images all at the same brightness level and merged them to HDR, and another one of the living room but with different and slightly more natural looking colours.

Sausage dog?
April 19, 2008, 8:08 pm
Filed under: Frivolity | Tags:

Seen on a street in Paris – anyone care to enlighten me as to what this might mean?

Smallest number of keypresses
March 6, 2008, 1:39 am
Filed under: Frivolity, Mathematics

OK, this is not the entry I promised in my last blog entry, but…

What is the quickest way to type 250 c’s in a row in a standard Windows text field? I make it 24, can anyone beat that?

c, c, (press and hold) ctrl, a, c, v, v, v, v, v, a, c, v, v, v, v, v, a, c, v, v, v, v, v

Comments Off on Smallest number of keypresses

Countdown numbers game in Python

One of the things about being ill is that you have to spend a lot of time in bed with nothing much to do. Having watched the whole first series of the Sopranos, I had to find something else. So here’s the result. I revisited an old program I wrote many years ago to solve the Countdown numbers game.

In this game, you’re given six numbers between 1 and 100 and a target number between 100 and 999. You’re given 30 seconds to try to make the target using the six numbers and the operations plus, minus, times and divide.

I originally wrote a program to solve this many years ago (when I was about 14 I think), but the algorithm I used was pretty horrible. I worked out by hand all the possible arrangements of brackets you could have for six numbers, and then tried each operator and number in each appropriate slot. It worked, but it was ugly programming.

Recently I’ve been learning Python for an academic project, and so I thought I may as well try rewriting it in Python. I think the solution I’ve come up with is nicer than any of the solutions I’ve found on the internet (mostly written in Java or C), although having written it I found this paper which uses a very similar solution to mine (but in Haskell rather than Python).

Python programmers might get something from the minimal code below (all comments and docs stripped out), or you can take a look at the full source code here, including detailed comments and docs explaining the code and algorithm.

My ideal (as always with Python) was to write a program you could just look at and understand the source code without comments, but I don’t think I achieved that. I’d be interested if a more experienced Python programmer could do so. Let me know.

This version is incomplete, from the slower version, and is supposed to be understandable without explanations (takes about 40 seconds to find all solutions, too slow for Countdown):

def ValidExpressions(sources,operators=standard_operators,minimal_remaining_sources=0):
    for value, i in zip(sources,range(len(sources))):
        yield TerminalExpression(value=value, remaining_sources=sources[:i]+sources[i+1:])
    if len(sources)>=2+minimal_remaining_sources:
        for lhs in ValidExpressions(sources,operators,minimal_remaining_sources+1):
            for rhs in ValidExpressions(lhs.remaining_sources, operators, minimal_remaining_sources):
                for f in operators:
                    try: yield BranchedExpression(operator=f, lhs=lhs, rhs=rhs, remaining_sources=rhs.remaining_sources)
                    except InvalidExpressionError: pass

def TargetExpressions(target,sources,operators=standard_operators):
    for expression in ValidExpressions(sources,operators):
        if expression.value==target:
            yield expression

This version is actually complete, from the faster version which needs the comments to explain (takes about 15 seconds to run, good enough to win Countdown):

sub = lambda x,y: x-y
def add(x,y):
    if x<=y: return x+y
    raise ValueError
def mul(x,y):
    if x=2+minremsources:
        for e1, rs1, v1 in expressions(sources,ops,minremsources+1):
            for e2, rs2, v2 in expressions(rs1,ops,minremsources):
                for o in ops:
                    try: yield ([o,e1,e2],rs2,o(v1,v2))
                    except ValueError: pass

def findfirsttarget(target,sources,ops=standard_ops):
    for e,s,v in expressions(sources,ops):
        if v==target:
            return e
    return []

Ineffective and paranoid (but I had a nice holiday)

One of the things about the paranoid security measures involved in international travel is how unreasonable and obviously ineffective they are. These new measures only burden the ordinary passenger, they would be pretty ineffective against someone who had malicious intent (as Bruce Schneier keeps going on about). I had my own experiences of this recently, but before I get to that, here is a picture of the view from my hotel window from last weekend:


The first incident was taking the Eurostar from Paris to London. When I arrived at the station I realised I’d forgotten my passport, but I thought it was worth trying to get on the train anyway. You have to pass through two separate passport controls at Gare du Nord in Paris – the French controls and the British ones. The French control didn’t really care, he just told me that it would be illegal for me to come back into France without my passport and waved me on. The British were a bit more paranoid, and after a few minutes of argument, they decided to test my Britishness by asking me questions about where I lived: what is the name of the pub on such-and-such street, etc. Fortunately for me, despite answering that question wrongly, I obviously said it with enough confidence that they were convinced I knew what I was talking about. Moral of the story: if you’re white and can bluff well you can get through security without a passport.


The second incident was travelling to Israel for a conference. Before they let me on the plane, I was questioned by Israeli security for 45 minutes. They noticed that I have a Jewish surname so they started off by asking if I was Jewish and if I had any Jewish family. Intrusive questioning continued, they asked me about why I was only carrying a small rucksack, why I was going for such a short time, who invited me to the conference, what theoretical neuroscience was, … Before they let me on the plane, they got me to log on to my email and show them the invitation to the conference.

Everyone at the conference was pretty surprised at this treatment, but on the way back I met someone at the airport in the departure lounge – he came up to me and said “I just got the 45 minute treatment. They made me do a 10 minute presentation on the talks we heard at the conference!” What if he’d been asleep during them?!

Anyway, after being questioned, they swabbed my bag meticulously and used their “Ionscan” to test for explosives. Very sensible you might think, except that having done that they slapped a ‘checked’ sticker on it and let me wander through the main terminal before checking in. D’oh!

Anyway, here’s a picture of the Golan Heights which you could see from the Technion university:


And the Bahá’í gardens:


Israel is actually a very nice place and I would have been entirely happy to be there if it weren’t for their government and relationship with the Palestinians. As it was, I felt a little uncomfortable, especially about the fact that the people around me would all have been in the army and might even have killed Palestinians.

Still, I’m not going to complain too much – they took me to two excellent restaurants in Haifa after all. 😉

Macaroons: a visual ode
November 10, 2007, 11:07 pm
Filed under: Frivolity | Tags:

In tribute to this site, I present an ode to the humble Paris macaroon (click for the full size version):


October 19, 2007, 9:15 pm
Filed under: Frivolity | Tags: , ,

Despite the title, this is not a post about New Labour, but about this lady…


No, I’m not just a perv posting silhouetted computer generated naked woman spinning for kicks. The strange thing about this is that you can see the woman spinning either clockwise or anti-clockwise. The article I got this from claims this has something to do with whether you are left-brained or right-brained, but that’s probably nonsense. You can also flip from seeing it one way to seeing it the other way. The way I got it to work was to look at the ‘reflection’ at the bottom, and try to convince myself that when I thought the upper foot was at the back, it was actually at the front. After a few spins, the woman at the top starting spinning the other way. From then on, she stayed spinning that way quite stably until I focused on something else and then looked back.

FWIW, I naturally see her spinning clockwise, which apparently means I use the right hand side of my brain more than the left (contrary to most people, according to the article). A quick search on the internet suggests this means I am visual, intuitive, etc.

Update: Just scoured the internet to see if anyone had written anything interesting about this, and the answer is: not really. Two pages did stand out though:

  • This one from NeuroLogica blog, which like me takes a pretty dim view of the whole left/right-brained thing
  • This one which shows two slightly modified versions of the animation side by side. Minor cues have been added to bias your interpretation of the image one way or the other, and they’re completely effective.