30 September 2008

Publication-quality plots in MATLAB

I've done something similar (but much more simple), but this article has some interesting points. Now if only MathWorks would fix that stupid bug that showed up with the latest Java update.

Here's what I do: it scales the fonts and figures (using hgexport) and markers so that they show up as not to small a size when included as 3-inch figures, changes the font to Times, makes the minimum line width 0.5 points, exports to EPS, and uses the epstopdf tool to convert it to a pdf (since Matlab's pdf export is buggy and always puts the image on an 8.5 x 11 page). The results look consistent and very clean.

UPDATE 11/30/2008: I fixed the behavior of some of the resizing when there are multiple axes on a single figure.

UPDATE 01/21/2009: For future updates, see the projects page

24 September 2008

Random number generators

I spent a good deal of time today -- way more than I should have -- looking at random number generators, specifically the ones in Boost (which are aliased by its std::tr1 deal). It turns out, based on my limited testing, that they're incredibly slow. The Mersenne Twister here is up to five times as fast. If I ever write a real Monte Carlo program, I definitely won't want to make my program five times slower if I don't have to.

I also spent about an hour trying to find where in my header files I'd somehow done "using namespace std", or if I'd accidentally included a instead of a , because somehow sqrt and rand were in the global namespace. It turns out that gcc's implementation automatically makes all the math functions global. Boo.

22 September 2008

What the functor?

Today I did the most advanced C++ programming that I've ever done. It's a recursively templated function that checks for soft equivalence of two doubles, or two vectors of doubles, or two vectors of vectors of doubles, or so on and so on.

This evening, I took that design and added functors to it, so that it can do any arbitrary comparison. I'd just read about them yesterday and gone, "Huh. What kind of weird application could those have?"

10 September 2008


My professor on pseudo-random numbers in the context of Monte Carlo:
They look like random numbers, they smell like random numbers, and by God, we're going to treat them like random numbers.