Thursday, March 31, 2011

Matlab liked my idea

Matlab is one of the most frequently used programming languages for science and engineering.

Though I can't verify it, it seems that Matlab has incorporated one of my ideas into its standard distribution.

Back in 2006, I was working on reconstruction algorithms for computed tomography (CT). Here is a video I made that demonstrates CT reconstruction. It takes the radon transform (at the bottom) and constructs the image slice (top).

I found Matlab's code slow, so I replaced the time-consuming part of their code with a faster version that I wrote. It was faster because I precompiled it using mex... nerd detail. I submitted my code to their File Exchange service so other people could benefit from it.

Anyhooo, in preparing my lecture on CT reconstruction today, I was suprised to see that Matlab's code was now faster than mine. WTF?!

I looked at their code, and saw that they had replaced the exact same part with mex code, just like I did.

Here is what a snippet of their original (slow) code looked like.

I replace it with the following code that calls the program I wrote (LinearBackproject).

And now this is what their new code looks like.

They even used my 0/1 flag (the last argument) to indicate to the iradonmex subroutine whether to use nearest-neighbour or linear interpolation.

Even if Matlab did use my code directly, I have no financial recourse. But it feels nice to be appreciated.

Friday, March 25, 2011

The Paradox of Choice: Book Review

Just finished listening to the audiobook version of The Paradox of Choice: Why More is Less by Barry Schwartz.

I'd first heard of this book a while back, and it sounded amazing. I reconnected with it in a rebroadcasted episode of the Skeptically Speaking podcast (actually, radio show).

Here's the idea. You walk up to a samples table at the grocery store and are faced with 6 brands of jam. You can try any or all of them. After, you can choose to buy some jam, or mosey on with your other business.

Suppose instead that you are faced with 24 brands of jam instead of 6. Logic dictates that you're likely to find a jam that's superior to any of the 6 in the original scenario. Again, you are free to purchase.

Which scenario do you think garners the most jam sales? The 24-jam case? WRONG! Significantly more people opt to buy jam when there are only 6 brands to compare. ... I know... WTF!

Paradoxically (hence the title), including more options actually makes all options seem less appealing, even though it gives one more of an opportunity to find the BEST option. Why? Dr. Schwartz offers a number of reasons. For example, when faced with more options, you have more pressure to find the best.

Another example: Students taking a photography course were allowed to keep one of their prints. However, half were allowed to reconsider their choice, and had the option to change their mind and select a different one of their prints to keep. Even though very few actually exchanged their prints, a survey revealed that those with no option to trade were happier with their print. Somehow, adding the option to change their minds made the free-to-choose group less satisfied with their choice. Paradox.

While having too much choice can make you unhappy, he's careful to point out that too little choice can also be a problem. He's not condoning slavery and destitution. But most of us are offered more options than we can realistically understand.

One of his central theses is the differences between "maximizers" and "satisficers". A maximizer is someone who wants to consider ALL the options, and is seriously interested in finding the best. A satisficer, on the other hand, is someone who wants to find an option that is simply good enough. I can related to being a maximizer, thinking of each decision as a challenge. But Schwartz supplies ample evidence from the scientific literature that maximizers are less happy than satisficers. Well, that sucks.

Luckily, he offers suggestions on how to limit the impact of choice in your life, to make you happier and regret less. But you'll have to read the book to find out what they are.

Tuesday, March 1, 2011

Evolution and Beer, two of my favourite things

Now there's a beer for all you Darwinists,

The circular seal on the left says, "Created in 27 days, not 7". Here's what it says on the back label,

I bought it at a ski resort in Utah, near Salt Lake City.