Home

Research

Geek

DVDs

CDs

Books

Nabla

Nabla is Not A Blog, Alright? It's just my random online ramblings, and any similarity is obviously some kind of coincidence. Nothing to see here, move along...

Electronics for Newbies: The LCM555

Having not played with any electronics for something over a decade, I thought it'd be time to whip out the breadboard again. So, I thought I'd start with the bog-standard newbie construction, a 555-based blinking LED. This time round, for fun, I thought I'd use an LCM555 CMOS-based 555, since it apparently wouldn't do bad things to the power rail, which is nice, as my eventual goal was to use the 555 as a clock for some sequential circuitry while testing. I looked at the reference circuit design, plugged it into a surplus Nokia phone charger (the LCM555's got a nice, wide supply range, so I didn't think too hard here), plugged it all together, and... nothing.

So, yay, electronics debugging time! For the first time in my life, I actually bothered to learn how the 555 works, rather than treat it as a magic incantation for making something blink. It's actually rather straightforward and neat, but I'd never bothered getting the datasheet before. Once I understood how it worked, I realised I'd been choosing resistor values that were basically shorting it. You'd have hoped something might mention not to do this, but noone seems to bother. D'oh.

I fix that up and... nothing. Even a fresh chip doesn't work. I'm now a little frustrated, but at least I understand how it's supposed to work. I now set up a simple test circuit which removes all that faff with capacitors, so that it should basically run in a steady state and show its hysteresis:

I plug this in, and it behaves weirdly. The the lower level switches on, but then it immediately switches off above this level - there's no hysteresis up to the higher level. Why this asymmetry between the levels? Could it be something to do with the adjustment pin ('CV')? Nope. The circuit should be quite static, without a capacitor, so I shouldn't be seeing any glitchy behaviour. However, when I put more bypass caps in, it goes from on/off to on/slight glow. Hmmm.

Argh. Sticking a multimeter in min/max mode voltage on the power supply reveals a rather high max, and a min of zero. Frequency? 100Hz. Yay, we have a fully-rectified but unsmoothed, yet alone regulated power supply. I'd really assumed that thing would be regulated. Apparently not!

The attachment of a 9V battery (they're convenient in that you can attach them using crocodile clips, if you don't have a proper snap), and everything works fine!

So, now I've been learning up on power supply theory. Horowitz and Hill has been sitting on my shelf for years - I tried reading it front-to-back before, and wedged somewhere near the start of Chapter 3, but I've now zipped through the whole of the power supplies chapter. I only needed about 3 pages, but it's fascinating, and each chapter seems to be about as self-contained as it can be, so it's been surprisingly engrossing.

I could just power my future projects off batteries. Not a 9V, since many of the digital chips I'm looking at max out not far over 5V, but maybe a set of rechargeable AAs. However, I now want to play with all the options, so I've ordered a few battery holders, plus the chips, caps etc. for both linear and switching regulators. I think the switching regulators should be overkill, but at least fun to play with.

We'll see how it goes.

Permalink. Posted 08:39, Wed, 03 Mar 2010.

Python is the new BASIC

This is not an original blog post title. Others have said the same thing, followed by a post body saying 'but I don't mean that in a disparaging way'. Let's get one thing clear. I mean this in a disparaging way.

Ok, it is a good beginner's language. And unlike Dijkstra thought about BASIC, you can learn it as your first language, and you won't be scarred forever (just like BASIC). However, you will eventually need to move on from this language and be rehabilitated into society before you can be fixed up. You need to acknowledge that it's not a real language, and so few Python programmers admit this. :p

The problems I have with the language are, basically, that it's a dynamically-typed grab bag of ideas from all over the place. So, its core design isn't particularly coherent. As the ideas were copied without real understanding, they're done wrong, and there are unpleasant bodges. Dynamic typing means there are whole classes of error you can pointlessly leave in, waiting for the appropriate runtime failure. Yeah, you can do insane amounts of testing and run other tools, but... a solid, static type-check from the get go is just so much cleaner and safer. And that matters.

The problems I have with Python programmers is that they think they know something. The language is neither low-level, nor cutting edge. It doesn't show you the hardware, or bring you to neat theory. It just gets the job done, and because it's so pragmatic, it gets the job done badly. So Python programmers, having chosen this particular sub-optimal point in the space of programming languages for themselves, are either ignorant or deluded.

(I'm still programming Haskell for my day job. It's an impractical and basically ludicrous language. However, the right language doesn't exist, and it certainly doesn't have an excellent compiler and set of libraries. In the meantime, I love Haskell.)

Permalink. Posted 23:58, Mon, 21 Dec 2009.

Finding bugs in the GHC runtime

Race conditions are always a pain. We just spent the better part of two days tracking down a race condition which caused our production executables to hang once in every few thousand invocations. Surprisingly, it wasn't the normal DllMain deadlock.

On the other hand, it was a nice excuse to play with WinDbg and binary patches.

See GHC Trac for details.

Permalink. Posted 14:13, Sat, 12 Dec 2009.

Magnetic Scrolls

My Project Euler addiction has been effectively destroyed by taking away my mathemtical ability. A new baby has had that effect on me. But I still have a puzzle urge and time between feeds. So, I've been looking at the old Magnetic Scrolls text adventures. I tried Fish! and Guild of Thieves nearly 20 years ago, but never really got very far, so I was intrigued about having another go. Jinxster looked like a lot of fun, so I had a go...

And generally, it was! As with so many adventure games of the era, it's unforgiving and pedantic. You have to spell things out, and if you make a mistake it'll let you keep playing even though you can't play to completion. Having said that, it's friendly as far as the genre goes. In-game characters sometimes provide subtle hints, and the structure of the game allows progress even if you're stuck on one puzzle.

On the whole, the puzzles are rewarding. Initially, I thought there were a number of evil red herrings in the game, but it looks like a number of puzzles can be solved multiple ways! I'm almost proud of myself. I made it through the whole game except the last puzzle without spoilers. When I read the spoiler for the final puzzle, it basically told me how to do what I was already trying to do. *sigh*

In fact, I found the whole ending section disappointing. The last puzzle was put together slightly shoddily, and the ending might have tried to be a clever twist but... no thanks. It's a shame, really, as I rather enjoyed the game as a whole. I may have to play another.

Permalink. Posted 16:09, Mon, 07 Dec 2009.

David Alexander Frankau

Having now announced this to most of our friends directly, this is now unembargo'd!

Caroline and I are delighted to announce the safe arrival of baby David Alexander Frankau, who was delivered safely at home at 8.04am on Friday 30th October 2009. He weighed 7 pounds 11 ounces at birth and is, in the opinion of his completely unbiased parents, the cutest baby ever!

Permalink. Posted 23:25, Tue, 10 Nov 2009.

Fun with pipes on Win32 (3)

So far I've talked about the irritation I was seeing on the C++/Win32 parent process side. However, we also saw weirdness on the Haskell side. Everything is done inside a System.Timeout.timeout call, so that the process really should never wedge. The parent process, being buggy, was doing a blocking read on stdout. The child process was writing to stderr. We saw weird behaviour:

The first piece of behaviour is expected... but what's going on in the other two cases? In the last case, the OS buffer is filled, the write call blocks, and as the write is inside the timeout block the timeout occurs. We might expect this, but why only over 4608 bytes? Haskell internally buffers 512 byte blocks. So, if you write over 4608 bytes, it'll fill up the internal buffer 9 times, write out 4096 bytes (to fill the OS buffer), and then trigger a final write, inside the 'timeout' block. The process times out.

Between 4097 and 4608 bytes, the internal buffer will be drained 8 times, writing out 4096 bytes to the OS, and filling its pipe, but leaving the internal non-empty. We leave the 'timeout' block, and start to shut the process down. Our stderr internal buffer needs flushing, so we perform a blocking write, this time outside the 'timeout' block. Deadlock.

What's the upshot of this? If you want to know what's going on, you need to understand the details of your system, as abstractions leak. Oh, and if you want 'timeout' to work quite as you expect, you might want to flush your handles before the end of the block.

Permalink. Posted 22:33, Tue, 15 Sep 2009.

Fun with pipes on Win32 (2)

Previously, we'd moved from using anonymous pipes to communicate with our subprocess, to named pipes with unique names. Problem solved, right? Sadly not!

Rather than create completely unique names, I created names that were guaranteed to be unique for the lifetime of the sub-process. Generating totally unique names just seemed like overkill! So, I create one sub-process, then the next one, and use the same unique pipe name each time. As long as the sub-process has died, and the parent's end of the pipes are closed, the old pipe will go away, and a new pipe with the same name can be created.

Furthermore, our sub-process manager is multi-threaded. So, we can fire off multiple sub-proceses at the same time. However, the pipes weren't being closed properly (so we couldn't reuse the names) when run in multi-threaded mode. Why?

It's all to do with the way Win32 passes handles to sub-processes. In order to get a handle into a sub-process, we have to make the handle inheritable, and then spawn the sub-process with 'inherit all inheritable handles'. Unfortunately, if you spawn two subprocesses around the same time, both children will inherit the handles (even if they're not wired up to stdin/out/err in that particular process). So, the other process is holding the pipe open.

We can reduce the window by closing the pipe as soon as the sub-process is fired off, but the race is still there. We could then hold a lock during the spawn step, but it's slightly icky to introduce the extra synchronisation. Personally, I think it'd have been nice to control exactly which handles are passed to which subprocess, but this looks like a weakness of the Win32 API. Unix-style APIs, using fork/exec allow you to control the exact handle (file descriptor) set-up for the child. Gah.

Another funkier approach that I didn't try is to spawn the sub-process suspended, use DuplicateHandle to poke the handles into the sub-process, and then unsuspend the process, to spawn a subprocess with exactly the handles required.

So what did I do? I just made the pipe names globally unique.

Permalink. Posted 22:07, Tue, 15 Sep 2009.

Fun with pipes on Win32 (1)

Most of my work nowadays is writing Haskell, but to interop with other systems we have COM server which fires off the Haskell processes and communicates with them through pipes - we could do things less indirectly, but this is a nice, simple way of decoupling the components. However, the pipes have been really quite irritating to deal with.

First off, Win32 anonymous pipes (the kind of pipes you'd expect to use to communicate with a child process) don't support WaitForMultipleObjects. This is really quite irritating if you want to support select-style reading from your sub-process. Why might you want to do this? Well, the alternatives are:

So, instead I tried WaitForMultipleObjects-ing on the handle. MSDN said I couldn't, but MSDN lies about lots of stuff. It turns out MSDN was telling the truth, although it wasn't immediately obvious. It basically immediately returns (without error), so we then perform a blocking read on the pipe, leading to the deadlock described above, as we wait to read one pipe, and the child waits to write the other.

The solution? Use named pipes, with unique names. This link contains the basic source, which you may want to adjust for your personal use, while complaining that the Win32 API really should do this right itself, especially since it's such a common usage case.

Permalink. Posted 21:43, Tue, 15 Sep 2009.

I own a Nokia 2630.

This is a rubbish phone. Fundamentally, the call quality is shocking. I assume the aerial is rubbish. The user interface lags - I push a button and have to wait to see something happen. I reckon there's a half-second lag betwen me hitting the keys, and the phone actually locking or unlocking, and ditto for most other operations. I previously had a 6230, and while it had its foibles, at least the text went in as you typed it, the keypad had less inconvenient buttons, and resuming an interrupted text was super-simple. How, given fewer constraints than previous generations, they've managed to make the interface worse, I do not know.

In fact, I only discovered how to change the volume on this thing today, thanks to googling, as I felt so silly being unable to do that. Left and right directional keys during a phone conversation, apparently. Makes me realise how much I liked dedicated volume keys. Even my 3210 used up and down, I think.

This is my fourth Nokia phone, as I've generally found them consistent and straightforward. Oh, and apparently they've had good sound quality, 'cos in comparison, this thing's rubbish. I try to choose simple, small phones, 'cos all I want to do is keep it in my pocket (small) and make calls and send texts (simple). So, I got this simple cheapo phone. It does admittedly deliver on the small side, but given it doesn't actually make phone calls very well, I should probably just keep my pocket empty instead.

I have a suspicion that they could make a cheap, high-quality phone, but they'd rather make their low-end model rubbish, to encourage you to upgrade. After all, they couldn't deliberately design something as bad as this, could they?

Permalink. Posted 23:18, Sat, 14 Mar 2009.

We had a skiing holiday

Not particularly exciting for anyone who wasn't present, but I enjoyed this sufficiently to talk to anyone who'll listen to me about it. Caroline and I went on holiday to Courchevel with a couple of friends. Caroline doesn't ski, and so hung around and absorbed the ambience. I went on the slopes and just massively enjoyed it. We were last in the area a couple of years ago (La Tania last time, 1850 this year), and at the time I did one red run and was petrified. This time we spent most of our time on the reds, and it really opened the place up and was just so much fun that I have a giant grin on my face writing about this, just thinking about it.

Outside of the skiing, our gap-yearing chalet host was fantastic, and our friends' toddler upped the cute factor (so glad I didn't have to play any role of responsibility, though ;). A wonderful break. But gosh, Courchevel's expensive!

Permalink. Posted 22:57, Sat, 14 Mar 2009.

I'm going to have a paper published!

For the first time in years, I'm going to have a paper published ("Going Functional on Exotic Trades" in the Journal of Functional Programming), which is remarkably pleasant. It's my day-job in paper form, and it's mentioned at the bottom of my now-recently-updated research web page. Yays.

Permalink. Posted 23:26, Tue, 09 Dec 2008.

The C++ Standards Committee Hate Me

This is the only possible reason I can think of for the fact that the default "precision" value for an ostream is 6. What does this mean? It means that any floating-point number it prints out will be rounded to 6 significant digits.

What?! Why?! Let's put this into perspective. A double-precision floating-point number commonly has a 56-bit mantissa. Let's be generous, and say that each decimal place requires 4 bits to represent it. We'll even ignore the hidden bit. That's still 14 digits. Even if you then go and assume that your calculations have destroyed half the precision, pretty much a worst case unless you're either doing something wrong or are in hardcore numerical-analysis land, that's still 7 significant figures. And that's a very generous worst-case analysis.

Let's look at it another way. 32-bit ints go to 10 significant figures. They can be stored exactly in normal doubles. They can be printed directly, and that's fine, but if you cast them through a double first, the default will truncate them when you print them.

I have a program that reads in numbers and prints them out again. I assumed sensible defaults for precision. I lost. I have had to fix the precision on my ostreams before writing to them, and I have no idea why. I'm sure there are situations where 6 significant figures are what you want. On the other hand, I would very much like it if that were something you had to select, and the defaults weren't incredibly stupid for default use.

Pah.

Permalink. Posted 22:36, Sun, 07 Dec 2008.

Rules of thumb in writing code

There are a number of rules of thumb when writing code. Things that are generally accepted as good style and ways to work. You know, things like employing abstraction and making stuff data-driven. What they don't tell you is that there's too much of a good thing. This is patently obvious - you can always make things more data driven by adding an extra interpreter, and you can always stick more wrappers in for 'abstraction'. Put another way, you're trying to find a maxima of style in program space, and this isn't going to happen by heading traipsing off to infinity.

They're called 'design decisions' for a reason. There's a decision to be made. You can't hide behind just doing commonly accepted 'good' things. If you do that, you're going to end up producing 'enterprise' code which runs around in circles, reinvents all kinds of wheels and/or pulls in every library you can think of, bloats out to infinity, and is still a complete pain to actually maintain. And then I have to review the code and explain what's wrong. And guess what? Every single decision will get justified as doing what is commonly accepted as good practice. *sigh*

Permalink. Posted 22:07, Fri, 12 Sep 2008.

On Rewriting Code

This note is somewhat bitter. It's about the software event horizon, beyond which a piece of software sucks and there is nothing you can do about it. It's something I encountered a couple of years ago, so hopefully it's far enough away, and I've filed off all the serial numbers. It was in another team. And besides, the project is dead.

It has been claimed that the single worst mistake you can make you can make on a big software project is to rewrite it from scratch. On the other hand, I believe there are situations where the best thing you can do is to throw it all away and start again. Presumably, these two situations are distinct, and the sign of an experienced developer is one who can choose the best course?

No. Sometimes, the code base is just screwed. It's dead, and you don't know it yet. You can rewrite from scratch, and it'll fail. You can maintain the existing code, and it'll just bog down and become a programmer trap, a developer black hole. In retrospect, you'll say you should have done the other thing.

However, you're just in a no-win situation. What can you do? Well, often it's not actually that bad. It'll be painful, but you can start retrofitting test harnesses, decoupling components, and pull the code base back to something where sensible decisions can be made. However, if your code has plenty of race conditions, relies on 'strategic leaks' and generally has bodge upon bodge upon bodge, it may be a no-hoper. I suggest firing the management involved for letting it get into this situation. Then fire their management for letting them do that. For bonus points, trawl through the source control logs for the very worst bugs introduced, and put the developers involved on the 'do not rehire' list (obviously they won't still be with you - such a project requires high turnover).

In summary, the best thing to do is to steer clear of such projects. For some reason, no-one believes it can be that screwed up, so whatever you do people will be unimpressed. Run away from a zombie code base while there's still time!

Permalink. Posted 11:21, Tue, 29 Jul 2008.

Yellow Peril

I made a hideous discovery in Heffers, the Cambridge bookshop, just before I got married: The Springer Yellow Sale. A very dangerous event for the wallets of wannabe mathematicians. In the Yellow Sale, plenty of Springer maths books are pretty much half price. This reduces them from eye-wateringly expensive down to just plain expensive. Who can resist half-price introductions to p-adic numbers? Suffice to say that, despite my already huge maths book backlog, I've now got a few more lined up. Ho hum. I'm weak. Sale ends at the end of July!

Permalink. Posted 22:49, Sat, 26 Jul 2008.

Protocol Buffers

You may well have heard of Google's Protocol Buffers, the latest and trendiest way to treat everything as a nail. The logic goes something like this: XML is complicated, verbose, expensive to process and ubiquitous. So, let's use something completely different for everything instead!

What's XML good for? It's a decent representation of structured data. So, we get to use it as an insane way of writing RPC requests and obfuscating data better put in a CSV file. Oh, and serialising objects. This is all obviously rubbish, and Google's protocol buffers will solve everything. Until we realise the weaknesses of the new format, that is.

What might be nice is if people actually applied sensible tools for the job, and didn't conflate different requirements. Protocol buffers are a lightweight IDL implementation, so it's probably best to use it for that. Use it to generate RPC requests. Maybe use it for inter-language communication of data-structures, and limited persistence.

Then notice that protocol buffers aren't self-describing, aren't easily human readable or editable, and things like that. Note that you might want to use JSON or even XML for appropriate situations. CSV maybe. And notice that object serialisation (as opposed to data structure serialisation) is something you don't want to conflate with other stuff, because if you do it'll become some kind of interface, and if you're really unlucky people will be editing the serialised structures by hand, and it's all a mess.

Please. Use the right tool for the job.

Permalink. Posted 00:05, Sat, 26 Jul 2008.

Fun with CoLoadLibrary

This is for the 3 other people in the world still using COM.

We're writing a 'front-end' COM server which wants to delegate work to back-end DLLs. Specifically, it will load up a DLL and pull out an object with the appropriate interface. It sidesteps CoCreateInstance, so we avoid lots of painful registry look-ups when we know exactly which server we want to implement the thing. Why would we do this? Because it allows us to supply our own version of DLL hell, rather than the COM-server-registration one which comes free as standard.

So, is all light and fluffy? Not quite. Normal COM object creation gives you appropriate cross-apartment marshalling and proper DLL unloading. The marshalling isn't a problem - the newly created object just ends up living in the same apartment as the loader object. What about DLL unloading? COM normally allows libraries loaded for the sake of accessing COM servers to be unloaded after a period of unuse through CoFreeUnusedLibraries(Ex). So, if COM didn't load our library, it won't unload it. Argh.

What's specifically the problem? Suppose we have a COM server in the back-end with instances still alive in it. Then it can't be unloaded. Moreover, it can't unload itself when the last instance goes away (FreeLibraryAndExitThread being the nearest thing, but with nasty race conditions). The only thing that knows it needs unloading, and that can unload it, is the front-end library which LoadLibrary'd the back-end. So, this thing must be prevented from unloading until all the back-ends have disappeared.

It looks a mess, since the loaded DLL has to somehow inform the front-end when it's done with, so that the front-end can unload it, and in turn be allowed to unload. Quite a faff. Why can't we just tell COM to unload the back-end for us when all the objects are gone?

Back in the day there was CoLoadLibrary, which had an 'AutoFree' parameter, which did just that. COM would take control of the unloading of the DLL at the appropriate point. Except... it no longer works. MSDN helpfully notes this, after explaining how it would work if it did. In practice, no error is raised if you use this flag. Effectively, it just silently leaks the DLL.

So, how did the COM unloading mechanism work anyway? It calls DllCanUnloadNow on all the COM servers loaded through CoCreateInstance, and on any that return true, it then unloads the DLLs. In the end we just used this mechanism to fake up the COM unloading system. COM would ask our front-end DLL if it could unload, and this would trigger a cascade of DllCanUnloadNows on the back-end DLLs. If they could be unloaded, they got unloaded, and our front-end DLL finally gets unloaded only if it's supporting no objects, and all the libraries it loaded are now unloaded.

It works, but WHY OH WHY COULDN'T THEY JUST LEAVE POOR COLOADLIBRARY ALONE?

Permalink. Posted 22:56, Wed, 23 Jul 2008.

On the Naming of Climbing Shoes

In an attempt to improve my health, I'm trying to get a bit more exercise. Specifically, I'm trying to take up climbing (we'll see if I keep it up). Since rental shoes are, er, pretty grim, I bought myself some climbing shoes. I got them from Rock On at Craggy Island, the climbing centre in Guildford. I recommend both the centre and the shop to beginners. I can't tell if the guy in the shop was actually knowledgable, as I'm a novice, but he did a very good impression and was very helpful!

But what shoes did I get? I got a pair of 'Ballet "Gold"'. Yes. The quotes are in the name. I checked, and they are men's shoes. I love the combination of macho-ness and class that comes from combining the word 'ballet' with a precious metal in quotes. Presumably they feared that if they didn't use the quotes someone would sue them for the lack of valuable metals. Taking this line of reason, I assume it must actually be possible to do ballet in these shoes, although it does seem unlikely.

In short, I suspect the marketing department involved do not speak English.

Permalink. Posted 21:08, Sun, 20 Jul 2008.

Best Art For Under 10 Grand

We went to the Royal Academy Summer Exhibition the other week. It was rather good, although we didn't come away with anything (some of the works are fairly cheap, and pretty good, but nothing affordable really connected with us). However, it did give us a chance to find a few artists which we really rather liked. So:

Disqualified on price were Ken Howard and David Tindle.

When we win the National Lottery, these guys better beware.

Permalink. Posted 22:45, Mon, 07 Jul 2008.

Wedded!

Caroline and I are now married! We got married at St. John's College chapel, Cambridge on 7 June, and have just returned from a little honeymoon in the middle of nowhere. While we have tonnes to say on the subject, I think we'll leave it at that for the moment!

Permalink. Posted 16:03, Fri, 13 Jun 2008.

Solving Rubik's Cube

A few weeks ago I went on a recruiting thingie at the Cambridge Computer Lab. As well as trying to recruit grads, it's a chance to grab freebies from other stands. I got a nice Rubik's Cube, which gave me a bit of a flashback.

When I was small, I got a Rubik's Cube, but never solved it. Fun, but frustrating. When the Rubik's Magic came out, I sidestepped the whole puzzle element, and got it with a book solving it. I think I missed the point a bit there, but it was a good fun toy. When the Rubik's Clock came out, I finally solved one. Got it Christmas Day, solved it Boxing Day, my family thought it wasn't good value for money, but I rather enjoyed it. A couple of years later, I got a little book on solving the Rubik's Cube, but didn't actually work out how to solve it myself. Ho hum.

So, this time round I thought I'd solve it properly. My plan was to grab a few basic sequences, and then build it up into a full solving sequence. First, a bit of notation. The front and back faces are F and B. L and R for left and right, and U and D are the top and bottom. Edges pieces can be specified with two letters (e.g. UR), and corners with three (e.g. URF). I'll write a particular face rotation with either a positive sign (e.g. +U) for that face being rotated clockwise, or minus for anticlockwise. I'll use '3X' to mean repeating the sequence 'X' 3 times.

So, after a few simple experiments, I find the sequence 3(+L+L+U+U) swaps FU and BU, and FL and BL. The other sequence I used was based on explicitly trying to shuffle some of the squares around. The sequence is +L+F+F-R+F+F-L+F+R-F, and what it does to the top is... complex. We'll call this sequence 'X'.

It's easy enough to get one face sorted, so that one third is right. Put that face on D and then line up the centres of the non-U faces to match the colours on the lower edge. Then all you need to do to get the middle sorted is to fix the edges in the middle layer. You can do this by arranging it so that the ones you want to swap are at FR and UL, and then do +L+U 3(+U+U+F+F) -U-L. Once you've done that for all the middle edges, it's only the top to go!

We can now use this 'X' sequence to tidy up the top. X will shuffle around various edges and corners, and change which face of them faces where, but main thing to note is that URB stays where it is (turning in place), while the other corners rotate round. So, by putting the appropriate top corner into URB and applying X, you should be able to get the corners into place for the appropriate colours. However, they won't yet be facing the right way up.

Applying X 3 times shuffles puts the corners back where they started, but facing different ways up. More specifically, URB is identical to how it was before, but the other three corners are turned clockwise on the spot. By repeatedly carefully choosing the corner to be URB, and then applying 3X, you'll now have everything complete but the top edges. The top edges can now be completed by variations on the 3(+L+L+U+U) sequence. If you want to swap two pairs of faces, it then becomes quite simple: Find a short sequence which places those pairs you want to swap into FU/BU and FL/BL, apply the swap sequence, and then undo your original sequence by running it backwards (unturning faces in the reverse order). My group theory is more than a little rusty, but the operations you can create this way are the conjugates of our original swap operation. This is the technique we used to fix up the middle-layer edges.

This will do a certain amount of edge-swapping, but we can end up with situations where we want to rotate around three edges, and the swap operation doesn't make this look easy. Can we do it? We can't do it by just swapping top edges, but we can temporarily untidy the middle. Let's say we want to cycle UL, UB and UF. We'll choose two more 'victim' edges, whose roles are to be swapped at appropriate times, but end up where they started. These will be FL and FR. Then we arrange a pair of those conjugate-based swaps, to achieve the cycle. In the following table, each new row represents two sets of edges being swapped around. The swapped elements are in bold:

UBULUFFLFR
ULUBUFFRFL
ULUFUBFLFR

At the end, we've cycled those three pieces around. While I haven't proven it, this appeared to be the final piece I needed, and I've been able to solve the cube several times using the above toolkit. It is, however, a very unwieldy toolkit. The sequences chosen are built by incremental construction from smaller sequences, rather than finding the shortest sequence to do the job. The idea was to see how much I could build up starting with only a very small set of 'primitive' operations. If you're interested in solving the cube quickly, the booklet I bought all those years ago, 'Resolving Rubik's Cube' by Jon Millington, does the job most effectively, although not with much in the way of motivation. There's plenty of fun in finding your own way to solve the cube, though.

Permalink. Posted 08:55, Mon, 10 Dec 2007.

The St. Petersburg Game

The other day, someone I used to know at uni and I were discussing the "St. Petersburg Game". Basically, you repeatedly throw a coin until a heads appears, and then you pay out 2^n, where n is the number of tails thrown before the heads appeared. How much would you pay to play this game? In theory, the expectation of this game is infinite, so if you're fully risk neutral and everyone will always be able to pay up, you'd pay any amount.

So, there are two ways to generate a more realistic price to pay the game. My argument was that I'm risk-averse, and so I have some utility function for my money. I might buy a 1 pound lottery ticket with a million-to-one odds for a million pound payout. I wouldn't buy a thousand pound lottery ticket with a thousand-to-one odds of a million payout. My argument was that for one go at the game, I wouldn't want to pay more than 3 or 4, because I'm not really interested in remote chances of earning vast amounts, I'm interested in a reasonable chance of not making a big loss.

His argument was that credit needs to be taken into account. Beyond a certainly point, you would go bust. So, I might as well truncate the series that generates the expectation at that point. In other words, if you can only pay out a million, (2^20), the fair value is 11. This only makes sense if I'm playing repeatedly, but apparently that's the case he was thinking about. Certainly, if I'm playing repeatedly, I'd pay more than 3 or 4, since I'd have a much better chance of seeing some of the big payouts which make it worth it (this may sound woolly, but I'll try to make it a bit more concrete later on).

So, if we're playing repeatedly, fair value isn't what we care about, really. What we care about is the end-state. We assume that the two players will keep going until one of them gets wiped out. Unfortunately, my maths isn't good enough to work out closed form solutions for probabilities of wipe-out given different starting account values, so I wrote a simulation instead. I hacked it up fairly quickly, so it's probably annoyingly buggy, but I hope I haven't made an error fundamental enough to invalidate the whole thing.

What I'm doing is a set of simulations, where for each simulation I find the break-even level, where if I paid more I'd go bust first, and if I paid less you'd go bust first. I collected the results for 1000 simulations, assuming that I have one million and you have one million, to start with. I then took some percentiles, and prices:

PercentilePrice
10%9.948271666
20%10.18424126
30%10.43704421
40%10.66959518
50%10.98563359
60%11.36414737
70%11.84457506
80%12.97528121
90%16.04786940
PricePercentile
10.532.90%
1150.20%
11.562.7%

So, 10% of the time, if we both start with a million, I'd lose even if I paid 9.95, and 10% of the time, you'd lose even if I paid 16.05. It looks like the price which gives us even chances of wiping out our opponent is actually near 10.99, which looks suspiciously like our fair value!

This is, of course, assuming that I'm willing to risk losing a million in order to gain a million. What happens if my pockets are much deeper, or shallower, than my opponents' (Or that I just want to place my stop-loss closer)? Why, I'll just run my simulation again with different parameters... first up, I have 100K with which to steal your million:

PercentilePrice
10%8.288661462
20%8.560000916
30%8.744448393
40%8.959470526
50%9.151535916
60%9.403354633
70%9.664265445
80%10.00022710
90%10.78195451

So, even if I paid 10, rather than the fair value of 11, I'd still get wiped out 80% of the time. And if I have 1M with which to try to remove your 100K?

PercentilePrice
10%10.13697085
20%10.64982176
30%11.07549714
40%11.53903907
50%12.14243862
60%13.05499767
70%14.48813500
80%16.87636127
90%25.58518196

So, if I were willing to lose 1M half the time, in order to win 100K the other half, I'd be happy to pay about 10% over the fair price associated with you having 1M. Not surprising that I'm willing to pay more if I'm happy to take the same risk for less reward. However, another way to look at it is that if we both had 100K, I'd be willing to play around 9.3 to play for a 50% chance of winning - i.e. an expectation of 0. At the 1M level, this price is now 11. If I want the expectation to be zero for winning 100K or losing 1M, I need to win 90.9% of the time. At that percentile, I'd be willing to pay 10.1. This happily sits between the two bounding situations. No real shock, there.

Switching tacks, one of the things I noticed when running these simulations is that it can take several million plays to bankrupt someone if you start with a million each. If you really are throwing coins, you'd be giving up rather sooner. Another way of approaching the problem is to see what the percentiles are for the break-even prices if make each game consist of a certain number of plays. I've plotted the percentiles of prices for 1K, 10K, 100K and 1M plays per game:

PercentileBreakeven on 1KBreakeven on 10KBreakeven on 100KBreakeven on 1000K
10%4.5526.19097.833479.517169
20%4.9466.66378.359549.914645
30%5.2757.09398.6994010.315357
40%5.7397.52919.0915310.684029
50%6.1587.97149.5443911.188397
60%6.8028.540610.3450311.798191
70%7.6269.570011.0293612.726459
80%9.01211.057612.5820514.213793
90%13.25814.526315.8342518.443645

As you can see, the amount it's worth paying per go to break even at each percentile level even increases with the number of goes you play before stopping. Why is this? As I said woollily before, the longer you play, the more likely you are to actually see one of the big payouts. In a way, the behaviour of this thing is rather like a log-normal distribution, where the mean and median are in different places, but more so. In each case, the mean payout is infinite, but the median starts to slide upwards with the number of goes.

Another thing to notice is that the increase in payout with number of steps matches the appearance of less-likely cases. So, if you're truncating at a certain level of unlikeliness, doing 1000 times as many games means truncating 10 steps later (2^10 being approximately 1000), and thus the price being 5 greater. Look at the price difference between the 1K and 1M column, and this is what you see. Extrapolating back, if I'm willing to pay 3 or 4 to play the game once, I'm effectively at the 75 percentile price. Which sounds about right - I would only be willing to lose three quarters of the time in order to get a hopefully pretty impressive payout that last quarter of the time.

I think this approach provides a slightly different way of looking at the game. Remember, the above prices are without bounding the pay-offs, so we're not taking the credit approach. The expected payout is still infinite. However, if we're only interested in what happens in sensibly common cases, this is more useful. This is basically a VaR approach. The credit approach can also be looked at as finding the expectation, contingent on being in particularly large percentile. Mathematical modelling of finance has always been rather poor at getting the behaviour in the tails right....

Permalink. Posted 16:03, Sun, 09 Dec 2007.

Engagement!

I am now engaged. So is Caroline. We are engaged. To each other. It's great. This is actually surprisingly old news, having happened on 30 June, but I've just been taking my time getting around to writing this up. This says less about our excitement at getting engaged, so much as my incredibly slack process of writing things up.

I think it was all rather good. We'd gone up to Cambridge for a long weekend to celebrate our third anniversary, and had a nice meal at Midsummer House. Then I proposed, and Caroline accepted. We were both very happy. The food's really very good.

So. Hurrah. We're now looking at a wedding date of 7 June 2008, at St. John's College chapel.

Permalink. Posted 21:47, Sat, 24 Nov 2007.

Enterprise Middleware Development

I wrote this a few weeks ago, but never stuck it up:

I'm reading Joel on Software at the moment. It's quite interesting, and I'll no doubt review it at the appropriate juncture. What I have noticed, however, is how product-focussed he is. With user interfaces and stuff. We don't really do that. While we kind of have users, we really have people who interface with our code, and in the distance we have the angry shouts of actual end users. In other words, we are doing Enterprise Middleware Development. It's that polysyllabic. We're also not coding for the long term - the codebase isn't static and requirements are always changing. Anyway, I thought I'd share some of the thoughts I've had:

Permalink. Posted 22:33, Sat, 21 Oct 2006.

Further Congratulations to Matt and Cat!

Matt Kelly and Cat White got married. I was present. It was great. I don't really have a huge amount to say about this beyond the fact it was in Wales, the service was lovely, the food was tasty, and the evening was most entertaining. Especially Ben. I hope the couple are enjoying themselves in, um, Thailand, I believe.

Permalink. Posted 23:50, Mon, 18 Sep 2006.

Software Reliability

It's a bit of a random link, but I've recently been trying to remember a talk I saw at the Computer Lab about the horrendous state of software reliability. I've finally tracked the author down, and Professor Les Hatton has a fascinating view on this stuff that just makes you want to give up and do something completely different. He's a bit of a polymath, so it looks like there's some other cool stuff there, but I haven't really had an in-depth dig. The paper on optimising your phone tariff versus the phone companies' obfuscated talk plans, for example, is quite fun.

Permalink. Posted 23:10, Thu, 20 Jul 2006.

New York, New York!

We went to New York just over a couple of months ago. I've just finished writing it up. On the other hand, it's about 5000 words scraped out of odds and ends of time. There are pictures, too, so don't worry too much. So, without further ado, what we did on our holidays

Permalink. Posted 01:05, Wed, 26 Apr 2006.

Congratulations to Matt Kelly and Cat White! (and other random bits)

On Saturday, I attended Matt and Cat's engagement party in the relatively spiffy surroundings of New College, Oxford. It's not bad, as far as the Other Place goes. Matt was a housemate in St. John's Road when we were grad students, and Cat was his girlfriend then. So, it's great news and a good excuse for a catch-up. I'm very much looking forward to the wedding in September.

Matt berated me for not putting more random rubbish on my website, so presumably I'm supposed to mention things like last week Caroline bought me a deep-fat fryer for my birthday, and today the kitchen cupboards fall down (well, only partially - we took them down before they totally collapsed).

I'm probably also supposed to mention pet peeves, like the chunky protective cases people have for ipod nanos, and other similar goods. Why do these thing exist? These electronic goods are designed to be small, and will be worthless in a couple of years anyway. So, you're adding totally unnecesary and pointless bulk. Nice.

Permalink. Posted 01:23, Mon, 24 Apr 2006.

Sore Throats Suck

They do. You may think being off work sounds fun, but it's actually surprisingly boring and you don't get to catch up on the stuff you'd like to because you're actually lying around in bed. Even the Winter Olympics is inaccessible because the TV is downstairs and that's basically too big a move to shuffle a duvet/blanket/whatever. Darn.

So, if you're thinking of getting a sore throat, my advice: Don't.

Permalink. Posted 15:46, Tue, 14 Feb 2006.

I am a Doctor, Oh Yes

Dr. Simon Frankau, I'll have you know. I've been doctorified for about a month now, and the novelty still hasn't worn off. Well worth however many years of my life it was... :)

Permalink. Posted 00:11, Wed, 16 Nov 2005.

I have a new job!

I am moving to a new job. This news is a little less exciting than one might expect. My old job has been very good and has given me lots of experience, but a few people moving on made me think about where I wanted my career to go, and I want to do stuff with more maths in. So, I got a job with more opportunities for maths. I'm sad to leave, but I'll have to see how it goes....

Permalink. Posted 22:59, Sun, 25 Sep 2005.

Vienna!

Some time ago, Caroline and I had a most excellent short break in Vienna. Since then, I promised I would write it up, but then I've taken forever to do this, and since my memory's not excellent, I'm going to be reconstructing it all rather flakily. I should, however, point out that Vienna's a great place to visit. 'cos it is.

Tuesday 24 May: We arrive in Vienna. The flight wasn't particularly eventful, and we take the super double-decker express train into town which takes 15 minutes. The downside is that there's 30 minutes between departures and we just missed it. Not really a worry, since I'd just bought a Su Doku book in London, and was busy getting addicted. The view from the train is initially rather industrial, switching to alien suburban (the architecture being reasonably different to the UK, if quite nice) and finally urban. We get off, orient ourselves, and walk towards the hotel. Initial impression is... European city, really.

Walking through the historic centre, we don't really look at much in detail, but it all seems very pleasant. The city seems a good choice. But then... we try to find the hotel. The street I thought it was on is being repaved, and is partially closed. Could this be why we got such a good rate at a 5 star hotel (well... we thought we'd push the boat out a little on a short break :) ? It really didn't help that I hadn't printed out a full itinerary, or indeed the hotel's address, having been in a bit of a rush. We went up and down the street (most difficult, given it was mostly closed). No sign. We asked in another nearby hotel. Our hotel was backing on to the street in question, and was just round the corner, quite open, and looking rather nice.

Being rather tired, and perhaps a little emotionally strained, we checked in, cleaned up a little, and went for supper. I think I had something approximating steak and chips. Since it was quite late, the big restaurant was closed, so we were eating in a smaller, simpler restaurant. The language was alien, and it was difficult to tell if we were gently having the piss taken out of us, but it wasn't unpleasant and we toddled off for some well-earned rest.

I should probably mention that before going on holiday I was 'warned about the people'. While a few of the Viennese were a little brusque, generally they were very pleasant, especially given the amount of stress we must have been causing them with our language skills (having said that, Caroline's got a freaky ability to pick up a new language in about 3 days - by the end it appeared she could pretty much understand anything). It could well have been the areas we were wandering around (the rather expensive central part), but people were generally very smart and stylish. So, there you go.

Wednesday 25 May: Surprisingly for us, we got up in the morning. We started off with a trip round the ring road. Ring roads always make me think of the M25 and Milton Keynes for some reason, but this is something else entirely. A loop of pleasant buildings round the old centre. We saw the university, and the rather splendid town hall (Rathaus), and the Burgtheater, as well as the pretty gardens placed between them. It was now about lunchtime, so we popped into a nearby cafe for a drink and cake. Their legendary cake-making status is well-deserved - I had my first slice of Sachertorte and, well, wow.

Following on from this ever-so-healthy lunch, we walked through the Volksgarten, towards the Hofburg palace. The weather was pretty much fantastic throughout our stay in Vienna. Incredibly warm and dry. So, walking through big, pretty, well-maintained gardens. Such a chore, obviously. Having survived the onslaught of so many roses and a couple of fountains, we found ourselves at the Hofburg, palace of the Hapsburgs, and general all-round Impressive Big Place. I think we may have had a quick look at the Maria-Theresien Platz, staring at statues and the outside of the natural history museum and art museum, before passing back through the Hofburg and more into town.

It was about here that we lost our proper-historic-tourist footing, and just ambled around amongst the shops, getting quite impressed by expensive jewellry. We found St. Stephen's, whose roof pattern reminded me of lego. I suspect, in retrospect, there may have been a model of this building in legoland when I visited, or something. Either way, quite a fun blocky pattern. We later had a peek inside, and... it was churchy. Some of the stained glass was rather good, though.

From there, we wandered around and found the Albertina, an art gallery on the South end of the Hofburg complex. There was a Mondrian exhibition on, which was amazing, as it showed his development, and his early work was completely different to the style for which he's famous. You get the impression of a man on a long quest to find his own style. Some of his Braque-like work was quite fun, but the white-background geometric style for which he is known was the definite show-stealer.

From there, we saw an odd exhibition stretching from early art to modern. It was most interesting looking through the styles, and seeing what we liked and didn't, and finding out, unsurprisingly, that famous artists tended to produce better stuff than those we hadn't heard of. In the modern end, there were some unimpressive Picassos, some Giacomettis I rather liked, and a jaw-dropping work by Francis Bacon. It was one of his Popey ones, and it was horrendous, but amazing. So, so visceral. Pastel on black paper, or something like that, it was simultaneously blurred yet sharp. A nightmare on paper.

We finished the Albertina by looking through their bog-standard collection. Plenty of pictures of landscapes and people, arranged in state rooms that were themselves quite impressive. What I liked the most, though, were drawings by Durer. I can very much do without his paintings, in all their gaudy, weirdly-unrealistically-arranged glory, but the sketches were so detailed and personal, that they really did seem to reach across the centuries.

We went back to the hotel, exhausted, for a rest, before going out in the evening for a meal at a cafe. I risked the boiled meat with creamed spinach and potatoes, and it was really very nice, unexpectedly. The Viennese food is slightly unexciting, but generally very tasty for all that. After that, of course, we had cake. I had something a little chocolatey and alcoholy, while Caroline has tiramisu. We were both very happy.

Thursday 26 May: This was the day we saw the Schonnbrun palace, which was quite amazing. Since it's not in the old centre (I don't think they'd have room for it), we took the tube out, which was pleasant enough. When we got there... it was big. And very yellow. Bright yellow. Apparently it was a bit more baroque in earlier times, but one of the previous tenants made it a little more tasteful.

Having walked through the main court, we started off with the garden. It's huge and very nicely kept. Walking straight from the back of the palace, we reached the fountain. Or, as it seemed to me, a small lake. It was rather cooling, given the boiling weather. From there, we walked up a carefully-arranged hill, to the folly. Which, of course, had its own pond. The view of the palace from there was pretty stunning. After resting a while, we descended through a more shaded route, and grabbed some ice creams. Caroline appeared interested in the zoo, but somehow we escaped it. On the other hand, we never saw the maze, either.

Walking back to the building, through the shade, we worked our way around and bought tickets for the tour of the house. Having queued for the tickets, we discovered they were time-stamped, and we would only be let into the tour proper at the appointed time. Most odd, but at least it meant we got audio-guides. The tour was pretty impressive, going through a good set of huge rooms, with a reasonable amount of background information on the Hapsburgs. The ballroom area was probably one of the high points, but also very interesting were the slightly quieter bits, that gave an insight into the personal lives of the residents.

From there, we ventured out into the cafe for lunch. Rather pleasantly, the food didn't just appear to be an excuse to extract money from desperately hungry tourists. Yay.

Once we'd seen enough of the Schonbrunn palace, we made our way back into town. About this point, my memory becomes hazy, but I wouldn't be at all surprised if we just wandered back to the hotel, knackered from the heat, walking and splendour of the buildings.

After recuperating, we went out for an evening meal of 'klein' schnitzel, as it was described. It was sticking over the edge of the plate in most directions. It was about this point that I learnt again that 'lemon beer' is not some clever local concoction, but basically shandy. Fortunately, Caroline didn't laugh at me much, and was most willing to help me out with it. Shandied up, we made our way back, via the Viennese stock exchange, the outside of which I had a quick stare it. I'm still not sure why I found the whole concept quite so alien.

Friday 27 May: This was our last full day, so we were determined to make the most of it. Heading down towards the Hofburg, we went to see the Kunsthistory musem (an art gallery). The building was most fine - plenty of marble and the like, and a great place to hold the artwork. The art again provided an opportunity to discover that famous artists do tend to produce more impressive paintings than those less famous ones.

It was very interesting to see the Breugels. Personally, his stuff leaves me cold, but Caroline is apparently a great fan of the 'little people with pointy sticks' (which I must admit most aptly describes much of his work). Seeing them in the flesh, though, was much less offensive than I thought they might be. Another highlight was the set of paintings by Rubens. The first room we saw, we were massively unimpressed by his work, but this only emphasised his development - the second room was pretty breath-taking.

After touring the paintings, we had a quick meal, and went through the egyptology stuff. Unsurprisingly, this wasn't quite the same after the Egyptian museum in Cario, but there was still some very cool stuff there. From there, we raided the gift shop and wandered out dazed into the bright sunlight.

Next up, butterflies. There's a big butterfly-glasshouse-thing (I'm sure there's a German word for it) next to a garden behind the Albertina, and this is where we went. There really are some immensely beautiful butterflies about - something I hadn't really realised until going through this place. Such varied shapes, such bright colours... and some of them are about the size of bats! Towards the end one deemed me worth landing on (I suspect, given the heat and the humidity, that my perspiration might have been making a good lunch for it). Three or four people seemed to think this was worth taking photos of, and when we decided to leave I had to give it a certain amount of persuasion before it would detach. I don't think the owners would let me take it with me....

After some cafe-based recuperation, we tackled the Royal apartments. The rooms were generally similar to those in the Schonbrunn - a mixture of the impressive and the personal. Later in the tour was the 'Sisi museum'. Sisi (Elizabeth) appears to be something of a national figure - something akin to Diana over here (ahem), despite the fact that Sisi was many, many decades earlier. She apparently had a bit of a tragic life, in between being made to look immensely beautiful. She didn't eat much and exercised to keep her figure, refused to be painted or photographed beyond a certain age, and was killed with a file (yes, as in a small wood-working tool). Most interesting. Having done that, we took a quick turn of the royal silver (so many plates!), and the Hofburg was done.

That evening, we had our final Viennese supper at the hotel where we first asked about the location of the hotel at which we were staying. We sat outside, watched evening turn to night, and ate some rather good food. Afterwards, we had a bit of a walk, to the Danube (or at least a branch of it), across it, and back. It appears the river-side was where all the cool kids hang out.

Saturday 28 May:

Saturday was half a day's zip around before returning home. We started off with a trip to Freud's house, aka The Freud Museum. I'm not a massive Freud fan, but he's supposed to be really influential or something, and it was quite interesting to have a look around the place, anyway. There were some good resources for those who are deeply into his history, a fairly amateurish but nonetheless interesting selection of odds-and-ends, but I think the highlights were the areas preserved in original form.

Next off, we went over to the Freyung, a oddly-shaped square surrounded by palaces, churches, pleasant tourist traps, etc. This was a square we'd been through (and admired) a few times, although this time we went for a particular display: There was an exhibition of Magritte paintings going on. Initial inspection revealed a small selection of pretty unimpressive paintings. Uninspiring early works. I felt let down. Round the corner, there were some more, and these were getting to be things that did look like Magrittes, and not amateur knock-offs. Was that it? I finally realised, no, they actually did have quite a bit more, hidden round a corner, and some of them were pretty darn excellent. Yay.

Following that, we toyed with the idea of a horse ride round the city, as we'd been planning for a couple of days (or rather, Caroline had been persuading me, and I'd been lamely claiming that another time would be preferable). Sadly, we were both getting pretty nasty hayfever (with horse straw the prime suspect), so we skipped that idea. About now we were starting to run out of time, what with the remaining time for food, getting to the airport, etc., so we had our final look around the city, buying a Sacher torte, collecting our bags, and off for the flight home. That was pretty uneventful, and our holiday was done. Ho hum. Until next time....

Permalink. Posted 01:43, Tue, 30 Aug 2005.

Ten Years...

Over the weekend was the tenth anniversary of my mother's death. Not the kind of thing I normally put here, and not much I can say, but there you go. She was an exceptionally kind and loving mother, and an all-round great person. I can't believe it's been so long.

Permalink. Posted 09:13, Tue, 02 Aug 2005.

Working for The Man

Having basically completed my PhD, bar the administrivia, I've got myself a job. It was surprisingly simple. A trader e-mailed me asking if I'd like a job working on a fairly interesting project, I said 'maybe', I came for an interview/look round, and I got a part-time job. 6 months later I went permanent and full-time.

I'd never really considered investment banking before, as I'd always been put off by the recruitment stuff looking for highly-motivated go-getting blah blah leaders of tomorrow, rather than people who want to write good code. Fortunately, it turns out they hire those too occasionally. The industry has constantly surprised me (in both positive and negative ways).

So, what's my job? It's working on a Monte Carlo farm. What's that? It's a way of using several hundred PCs to work out how much complicated deals are worth (pricing), and how to manage them so the bank doesn't fall over when the stock market moves (hedging). It's all actually quite neat.

Permalink. Posted 23:36, Wed, 23 Mar 2005.

Skiing is fun

Not particularly surprising, given the number of people who do it, but it really is great, and I feel annoyed that I hadn't done it for so much of my life. You can pick up the basics in a matter of hours, and then the satisfaction of improving is great - almost as much as how fun it is to just go sliding downhill on snow. I'd been for a couple of introductory lessons on a dry slope before, but it just does it absolutely no justice.

We (Eben, Liz, Caroline and myself) went to Heavenly, on the South of Lake Tahoe, the California-Nevada border (plenty of casinos nearby), and the scenery is absolutely stunning (beautiful snow, skies, lots of lovely trees), and the scale of the runs just makes the dry slopes seem comedy. I'd always thought of Winter as dark and gloomy, but this was Winter at its very best - pretty much Summer, but not too hot, and with soft, fluffy snow everywhere.

Well, that's not strictly true. On our final day it snowed quite heavily, and Eben and I were determined to make the most of it. It was actually very fun, in a freezing cold white-out kind of way. The blizzards cleared briefly, giving an absolutely amazing view of Nevada. Anyway, rewind to the start of the holiday....

Lessons are well worth it. They're not cheap, but I suppose the whole holiday thing isn't particularly. On the other hand, they're a great way to get started quickly. In a week I got from pretty much nothing, through greens to simple blues, although my impression is that Heavenly is a fairly fluffy resort, ratings-wise. Myself and Caroline learnt to ski, while Eben learnt to snowboard. Liz planned to snowboard, but reverted to her skiing roots (yay).

I should probably also point out that winter sports are a great way of getting injured. Somehow (without any obvious instant where it started), my ankle started to hurt, so that I couldn't walk in boots. Skiing, fine, walking normally, fine, walking in boots, big pain. Fortunately, it didn't affect me too much, after a day off. Eben and Liz had their own accidents, and it seems Caroline, who seemed to have the most conservative approach, was the only one of us to come out unscathed. Although she did get quite tired quite regularly. :)

Having said that, so did I. After a day of skiing we couldn't manage much more than supper and bed. How people do apres-ski, I have no idea. On the other hand, Americans really know how to do food. Their steaks are just fantastic, and I'd recommend Echo at the Embassy Suites, Fire and Ice, and the Hawaiian sushi place whose name I've forgotten. Cecil's bar and grill was disappointing. Oh, and the food on the piste is pretty poor, too, but you'll be too busy skiing, won't you?

It was my first holiday in the US mainland, and Caroline's first visit to the US, and although there's probably some skew from the fact it's a holiday resort, the whole place was just so... American. Everything was bigger, the people insanely friendly, and everywhere there were little touches that just kept making us want to pinch ourselves, see if it's a dream. Ok, so maybe we're a little easily-pleased by that kind of stuff. :)

Finally, I think I should give a bit of a run-down of the runs I'd been down:

Permalink. Posted 23:22, Wed, 23 Mar 2005.

Edinburgh and the Fringe

I went to Edinburgh with Caroline for a week to see the Fringe. It was much fun. Having not been to Scotland before, it was a most interesting experience. Coming from Cambridge, Edinburgh is incredibly vertical. Perhaps it's not much compared to some other bits of Scotland, but still... wow. Literal high points were the Castle itself, Carlton Hill and Arthur's Seat. Interestingly, Arthur's Seat had some very steep edges, but not a single safety barrier in sight. Similarly, you could climb all over the pseudo-classical ruins on Carlton Hill. It's almost like people have to take responsibility for their own safety. Quite different from most English tourist sites.

It's not only the landscape that's vertical. There are some very tall buildings. Some are 8 or 9 storeys tall while carrying it off as if they were only 3 floors high. The architecture is generally wonderful, making it a very pleasant place to walk around. On the other hand, there was a surprisingly large amount of obesity. Or perhaps not so surprising, given the legend of the deep-fried Mars bar. Perhaps it's defence against the cold weather. Oddly, while we were there, the weather remained quite dry, and even reasonably sunny. Excellent.

Some time later I'll review the shows we went to see....

Permalink. Posted 18:18, Sat, 28 Aug 2004.

Yay for Caroline

Caroline Parr is a very nice human being, and (rather to my surprise) my girlfriend. She seems to like my web pages, and so now gets to feature in them (don't you feel lucky, Caroline? :). She has a job where she simultaneously saves the planet and organises parties. How cool is that? She's also great in ways too innumerable to mention, so I'll stop here (there's only so much being smug you can do before your friends kill you).

Permalink. Posted 00:15, Tue, 13 Jul 2004.

They're coming to get you!

The RIAA and/or MPAA seem to have cottoned on to the existence of IRC, and now have machines that trawl IRC, presumably for fserves. Of course, they don't do it obviously, but instead use anonymous bots which regularly change through nondescript names.

I'm on a channel which I use to keep in contact with my uni friends, on Quakenet. It's fairly close-nit, with regulars, so we tend to notice random people who pop in, say nothing and then leave. I used to think 'how rude', but then I noticed that some were the same IP repeating. It appeared to be a bot which kept joining, but doing nothing... so I thought I'd investigate (eventually). And then I noticed there were at least a couple which'd been popping in:

Permalink. Posted 13:27, Tue, 15 Jun 2004.

TheTrainLine.com are evil

Thetrainline.com is an online ticket selling company. You book tickets online, collect them from a machine at the station, and go on your way. The online system gave me a cheapter option than I'd managed to find searching through the touch-screen gui, so I thought I'd try to use it. However...

They don't let you collect tickets in Cambridge. They take 2 hours (!) to transfer the information from their database to the machines. They charge 10 pounds for cancellation, even if you never collected the tickets. So, when I ordered tickets in the evening in London before going home, I was totally screwed. I've been charged 10 quid to have a couple of lines entered into a database and removed a while later.

Mysteriously enough, while debiting my account was pretty instant, the refund process is insanely slow. For some reason, it involves phoning up a national rate number in order to cancel. That is, to cancel an online order. The website says it may be possible to change the ticket type. Nope, not a chance, despite the fact that no tickets had been issued.

My only possible interpretation is that the service is deliberately crap, and they plan to make their profit using refund charges from disgusted customers. Well, they got me. Bastards. I should have used a credit card for the order, and cancelled the item through that.

Permalink. Posted 23:33, Sun, 23 May 2004.

Egyptian Holiday

I have just returned from a fortnight in Egypt (more specifically, in Cairo, with a a day-trip to Alexandria). I'll probably do a write-up of what I saw and did later, but in the mean-time I thought I'd share some random odds-and-ends.

The whole thing was a big lump of culture shock for me. I'd never been outside of the "Western" world before (just Europe and a brief conference in Hawaii). As such, everything was a bit stressful. Enjoyable, fun and highly worthwhile but also very tiring.

People are friendly! But aggressively so! It's a friendliness that is quite unnerving, especially when combined with the concept of 'baksheesh', or 'getting a tip for doing very little, and certainly nothing you want'. Stand still too long in a railway station, people will help you out without asking, and then want money for it. Take a photo near the pyramids? People will want money if their camel appears, or if you took it from 'their' spot. The amount people want is generally small, and this is their livelihood - the gap between rich and poor seems huge. But... it's just very stressful if you're not used to it.

Of course, why settle for a fixed amount if you can get a percentage? In the souk, if you express interest in something they don't have, will they point you to who has it? No, they'll lead you there. How kind. The fact that they'll hang around while you buy stuff, and the prices mysteriously inflate is besides the point. Alternatively, you will stay at the original shop, and they'll fetch stuff for you. Again, most kind, apart from in the financial aspects.

The souk is probably the most scarily-friendly-because-we-want-your-money place. You very quickly harden up to all the invitations, compliments and so on, if you wish to survive. Dark glasses are a good idea, as simply looking at a shop can cause the owner to pounce on you (this even happens to a lesser extent at some of the high-street stores). The quality of spoken English is really very good - apparently there is a good free education system, so the tourist-pestering scum you encounter may well be highly educated. And when Japanese, Spanish and so on appear... they get their native language used too. Highly impressive.

The above may make the country sound like a nation of money-grabbing insincere sales-weasels, but it's not like that. Those who aren't selling things are just as friendly as those who are. Indeed, it's quite difficult to not be insulting having got used to the souk, ignoring people who really are just wishing you well, rather than trying to rip you off.

The universal catch-phrase is 'Welcome to Egypt!'. I suspect they must be trained at school, so that a foreigner pops up, and all the children have to shout 'Welcome to Egypt!'. The fastest gets a lollipop, and the slowest beaten, or something. Adults often want to shake your hand (and I'm talking about strangers on the street, here), while children will also try out 'What's your name?' and 'Where are you from?'. Big smiles all round.

The traffic is lethal. It appears road-markings are an approximate guide, and cars will fit into any space they can (more or less). There's hardly a car that's undented, and horns are in permanent use. Indicators mean nothing, but that's okay, 'cos I've no idea how to indicate for pulling across 3 rows of traffic (fitted onto 2 lanes), and performing a random u-turn. Most roads are one-way, presumably because otherwise all the cars would just mingle together in opposite directions.

Taxis are extremely popular. They were painted black with white panels, and were generally the most beaten-up vehicles. Ancient Ladas and all sorts are in use. Many have fur-covered dashboards and danglies from the mirror. A tissue box on the dashboard is universal, and seat-belts... uncommon. Various taxis are kitted out with dodgy 'sports' extras, blue neon lights, etc. However, they seem to have totally ignored tuning the engines, which spew out plenty of pollution. Cairo has limited visibility in the daytime, good sunsets, and washing your hair will result in much grey water.

Back to taxis: Egyptian prices are unavailable to tourists, who instead resort to haggling. Haggling causes me pain, since I always end up feeling I must have got a rubbish deal. Sometimes later, I find that I have. There's always an extra 100% profit margin more than you think. Fortunately, I went with an arabic-speaker, which made life much simpler.

Of course, there's money to be made in Westerners, so you get nicely obnoxious taxi-drivers hanging around outside tourist traps, offering you taxis, at impressively extortionate (for Cairo - very cheap for anywhere else) rates. If you don't ignore them, they'll follow you, and make sure any other taxis you try to pick up know that you deserve a 'very special price'. Perhaps they'll want a commission on whatever you finally get. If you do ignore them, they'll still follow you, but not quite so far.

If you stand by the side of the road, the taxis will also be keen to get you. This complicates the other interaction with Cairo traffic: crossing the road. The basic technique involves estimating a gap in the traffic, and boldly strolling across the road. Drivers expect this, and will drive around you, as long as you keep moving. Hesitation will confuse them and could be messy. Guess what my UK-trained instincts tell me to do, in the face of speeding rust-buckets? Of course, timing the gap is difficult if half the traffic is taxis trying to pick you up. At peak time, you may have to cross the road a lane at a time, with the traffic flowing around you. Again, this is complicated by the way that flows of traffic and marked lanes have nothing like a one-to-one correspondence.

Having said all that, we didn't experience a single crash while we were there. I suppose it just goes to show that with infrequent events, perceived risk can get really screwed up. I'm sure the accident rate is many times that of the UK, but people are prepared to accept it in that situation. Moreover, people are used to that style of driving, and so expect things that would be unimaginable on English roads. One result is that cars just seem to be expected to get bashed. When parking, the 'keep going until contact' mechanism appears universally used. Kerbs are high, so that it is quite easy to scrape the underside of bumpers and so on, but people just seem to accept it.

I may sound very negative of Cairo, but these are just the aspects I found most alien, and since they're so strongly ingrained in me, I suspect I'll view anything different as somehow wrong. Having said that, I greatly enjoyed my holiday, and indeed much of what I have been ranting about. The differences were most interesting, and made the holiday worthwhile, but also oh so tiring.

Permalink. Posted 22:23, Wed, 07 Apr 2004.

Mail me at random.user@arbitrary.name.