Saturday, 13 September 2008

Prisoner's Dilemma

A great way to think about the guts of cooperation.

But there's more to life than game theory.

Consider the scorpion and the frog: http://www.spectacle.org/995/scorp.html

Wednesday, 9 July 2008

C++ Screening Questions

Q1) When you compile and run this program, what happens?

#include <iostream>
class A
{
public:
~A() { throw std::exception("whatever"); }
};
int main()
{
try
{
A a;
}
catch(...)
{
std::cout << "caught" <<>
}
}


A) it prints "caught" and exits normally
B) the output is undefined
C) the program exits with a call to std::terminate()
D) something quite different from any of the above

Thursday, 15 May 2008

Reading: Yield Curves

1) The Basics

Google for "curve boostrapping" and get the PDF from the university of chicago, real simple

2) More info

Google for "A Practical Guide to Swap Curve Construction" by Uri Ron, there's a PDF on the Bank of Canada website, this has a bit more on the practicalities

3) Interpolation

P. S. Hagan and G. West "Interpolation Methods for Curve Construction" gives a thorough survey, with their own method "monotone convex" being touted as best - a copy is here: www.finmod.co.za/Hagan_West_curves_AMF.pdf

Template Metaprogramming: is it worth it?

I split C++ features into 3 classes:
* useless/dangerous: eg, export keyword, throw specifications, uncaught_exception
* significant downsides: eg, template metaprogramming
* essential: eg, const, exceptions, inheritance

The downsides of template metaprogramming are:
(a) inconsistent compiler support across vendors (this is improving all the time though)
(b) a lack of compiler support for decent error messages (being remedied as "concepts" in the next revision of C++, C++0x)
(c) a lack of compiler support for closures (being remedied as lamda functions in C++0x)
(d) a lack of compiler support for external templates ("export" is useless, again this is remedied in C++0x)
(e) a lack of standard library support for metaprogramming, particularly for type traits (again being remedied in C++0x)

I have seen the results of three attempts at different banks to introduce extensive templating into quant libraries using metaprogramming concepts that have failed for the reasons above - these are not theoretical concerns.

In the same way that a gentleman was once defined as "someone who can play the saxophone, but refrains from doing so", I'd regard a decent C++ programmer as someone who's read the literature on this (my own reading includes Josuttis/Vandevoorde. Abrahams/Gurtovoy, Alexandrescu, some of the older papers on expression templates) and then **refrains** from using template metaprogramming unless they have sufficient reason.

So - template metaprogramming? Probably not. Unless it's a good idea. In which case I'm all for it.