Skip to main content


Showing posts from February, 2009

Behold! the power of python

I was writing code to do bootstrapping on a set of data. I wanted a test case where if I asked for one bootstrap I would be returned the original data. lambdas and function references saved me from inefficient code.



model_grid[:,:,:,boot],params[:,boot]= \

Instead of


model_grid[:,:,:,boot],params[:,boot]= \

Finally - video chat between a mac and a PC - skype

So we tried google's video chat. The self test worked out on my parent's computer (a PC) and the self test worked out on my mac. Then when we tried the chat neither audio nor video worked.

It was a bit of a disappointment, because it seemed to me it should, going through flash, be platform independent, especially since the self-tests worked out.

What did work was Skype. I'm naturally suspicious of closed source free things - I'm waiting for the day when skype will start charging, but until then : the future is here see the person when you talk to them on the phone. That's what we were promised in the 21st century. Our flying cars and ships to mars arn't here yet, but I'll settle for the video phone on my computer...

Good experience with Apple customer service

MacBook has been acquiring splotches of gray pixels over time. It started within a few months of getting the computer. I ignored it at first but then the problem grew worse. I made an appointment to have it looked at in the Boylston store. The appointment was at 6:00pm but I did have to wait till 6:20pm. They looked at it, told me they have the model in stock and the repair would take 2-3 days. I went home, they called me two hours later and told me the repair was done! I picked it up on the way to work the next day. That's how service should be. The computer had a month left on the orgininal 1 year warranty.

The MIT musuem is so-so

For $7.50 the MIT museum is overpriced for what it is, unless you have kids dying to play with robots. I went mooching round the museum and enjoyed a handful of exhibits.

I most enjoyed the holography exhibition. One of the more impressive ones is a life size one of a singer. I also enjoyed the movie holograms - holograms that change as you move around them.

The mechanical sculptures are a bust. The only one I liked was a miniature chair that assembled and disassembled periodically.

I enjoyed looking at some of the old computer stuff - especially magnetic core memories. A lot of the 'robot artifacts' are indulgent self homages to things that MIT professors built and are not very impressive.

I liked the Harold Edgerton (high speed photography) exhibit.

Starting at 2:00pm there was an interactive robot thing that I didn't go to. Little kids were standing in line patiently and they were taken in in batches and had to wait 15min per batch. I didn't think it wold be appropriate …

warning: character constant too long for its type

Problem: C++ warning: character constant too long for its type
Solution: don't drink and drive - multi-byte strings require double quotes in C

I've never got this error before. What is it? Have I uncoverd a bug in gcc? How much money do I get. It turns out that I was drinking and coding. i.e. mixing python and c++. I haven't touched C in a few months. Maybe one. I have been analyzing my data using code written in python. (Aaah python). Any how. I remembered to put semicolons, I remembered whitespaces don't matter nomore, but I forgot that multi-byte strings require double quotes. Aah the joys of bilingualism. : debugging python programs after a crash

I haven't got the hang of the visual debugger in pydev, but what I have found most useful is the pdb module and the command.

Basically, right after your program crashes type (having done import pdb previously) and you enter the debugger from where you can print variables, manipulate them, run other python statements. Invaluable.

Also, typing 'up' gets you up the stack.

Frequency domain filtering in python

Original signal (buried in 3 kHz noise):

Discrete Fourier Transform:

Get rid of offending noise spikes in frequency domain:

Cleaned signal (black) compared to original noisy signal.

And all this takes a few lines in python+scipy+matplotlib using scipy's signal processing module:

import scipy.signal as ss
import pylab

censor0 = pylab.array([[860,875], [2590,2615],[4330,4350],[5885,5893],[6885,6893]])
censor1 = len(x_orig) - censor0[:,[1,0]]
censor = pylab.concatenate((censor0,censor1))

x_orig = data['currents'][1][1][1][0] #The data
X_orig = ss.fft(x_orig)
X_filt = pylab.array(X_orig)
for n in range(censor.shape[0]):
X_filt[censor[n,0]:censor[n,1]] = 0
x_filt = pylab.ifft(X_filt)

Install scipy via commandline on mac


(just copy the link sourceforge gives you on the downloads page)

hdiutil attach scipy-0.7.0rc2-py2.5-macosx10.5.dmg
sudo installer -pkg /Volumes/scipy-0.7.0rc2-py2.5-macosx10.5/scipy-0.7.0rc2-py2.5-macosx10.5.mpkg -target "/"

Harvard has a new, high technology ID card with your name on it

But, mommy, how do I carry it around?

Harvard decided the old card wasn't good enough and has a new one with two stripes. The new card comes with all sorts of warnings, reminding us that Harvard really made its name from its Law school.I do what a lot of other people do which is to attach it to a lanyard. Our lab has a stock of those rubber grip lanyard so that shouldn't damage this card right? Well, be that as it may, this two stripe thing isn't going to work out.Attaching the lanyard to the middle of the card does not allow proper clearance for both strips and of course attaching the lanyard on one side means you have to detach for the other side.