Wednesday, June 08, 2011

Quote of the Day

“I am the president of FIFA; you cannot question me” -- Sepp Blatter, President of the Federation of Insufferable F**tards Associations

Lisp Compiler

I am working through "An Incremental Approach to Compiler Construction". Great fun. I started reading Lisp in Small Pieces (LiSP) a while back, but this paper is a more hands-on, tutorial approach; you're able to see the fruits of your labour sooner and measure your progress better. It would have helped more if I could have gotten my hands on the extended tutorial that is supposed to accompany the paper -- it seems to have disappeared from the web. Anyway, tackling the project with only the paper for company is more challenging.

Both this paper and LiSP use Lisp dialects as the source and implementation languages. While this has a number of advantages (can't imagine using C or C++ as the implementation language *shudder*), there is a minor drawback (I say minor because the benefits far outweigh the costs; most notably a) the joy of coding in Lisp and b) the obviation of the need for a parser) -- when you're writing regular Lisp code, you are juggling with the concepts of compile-time, run-time and read-time (to be fair, I haven't felt the need to concern myself with read-times yet), whereas when you're writing a Lisp compiler in a Lisp dialect, you now have two sets of these times to contend with -- one for your compiler and the other for your generated code. Moreover, there are transformations that convert the source expressions into simplified Lisp expressions in the source dialect, which adds to the fun and merriment. You are writing Lisp code that is acted upon by Lisp code, which then takes a quoted Lisp expression and produces another quoted Lisp expression, which is then acted upon by yet another piece of Lisp code which generates the equivalent assembly... As I said, great fun.

On second thoughts, I'm not sure whether the point about two sets of times (read/compile/execute) is really valid. The complexity mentioned at the end of the previous paragraph captures the situation more accurately.

Tuesday, May 24, 2011

May 24, 2011

The two most powerful human emotions are said to be relief and love, and this was borne out with the closure of the EPL season this weekend. There is something pathetic, and at the same time endearing, about supporters going berserk because their team scores a goal that is neither the equalizer nor the winner, but is one which enables their goal difference to climb above that of their fellow languishers in the relegation zone.

Speaking of the EPL, I have persevered in the data collection process, i.e., I have the full 38 weeks' worth of match results fed into the predictor. Time for some analysis, and hopefully, insights. Stay tuned.

Thursday, May 05, 2011

May 5, 2011

Listening to Harsha Bhogle's inane and faux cheerful prattling has always been an ordeal. I finally figured out a way to handle this (other than using the mute), based on a contrived answer to the question "Why is Harsha Bhogle so happy?" The real answer is, of course, that Harsha Bhogle is so happy because he makes shitloads of money, he's a celebrity, he's got a nice rug, and so on, but that's not the road we are going to go down. What if the reason for the overdose of cheerfulness is that he's not really happy at all, but that His Bubbliness' behaviour hides a dark secret? A secret never revealed to anyone, a secret that festers in his mind every single waking second, a secret that can only be kept at bay by focussing solely on the shining happy things in life, like the way the sunlight dances off Danny Morrison's shiny pate, like the significance of the fact that the number of stumps on both sides of the pitch are wonderfully symmetrical and equal, like how quaint and innocent is the fat lady screaming her head off in the stands when the camera is on her, like how wonderful it would be to have Kiss Cams in the IPL so we can catch geriatric couples expressing their undying devotion for each other before the entire world...

Sorry, I got carried away a bit there.

Anyway, getting back to the dark secret, if you listen to Harsha Bhogle with this backstory [*] in mind, your irritation vanishes completely, to be replaced by a tender pity for the poor man, and you almost want to pull him close to your chest, a la Robin Williams and Matt Damon in Good Will Hunting and repeatedly whisper "It's not your fault" (I said 'almost' because, you know, you don't want to get too close to the rug, considering that it will be just below your nose, with Harsha Bhogle discharging copious amounts of tears on your clean new shirt).

On second thoughts, maybe it was his fault -- I can picture him as a small child saying, "Uncle, do you think stars are God's puppies? Isn't it wonderful the way they twinkle 'Woof! Woof!' all night long? Uncle, why are you looking at me that way...?"

Man, I can't wait to watch the match today and put this theory to test.

[*] Since this is a family blog, I don't want to speculate on the dark secret, but being the sadistic bastard that I am, I'll just throw in the words 'uncle' and 'broom handle'.

Tuesday, May 03, 2011

May 3, 2011

Two comments from RI that sum up the Osama Bin Laden kill:
So Public Enemy 1, on the run for 10 years, allegedly responsible for the most heinous crime on american soil, is whacked last night/early hours of the morning, DNA test taken, then dumped off a boat the same day, before I woke up. Are you f*cking kidding me?
and
I'd like to throw out this scenario:

Let's just say that both US and Pakistani intelligence have known of Osama's whereabouts for a long time.

And for SOME reason they have thought it in the best interest not to act on this information.

And this man Osama has been very ill for a long time.

One day Osama suddenly passes away.

What would the US do?

To announce the passing by natural causes of Osama?? (this would be an unsatisfactory conclusion to the US public, I'm sure)

Stage an operation and claim that he was killed in said operation?

Dispose of his body to prevent a cause of death from being established?

Pure conjecture, I know.
Natty Narwhal is the suckiest Ubuntu ever. Not just because of the new interface, but from a general stability perspective. Two days' worth of freezes and I'm back to 10.04 (for good, probably; now I know why they have LTS).

Is it just me, or does anybody else get the feeling that the IPL team owners sitting in their special thrones watching the match is the epitome of the rich/poor, elite/plebe divide and all that's wrong with our country?

Saturday, April 09, 2011

April 9, 2011

Trust The Pervie Painter to portray something as noble as Anna Hazare's anti-corruption drive in erotic terms. What's the need for a woman with a bare midriff leading the march? Also check out the glutes on the corruption monster.

Thursday, March 17, 2011

Raymond Davis freed

Raymond Davis, the CIA contractor arrested in Pakistan for murdering two people, has been freed by the payment of blood money. Two things worth mentioning:
  1. The sheer hypocrisy of the American government; on the one hand, Davis was part of the diplomatic corps (no matter that this claim was torn to shreds quickly, which probably led to the whole blood money option -- which, you have to admit, was a stroke of evil genius), and therefore enjoyed immunity against prosecution even for as heinous a crime as murder, while on the other hand:
    In 2004, Mrs. Clinton and the senior senator from New York, Charles Schumer, presented a Bill that advocated cutting foreign aid to countries who owed unpaid parking fines to the City of New York. Senator Clinton was obviously incensed by the fact that diplomats were abusing their privilege. Diplomatic immunity was never intended to allow diplomats to violate traffic laws of the host country, or for that matter, commit murders.

    She registered her discontent with diplomatic immunity and argued that it was not “acceptable for foreign diplomats and consular officials to hide behind diplomatic and consular immunity to park in illegal spaces in New York City and avoid paying parking tickets. It is my hope that this legislation will ensure that the City gets the money that it is owed.” Senators Clinton and Schumer were successful in amending the 2005 congressional Foreign Operations Bill in the Senate that froze foreign aid to countries by amounts they owed New York City in parking ticket violations and unpaid property taxes.

    ..

    In 1987, a car driven by the ambassador of Papua New Guinea, Kiatro Abisinito, hit four other cars in Washington, DC. The ambassador invoked diplomatic immunity. However, the US Attorneys prepared a criminal case against the ambassador for operating a vehicle while being intoxicated.

    Consider the case of Georgian diplomat, Gueorgui Makharadze, who in 1997 killed a 16-year old girl in a fatal traffic accident in the US. The diplomat invoked diplomatic immunity and was ready to leave when the Georgian President, Eduard Shevardnadze, ordered the diplomat to stay in the United States and face criminal charges. Mr. Makharadze was convicted by a court and served time in an American prison.

  2. The supreme irony of using Sharia Law to save Davis.

Monday, March 07, 2011

Lawyers protest against examination

From The Hindu:
Hundreds of train commuters on the Tambaram-Chennai Beach section were stranded on Sunday for over an hour as lawyers squatted on train tracks between St. Thomas Mount and Guindy Railway Stations... The agitators, who had come to the city from various parts of the state ahead of the All India Bar Examination, were protesting against it.

The nation-wide open-book objective-type qualifying test was held in English and several regional languages across the country.

<snip>

Soon after the examination began, disgruntled candidates stormed out of the exam venue, assembled on the railway tracks and roads outside.

<snip>

[The president of the Tamil Nadu Advocates Association] said that a test of this nature would expose the lack of knowledge of students from local law colleges when compared to those from schools of excellence.
Why am I not surprised? The so called local law colleges breed some of the most politicized and virulent forms of Collegius studentus in the city, specimens whose actions would make the Bus Day celebrators seem like five year old schoolgirls. Getting a strong grounding in law is the last thing on their minds, and expecting them to clear the exam is probably a bit too much. Here's what happened: they enrolled for the exam, paid the fees, and so on, and turned up at the exam center, and a cursory look at the question paper (I'm not even going to comment on the fact that it was a frigging open-book exam) was all it took to convince them that the money paid for the exam would have been better spent on, I don't know, booze and movie tickets.

Tuesday, March 01, 2011

Bus Day

The yearly ritual of hooligans college students commandeering buses and causing mayhem on the streets of Chennai is not just a law and order issue. It's a symptom of a deeper problem: the government's desire to keep the youth off the list of job seekers for another three years by getting them enrolled in worthless degree programs (not to mention building a support base for political parties). Everyone knows that these degrees lead to nothing except dead-end jobs as sales representatives and collection/verification agents zooming around recklessly on two wheelers -- on the same streets that bring bring back nostalgic memories of beating up bus drivers and stoning passersby and policemen -- but people still enroll themselves in these programs. The pittance that is charged as fees probably contributes to this, but a more important reason is the disdain for blue collar work. The same three years, if they had been spent acquiring vocational skills like plumbing, auto repair, refrigerator repair, and so on, would provide them with a solid career with decent wage potential, but no, they would rather study a bachelor's degree in economics, get barely passing grades (if at all they don't retain a set of 'arrears' in perpetuity) and go to work selling Eureka Forbes vacuum cleaners.

Tuesday, February 22, 2011

February 22, 2011

This would be funny if things weren't so serious (from Gaddafi's thug of a son's speech; italics mine):
Before we let weapons come between us, from tomorrow, in 48 hours, we will call or a new conference for new laws. We will call for new media laws, civil rights, lift the stupid punishments, we will have a constitution. Even the LEader Gaddafi (sic) said he wants a constitution. We can even have autonomous rule, with limited central govt powers. Brothers there are 200 billion dollars of projects at stake now. We will agree to all these issues immediately. We will then be able to keep our country, unlike our neighbors. We will do that without the problems of Egypt & Tunisia who are now suffering. There is no tourism there. We will have a new Libya, new flag, new anthem. Or else, be ready to start a civil war and chaos and forget oil and petrol.
What a tool.

Meanwhile, there is talk of blond women snipers in Tunisia. Scary stuff.

Via Reddit: The hero of Bahrain. Effing bastards.

Wednesday, February 02, 2011

February 2, 2011

I came across this op-ed on the revolutions sweeping across the Arab world via The Deccan Chronicle. It tries to make all the right noises and strike the right notes, but doesn't really cut it. Question for the author: any reason why Jordan, Saudi Arabia and Kuwait don't find a mention in the list of autocratic regimes? Wait, I guess I have my answer:
Hussain Abdul-Hussain is the Washington correspondent of the Kuwaiti newspaper Alrai.
Not to mention that this appears in The New York Times/IHT.

Thursday, January 20, 2011

E Coli

Man, the E Coli bacterium is one versatile thing. Not only can it serve as secondary storage in a computer:
E. coli gets a bad rap – probably due to the violent illness it induces – but a group of Chinese University students in Hong Kong have found a novel and potentially reputation-changing use for the bacteria: data storage. The team has devised a way to encrypt and store information in the DNA of bacteria to such an effective degree that they say just one gram of E. coli could store the same amount of data as 450 two-terabyte hard drives.
it can also produce oil:
In September, a privately held and highly secretive U.S. biotech company named Joule Unlimited received a patent for “a proprietary organism” – a genetically adapted E. coli bacterium – that feeds solely on carbon dioxide and excretes liquid hydrocarbons: diesel fuel, jet fuel and gasoline. This breakthrough technology, the company says, will deliver renewable supplies of liquid fossil fuel almost anywhere on Earth, in essentially unlimited quantity and at an energy-cost equivalent of $30 (U.S.) a barrel of crude oil. It will deliver, the company says, “fossil fuels on demand.”

Sunday, December 26, 2010

December 26, 2010

The Economist has an insightful article about life in Shahabpur, a village in Uttar Pradesh -- the caste dynamics, how well (or poorly) its residents are adjusting to the changing times, and so on. A positive article overall, the frequent references to the villagers' open-air toilet habits notwithstanding (what's with all the "turd"s?). A couple of choice cuts -- one an open admission of corruption by the person working in the village ration shop (What was he thinking? Anyway, he can always claim that his words were mistranslated if the authorities try to prosecute him for this):
Mr Lal, who is popularly considered to have the best job in Shahabpur, also admits to skimming off a share of the loot. He puts his pilferage at a modest 2kg of rice for every 52kg-sack he handles. “I’m only paid 900 rupees a month, so of course I have to steal!” he explains.
and the other a poignant and pathetic story of justice denied:
Two months ago, while Sarju was visiting his parents in Madhya Pradesh, his 13-year-old son Ravendra was beaten senseless by two patel neighbours. The boy had skinned and dumped a buffalo carcass, from which a dog took a meaty bone into their field. Ravendra, who carries scars from this beating, was discovered by the local skin merchant, who informed the local BSP partyman, who reported the matter to the police. They took no action. Yet this flicker of official interest in their plight represents significant progress for Sarju and his family.

Friday, December 10, 2010

December 10, 2010

A surprisingly mature response from our government, when compared to the hysteria in the States over Wikileaks (italics mine):
Some of those conversations with politicians, industrialists and others have been leaked to the media and have been reported on widely. The government has also said that while the leak should be investigated, it cannot stop the media from publishing transcripts of the conversations on the leaked tapes.

Sunday, November 21, 2010

This and that

First off, the new Airtel logo: whoever the ad agency is, they made a killing alright ('Let's take the logo we did for the mobile services company, who was it, yeah Videocon, rotate it by 90 degrees, invert it, and, just in case someone calls us on it, we'll change the colour'). Probably the easiest crore or so they've ever made.

The 2G scam is devolving into a tit for tat, with the BJP government in Karnataka being fingered in retaliation. I don't know if anybody still believes that these scams are 'discovered' just when they can be leveraged to the full. Odds are near certain that there are people from the opposite camp watching all the irregularities and filing them away for future use.

It also proves the adage that it is better to ask for forgiveness than for permission, since moves are now afoot to 'regularize' the deals -- through tap-on-the wrist penalties, no doubt -- by which the violating companies got their licenses.

Staying on the subject of mobile services, yeah, mobile number portability is just around the corner, I promise.

Update: This from Reddit.

Wednesday, November 10, 2010

Speigel interview

I don't know if the questions were really this hard hitting or if the translation is to blame (italics mine):
Schäuble: I'm not that pessimistic in this regard. Although the Irish have accumulated huge debts to bail out their banks, they are making good progress in cleaning up their economy. And I also have great respect for the Greek government's resolve. A few months ago, hardly anyone would have believed that the Greeks would manage to implement such a drastic austerity program. They're moving in the right direction now.

SPIEGEL: Conditions in Europe are not as orderly as you describe. Just two weeks ago, the European Council (the EU body in Brussels that includes the heads of state and government of the membber states) decided to introduce a new crisis mechanism for over-indebted euro nations. Are you satisfied with the result?
and
Schäuble: The Council's decisions are a great success. Only a few weeks ago, many predicted that France would never support Germany in its commitment to a European crisis mechanism. And that the French would be willing to change the European treaties to do so was seen as completely out of the question. But then Chancellor (Angela) Merkel and President (Nicolas) Sarkozy met in Deauville and achieved a historic breakthrough on both issues. It's completely in line with the approach we Germans have always supported.

SPIEGEL: You can't possibly believe what you're saying. Until recently, Germany was demanding automatic penalties for countries that violated the debt rules of the euro zone. That demand is now off the table.
Ballsy, alright. Can't imagine our fawning media (or, for that matter, the American press) doing this.

Wednesday, October 20, 2010

Predicting the English Premier League - Part 1

My current project is to come up with a predictor for the English Premier League. Football + coding in Lisp + modeling/statistics -- throw in a fat man and it's Christmas. Not to mention, if the predictor is any good, a chance to make some money as well.

The bulk of the coding is complete -- the data loading, extracting the various bits from the match statistics, and so on. It's the prediction part that's tricky, as it should be.

The idea is to identify the predictors first. This is the first cut:
  1. The home record for the home team

  2. The away record for the away team

  3. The overall records for both teams (points scored out of the maximum possible so far)

  4. The recent records for both teams (recent == last three matches)

  5. Goal difference for the teams
These variables are not strictly fully independent (goal difference and overall record, for example), but I'm going to go with them for now. The prediction takes into account only the current season's matches, though ideally it would be better if it included all the match stats available -- this would help facts like 'Team A has never beaten team B in since 1973', for example, to come through and influence the prediction.

In machine learning terms, the problem is a multiclass classification problem, with the classes being 'home team win', 'away team win' and 'draw'; I am not looking at predicting scores, only results -- I assume one can bet on (and make money with) just results.

I turned to the venerable Elements of Statistical Learning to beef up on the theory, but soon beat a hasty retreat -- if you're just looking for overviews of the different techniques/algorithms and how to implement them, this book is not for you. I next turned to Wikipedia and found it somewhat better, though the sections on statistics and machine learning are still too heavy for my liking.

Anyway, I started with a) a linear regression model, with the three classes represented as equal intervals in [0,1] (I hope this is kosher) and b) the k nearest neighbours algorithm. I wanted to implement both of these methods myself, but the linear regression seemed too much of a diversion, and I settled on using R's glm() function for this instead. KNN proved pretty easy to implement, on the other hand.

The season is only eight match-days old, so there's not a lot of training data. Both the methods' predictions are pretty abysmal (accuracy of around 30-40%), and my own predictor which just looks at the total record and recent form matches these methods' performance (not to mention the method based on random number generation that behaves like the fricken Rain Man).

The next step is to try out other methods and read up on model selection.

Speaking of using Lisp, I have sort of come to a decision with respect to programming languages: it's going to be Lisp from now on (more particularly, Common Lisp). Yeah, I know about Stroustrup's quote about being fanatic about a single language, and the warm, fuzzy feeling I get when I think about Smalltalk, but Lisp is, to paraphrase Robert Pirsig, the high country of the programming world, what with its purity and elegance, "code is data", and the way you're able to accomplish so much with so little, with code that simply flows. I had considered this question earlier, and had settled in favour of Smalltalk, but I guess you gotta do what you gotta do. Anyway, Smalltalk and Haskell are still going to be in the toolbox. Another thing in favour of Lisp is that I made the effort to get to know the Allegro CL IDE better, and have taken a liking to it -- while the shortcomings I have mentioned earlier are still there, my productivity has definitely improved because of the increased familiarity with the shortcuts and IDE features. Oh, and the fact that I took the time to fully grok the chapter on CLOS in On Lisp and had my mind blown helped, too.

Update: Part 2 is here

Saturday, September 11, 2010

RIP Bloglines

Bloglines is shutting down. It was (the future tense is a bit premature, since the service will be up till October 1) easily the best online newsreader, Google Reader notwithstanding. I have also tried out alternatives like Newsgator and Feedshow in the past, but I didn't feel as comfortable with them as with Bloglines.

One of the reasons for Ask.com shutting down the service: the supposed waning popularity of RSS as compared to Twitter and Facebook as more effective means of real-time information flow. Doesn't sound very convincing to me. Twitter and Facebook have a place -- e.g., when I want to know how Amitabh Bachchan's digestive system reacted to the new breakfast he tried yesterday (not to mention herding away from Blogger and Wordpress all the non-serious twats with short attention spans and few original things to say), but this in no way reduces the importance of RSS; reports of its death are vastly exaggerated.

Sunday, August 29, 2010

Sweden

Got back from a three-day trip to Sweden last night. It was actually a one day trip, if you consider that I was in transit for two of the three days.



Sweden is a lovely country with friendly people. The climate was good too, with summer drawing to a close. But one thing that struck me was the number of smokers I came across -- I don't know where the country ranks in terms of number of smokers per capita, and so on, but people don't seem to be bother about emphysema, cancer, and the like. No regulations on public smoking also meant that I was exposed to quite a lot of second hand smoke during my waits at the railway station. One more thing: people are permitted to take their dogs inside trains too. Good for them.



I spent the one day I was there at Lund, a charming university town more than a thousand years old. The only negative aspect (two, if you count the taxi driver whom I think charged me double the actual fare) was my missing the train to Stockholm because of mistaking the inbound train for the outbound one (in my defence, both trains arrived at the same time, and no train numbers are displayed on the departure and arrival boards), and having to rush to Copenhagen and take an alternate flight, with all the attendant worries about changing your ticket, catching your connecting flight on time, and so on.

Monday, July 19, 2010

Lisp interpreter

From an old interview with Richard Stallman, via comp.lang.lisp:
LinuxCare: Wasn't the LISP interpreter written using lex and yacc?

Stallman: No, absolutely not. There's no reason to use lex and yacc to write a LISP interpreter. The syntax is so simple you don't need it. You'd just be making things harder.

Oops, I never got the memo - a while back I wrote a Lisp interpreter using the venerable old tools. Now is as good a time as any to release the interpreter in the wild -- here it is.