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.

mymathematicalgenealogy



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:

Impressive!

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 []