Tuesday, December 27, 2005

The Christmas of code

I was mostly working through Christmas. As opposed to the popular public celebrations in Asia during this time, most of America seems to celebrate X'mas at home with family and the streets are all but deserted. The Yuletide spirit did, however, rain down a lot of programming goodies onto me.

I had been searching forever for a good math library for C++ which could provide me things like probability distribution tables, linear algebra and the like, and a couple of days ago I discovered the GNU Scientific Library (GSL). Its an extremely thorough, well-documented and well-implemented library (in terms of API) for C/C++. Its a huge surprise this doesn't turn up if you google for c++ statistical library or c++ numeric computing. It has routines for all kinds of scientific computations from Fast Fourier Transforms to Statistical Distributions to Monte Carlo Integration. An amazing find. Shouldn't they be required to tell you about such stuff in graduate school, if not as an undergraduate?

I finally made myself reasonably conversant with creating Makefiles for gcc. Creating makefiles for your project manually however is difficult since the dependencies inside your code may change and thus play havoc with incremental builds. I could not, however, make myself learn autoconf and automake - for which there's a whole book - next to which the GNU Make manual looks like a short story. I decided instead to try and write a small piece of software which would generate makefiles automatically for simple projects. I ended up writing a small bash script, which I call buildmake, which basically does what I need - takes a bunch of cpp files, resolves header file dependencies and creates a makefile for incremental builds. If you're into that sort of thing, you can check it out here.

To complete the trio, I had been frustrated in my attempts to get Mac OS X to link static libraries with programs (I know, dynamic libraries are the "in" thing, but you try and convince your cluster administrator to give you access to /usr/lib); and I finally figured out the problem which left me kicking myself and (nearly) my laptop. Turns out that for Apple's GCC, the order of linking is important: gcc -lsomelib code.c will not work, but gcc code.c -lsomelib will. Now, I had tried to export environment variables, copy libraries to all sorts of places, explored unchartered GCC flags, but who would have thought of that! And nope, Google is not your friend if you have this problem either - found this nugget of information in what has now become my favourite book, despite the cheesy name - Mac OS X Tiger for Unix geeks.

Hope you all had a merry Christmas!

Thursday, December 22, 2005

Writing a final at MIT

For the first (and likely the last) time today, I took a final exam in MIT.

There was four subjects being examined in the same examination hall, which was inside a large indoor basketball court - very much like some exam halls in NTU (Singapore). There, the similarities end.

MIT admin staff probably select the oldest tables that can still be held together for students to give exams on. I must admit though, it was a pretty large table - about the size of a small dining table for six - and there was a table and two chairs per person. The top of my table had hundreds of marks from geometrical figures to a scrawled "JAK SPAROW WUZ 'ERE" (I sure hope he didn't have an English exam). The metal lining on the side of the top of the table was held together by duct tape in some places. They make sure you'll buy the "Estd. 1861" line. And the tables rocked. Rocked, squeaked and creaked as I wrote on them - matching every stroke of my pen. Sure was a good way to mask the nervous shivering while writing the paper!

A 9 AM exam in Singapore means students get in by 8.30 and there is usually pin-drop silence by 8.45 when the papers start being distributed. At 9 AM today, most students were having breakfast on the aforementioned tables. Coffee, yoghurt and bagels were the most popular choices. One guy was sitting surfing on his laptop, the staff (lecturer and TAs) had just about come and settled down. I was already beginning to like the atmosphere (except that I was feeling hungry and had never dreamed of getting breakfast to an exam hall).

One girl walked in to the exam hall dragging one large and one medium trolley suitcase behind her. Someone asks the question that was begging to be asked, "open book exam?" Turns out it was, but the suitcases were because she was flying home about one hour after the exam.

In NTU, before every exam used to come a 15 minute speech, which in my head had earned the nickname "All Students' License Agreement". It went something like, "No paper, book, document, picture or other referral device may be brought into the exam hall unless specified under..." Out here, our lecturer looked left, looked right and yelled, "I guess you guys can start". Then, realizing her mistake, said, "Only for my subject!"

After that, of course, as with all exams, the outside world ceased to exist for a couple of hours. There was one interesting thing in the paper, though. At one point, the lecturer had been kind enough to mention, "The next two questions are very hard. Don't burn your time on them if you can't see the solution." Very kind of you, but did you imagine the rest of the paper was easy?

Wednesday, December 21, 2005

Why Macs are better than PCs

The Inquirer has an interesting argument to make:
Apple, the long forgotten subject of this article, is different. It doesn't compete against anything at all. The industrial design focus group is one turtleneck wielding man, not a watered down group of suburban housewives who fit into income category 12A, or teens in the hip-hop demographic. Nope, Apple needs to please one person.
Very true, in my opinion - and speaking from personal experience - the reason why I stay away from any PC company. If I want a Windows/Linux box, I go out, buy the components and build it myself.

Probably 70% of the market believes that all that matters in a CPU is speed; 85% of the market cares more about price than a good sound card; 90% don't know how much of a difference a good power supply can make and 99% probably don't know that hard disks come with different cache sizes. But I do. Which is why buying a PC is never easy as Dell.

Tuesday, December 20, 2005

No longer favourites

What began as mild irritation last night has grown into serious ire. The del.icio.us social bookmarking site has been down for almost 15 hours now. I rely heavily on it for managing my bookmarks. The "latest links" section on the sidebar of my blog is tied to it; but the loss of that is a minor annoyance. The major annoyance is having to search Google for sites related to research and coding that I'd bookmarked online, thinking that saving them online was the safest option.

I'm thinking of moving onto other similar services (notably Simpy), but now that this has happened, I'll have to figure out a way to keep synchronizing with a given online service regularly to keep a backup of my latest bookmarks.

On a side note, the guys at delicious claim that a "power outage" caused various problems with their service, including corruption and crashing of slave/redundant servers, and last night they decided to put everything offline to rebuild their indexes. I'm not sure if this is a process that should take as long as 15 hours, if you'd set up things correctly in the first place.

Whats more interesting is that this happened right after Yahoo! acquired del.icio.us, and I wonder if the increased load from the announcement and interest led to the current problems as opposed to pure power outages.

In any case, a lesson learned, the hard way.

[Update] Del.icio.us is back on line. For those like me who didn't bother to create a backup, Foxylicious is a Firefox extension that creates a local backup of delicious bookmarks.

Saturday, December 17, 2005

FBPNN: Toward free and fair selections

Miracles do happen. The entire Indian Parliament has come to a unanimous agreement about an issue - the dropping of former India captain Sourav Ganguly from the third test against Sri Lanka to be played at Ahmedabad starting Sunday. It is reported that the Prime Minister nearly had a heart attack on hearing that the Left Front had actually supported his call to table the issue in the Lazy Old Keepers of Solid Anarchy on Benches of Hysterical Antics (LOK SABHA).

It was decided that the Parliament shall devote every possible resource to ensure that the Board of Cricketing Chaos in India (BCCI) doesn't stoop to dirty politics and ignore its real job. To this end, the Election Commission of India shall now be reinstated as the Selection Commission of India.

Representatives of this body will now control both the voting and decision making procedures at the BCCI using new innovative methods. One recent breakthrough is a pill developed by Ranbaxy Industries which genetically modifies neurons in the brain to induce selective amnesia in the recipient. Such a pill shall be given to the top selectors and will, theoretically, ensure that they forget which state in India they come from. An anonymous source at Ranbaxy, however, was not very optimistic. "What we've proven is that this medication is extremely effective in altering the genetic structure of neuron cells in the brain." But for it to work well, he said, "it is necessary for the host organism to possess neurons in a certain minimum quantity."

The opposition leader demanded in Parliament today that the matter be raised in the UN security council and a team be sent to monitor this process to ensure free and fair selections. "The human rights of a billion people are at stake", he said. "How can we live in a world where sports teams are selected with such injustice."

Speaking at a joint press conference, Somnath Chatterjee, Pranab Mukherjee, Buddhadeb Bhattacharya (the leaders who pushed the issue through) said that they were proud that to have taken this step to ensure the safety, security and well-being of every Indian. When asked how democratic elections in India would be held now, they replied, "Lets deal with one problem at a time. Lets talk about future elections, the cold wave in North India, violence in Kashmir, defense acquisitions, rural healthcare and all those other issues later. We will never get anywhere as a nation if we don't get our priorities right."

FBPNN is the Fake But Possible News Network 2005. While we make every effort to ensure that nothing in our reports is true, the ridiculousness of human behavior remains a step ahead; and therefore the complete lack of truth in this article cannot be guaranteed.

Friday, December 16, 2005

What should you do with your life?

If you read one article on the Internet today, let it be this one. A real insight for anyone who has struggled with finding the right career, and a real eye-opener for anyone who hasn't.

[via Sherene's blog]

Thursday, December 15, 2005

Meditations by Marcus Aurelius (Translator: Gregory Hays)

Meditations is a series of philosophical notes which was written by Roman emperor Marcus Aurelius sometime in the 2nd century A.D. That the book has survived for nearly two millennia is amazing. What's even better is that the wisdom of this work - almost every question asked or answered - is still as applicable today. The book (never intended for publication) is written as a series of notes by Marcus to himself. He writes observations, gives himself advice, debates with himself, records insightful observations by others, admonishes and motivates himself.

This is by no means a cohesive or flowing work - the book almost reads like a personal blog. Marcus frequently revisits and circles around a few common identifiable themes throughout the book - the nature of the human mind, body and soul; leadership qualities; how one should react to death; the importance of work and ethics; the impermanence in nature; the insignificance of human acts and lives from a greater perspective; and so on. Yet I found this very style appealing - and very human. It shows how he struggles with himself to avoid and conquer excessive desires, anger, impatience, pride and laziness - problems that I (and many others, I presume) have had to deal with.

There are arguments put forth in the book which really made me sit up, think and take notice; and rethink my life in more ways than one. This is a sponge kind of book - the more you read it, the more you will absorb. There are easily times that you can just read one line and simply think for a good half an hour about it. My favourite line from the book - "Our worth is measured by the things we devote our effort to.".

Definitely a great read for anyone interested in philosophy (and by philosophy I mean practically analyzing people and life) and open to new ideas about living life. This book has also been greatly recommended for leaders and statesmen (Marcus Aurelius was Caesar, after all!).

A brief note: There are many translations of this book available, and some are online. The Gregory Hays translation, however, is the newest in a generation and much more readable than others I tried. He also gives an excellent (if a tad long) introduction to the times and Marcus' life to put the book into context. It was definitely worth the US$10 that I paid for it.

Monday, December 12, 2005

Proof of global warming

The Economist describes scientific arguments that confirm the trend of global warming:
The first, and most basic, is the continuation of the warming trend at the Earth’s surface that has been happening since the early 20th century... the ten years to 2004 were the warmest decade since reliable measurements began in the early 19th century.

The second result is that the Arctic, a place where any warming trend would be amplified by changes in local absorption of heat as the ice melts, does, indeed, show signs of rapid warming.

...a disagreement between the temperature trend on the ground, which appeared to be rising, and that further up in the atmosphere, which did not. Now, both are known to be rising in parallel.

...the way the world’s oceans have warmed up at different depths... match climate models’ predictions of what happens when warming is induced by greenhouse gases better than it matches predictions of the result of changes in the sun’s activity.

The fifth is the observation in reality of a predicted link between increased sea-surface temperatures and the frequency of the most intense categories of hurricane, typhoon and tropical storm.

...an observation that ocean currents in the North Atlantic are faltering in ways that computer models of the climate previously suggested would happen in response to increased temperatures.
Meanwhile, as the rest of the world attempts to battle this menace, the most polluting nation stays aloof.

Saturday, December 10, 2005

Google Earth for Mac

Finally, second-class citizens in the Google Universe (Mac users) get Google Earth. Well, depends on how you look at it... I grabbed an unofficial version off the net and ran it - and it works! Here's a screenshot...

GoogleEarthMac

It definitely is VERY beta though... if you ask it to auto-go to a site, it virtually kills the rest of the software running on your comp (to the extent that music playing in iTunes sounds broken). Looks like they really have to work on optimizing the thing. Its good to see them working on it though.

The infinite highway?

In the latest MIT hack, some dude painted highway signs on the infinite corridor of MIT yesterday. I was lucky enough to get a few shots. Couldn't divine the purpose though :)

Interstate infinity

Of course, all of this had disappeared by today :)

Friday, December 09, 2005

Dark Moon by David Gemmell

I had given up. In my mind, a good fantasy story was a project. At least three books, sometimes as many as 11. I had convinced myself that it was probably easier to fully know and enjoy a fantasy series than to read the holy texts and become a Brother of the Latvian Orthodox Church, but not by much.

Then I came up on this book. Gemmell's writing style is flowing and lucid, and the plot of the story rocks. Its about how a warrior with a split personality, a musician possessing ancient magic, a cunning general and a old but brilliant engineer come together to save the world from an invasion by an ancient species. Even though the book is only 500 pages (fantasy readers will know what I'm talking about), the plot is very well developed and definitely gets you thinking. Of course, the plot or characters are not developed with the intensity of Jordan, Salvatore or Eddings, but they get more than one book to do it. Others I know have called the ending a bit abrupt but to me it made perfect sense.

This is definitely a book you can sink into and enjoy in one straight sitting. Regular fantasy fans will definitely enjoy it, but its also a great start for people who've been kept away from fantasy because they see a story that spans eleven books and counting!

Monday, December 05, 2005

FBPNN: Climate change conference is a lot of hot air

Montreal, Canada - The Undecided Nations Organization (UNO) has been holding a climate change conference for past few days here, the prime objective being to cut emissions of greenhouse gases and basically save the planet. As the entire human race watches with hope, delegates to the UNO go about their real agenda - to maintain indecisiveness about anything to do with climate change.

The last major climate change agreement was made in Japan and termed the KYOTO (Keep Yelling Out To Others) Protocol. This piece of international legislation was a model example to of how politicians worldwide could come together and solve the world's biggest problem - how to get campaign funding while still appearing to save the environment. The agreement was designed so that every world leader could claim that his country had been unfairly dealt with in some way, curse the greed of the rest of the world and convince the people's representatives to not ratify the treaty.

The Kyoto Protocol runs out in 2012, and has already begun to show its breaking points. Members of the Exasperated Union (EU), whose populations are known to contain vast amounts of concerned scientists and environmentalists, have already been forced to create their own version of the Kyoto protocol - squabbling over which has already begun.

The Unequalled Snobs of America (USA), has, as always - been completely opposed to any sort of binding climatic agreement. Quidditch prime minister Phony Blair attempted to show the USA in a generous light by suggesting that he believed that "all major countries" would accept legally binding emissions targets. For his troubles, he was snubbed by a minion in the US administration with so little authority that he referred to himself as the "leader of the US delegation to Montreal". Unconfirmed reports from the White House chefs show that the number of bones scheduled to be thrown to the de facto 51st state are to be decreased by fifty percent for two months.

The same minion cited the by-now famous US position on climate change: "We do not believe in taking possibly dangerous economic risks based on a phenomenon for which there is so little evidence. We do not believe in speculative science, whether about global warming or evolution. If you want us to act without evidence, you should probably try and bring us an unfounded rumour about weapons of mass destruction in an oil-rich nation." He went on to defend his country's position on doing their bit for the environment. "We believe in the spirit of voluntary reduction in emissions. By liberating so many of our brothers in the Middle East from tyrant dictators, we've clearly demonstrated what the spirit of volunteering can achieve."

Of course, the USA position on this matter can easily be understood. After all, how can they be expected to help in saving a planet which, according to their Constitution, consists of 95.8% alien lifeforms?

© 2005 Fake But Possible News Network

Thursday, December 01, 2005

Confessions of a linguistic flirt

Father, forgive me, for I have sinned.

Yesterday, I just picked up a new language. My mood was bleak, and maybe I'd had a bit too much coffee to drink. R. Just R. We met in machine learning class, and at first I never imagined I'd be spending any time with R at all - I thought good old MATLAB would work just fine for whatever I needed. And you know how much I hate the "getting to know" part.

I didn't have a choice, Father. I was really in it to cash in on the inheritance. You see, R's predecessor, S had passed on a procedure that I desperately needed to validate some test cases and R and S were the only ones that had it. I chose R because you know I like the younger ones and besides, S is proprietary. However sinful I may be, you know I'd never pay for that kind of thing.

So I took her to my home directory and got started. I got to know R quite well in just one night. My deadline is due soon and I really needed some quick action. Its amazing how little you need to talk to R - something I've never experienced before. The way to speak to R is also primitive (and hedonistic), but it sure produces amazing results. One liners with R go like

reducedX<-X[1:dim(X)[1],A$which[(A$Cp==min(A$Cp[A$size==m+1])) & A$size==m+1,1:dim(X)[2]]]

but they actually incorporate five long and loopy statements that you'd have to make with any other language! I hear your disapproval, Father. I have also committed the sin of breaking the code law - I know this kind of code is not maintainable, reusable, extendible or readable. But it boosts my programmer's ego so much! And even you have to agree that the code sounds so much alike to words said in the Bibles (GNU Make Manual, 4.14).

Yes, Father, I accept. As penance, I will go and finish properly documenting my older code in C++. And I promise, R will not be more than a one project stand.