Thursday, April 04, 2013

Building a Lisp Interpreter from Scratch -- Part 2: Core Forms

(This is Part 2 of a series of posts on pLisp)

Before looking at the object model of pLisp, we turn our attention to the core forms in our interpreter. Core forms are the primitive expressions that need to be handled by the interpreter; they cannot be palmed off to the libraries, where they could be implemented in pLisp itself.

Here's a list of the core forms. Quite a few of them are there because of necessity (see above), while some of them are more for convenience, i.e, life as we know it would not end if they were absent. Also, if you want to do anything practical, say arithmetic, strings, arrays, and so on, and not end up with an interpreter that just manipulates symbols, you need things like +, -, ARRAY-GET, and ARRAY-SET (not to mention PRINT for output).

'Core' core forms QUOTE, LAMBDA, IF, SET, CALL-CC, DEFINE, CONS, EQ, ATOM, CAR, CDR
Basic real-world stuff+, -, *, /, GT, PRINT, ERROR
Intermediate real-world stuffSTRING, MAKE-ARRAY, ARRAY-GET, ARRAY-SET, SUB-ARRAY, ARRAY-LENGTH, PRINT-STRING
Advanced real-world stuffCREATE-PACKAGE, IN-PACKAGE, CREATE-IMAGE, LOAD-FOREIGN-LIBRARY, CALL-FOREIGN-FUNCTION
ConveniencePROGN, SETCAR, SETCDR, LISTP, SYMBOL-VALUE
MacrosCOMMA, COMMA-AT, BACKQUOTE, MACRO, GENSYM
DebuggingENV, BREAK, RESUME, BACKTRACE, EXPAND-MACRO
Up to elevenEVAL

A few things:

1. EQ tests for equality of content.

2. QUOTE, BACKQUOTE, COMMA and COMMA-AT are not the operators' real symbols; they are indicated so to avoid confusion with punctuation (ditto for GT, but this has more to do with my laziness in working with HTML tags).

3. PROGN can actually be implemented as a macro using a series of LAMBDAs; I just went with a native implementation. Macros involving LAMBDAs are used for implementing WHILE and LET, however (the LET macro uses the MAP function in turn):

(defmacro while (condition &rest body)
  `(((lambda (f) (set f (lambda ()
                          (if ,condition
                              (progn ,@body (f)))))) '())))

(defun map (f lst)
  (if (null lst)
      nil
    (cons (f (car lst)) (map f (cdr lst)))))

(defmacro let (specs &rest body)
  `((lambda ,(map car specs) ,@body) ,@(map cadr specs)))

4. The other comparison operators are implemented using macros. 

5. LISTP can be implemented as a macro as well, through ATOM.

6. Strings are implemented as arrays, the corresponding GET and SET are again taken care of by macros.

7. DEFUN and DEFMACRO are macros that build on LAMBDA and MACRO respectively.

8. Did I mention that macros are awesome?

Astute readers may be wondering by now what kind of a bastard Lisp they're looking at. I initially started out with Common Lisp in mind (though building pLisp as a Lisp-1), then made a detour into Scheme -- mainly for the continuations -- before I decided to persist with the veneer of CL (maybe not just the veneer; the macro system is more or less full CL; I didn't venture into Scheme syntax rules territory at all). Anyway, to a large extent, one dialect of Lisp can be made to look like another by liberal and injudicious usage of macros, so it doesn't matter that much for our purposes, I guess.

Tuesday, April 02, 2013

Building a Lisp Interpreter from Scratch -- Part 1: Syntax and Parsing

(This is Part 1 of a series of posts on pLisp)

OK, first things first. Before we can start interpreting our lisp code, we need to parse it. Conventional wisdom says that we don't need to use tools like Flex and Bison for this, since Lisp syntax is simplicity itself, and we can roll out our own parsing and scanning functionality. We're not bowing to conventional wisdom; at least I didn't, so Flex and Bison it is. I can hear somebody in the back benches muttering "so much for the 'from scratch' bit": I assure you, this is the only place where we don't roll out our own (actually there are two other pieces of functionality where we make use of third party code, but those are orthogonal to or not directly related what we're trying to achieve, so they don't count. Sue me).

The tokens we're interested in are:
  • Symbols (abc, x, ...)
  • Integers
  • Floating point numbers
  • String literals ("Hello world")
  • Character literals (#\a)
  • Left and right parentheses
  • Quote
  • Back quote
  • Comma
  • Comma-At
Inquiring minds can now mosey over to GitHub for a look at plisp.lex.

In addition to these, we also handle single- and multi-line comments, ignore white spaces and arrow key presses.

A Lisp form begins and ends with parentheses. When all the currently open parentheses are closed, it means the interpreter has something to start interpreting. Needless to say, if you pass the interpreter a parenthesis-less form, i.e., a symbol, a literal or a number constant, this will also be interpreted.

Before we feed the interpreter the form in a, well, form suitable for interpretation, we need to discern its structure. This structure is represented by a typedef (oh, by the way, now would be as good a time as any to mention this: we're doing the whole thing in C):

typedef struct expression
{
  int type;
  char *package_name;
  char *atom_value;
  int integer_value;
  float float_value;
  char char_value;
  int nof_elements;
  struct expression **elements;
} expression_t;

The type member indicates what is the type of the expression, captured in these #define's:

#define SYMBOL 1
#define LIST 2
#define INTEGER 3
#define STRING_LITERAL 4
#define CHARACTER 5
#define FLOAT 6

(Source)

The rest of the fields store the value of the expression, depending on its type (e.g. atom_value will be for the case where the expression is a symbol, char_value for when it is a single character, and so on). The elements member stores the elements in case the expression is a list. An added wrinkle is the package name, to handle cases where the symbol name is preceded by the package name, as in 'math:power').

The conversion of the token stream into an expression_t structure is done in plisp.y, the scanner. The distilled logic is as below:

expression: atom | list;
atom: integer | float | string_literal | character_literal | symbol;
list: expressions_in_parens | quoted_expression | backquoted_expression | comma_expression | comma_at_expression;
expressions_in_parens: left_paren expressions right_parens;
quoted_expression: quote expression;
backquoted_expression: backquote expression;
comma_expression: comma expression;
comma_at_expression: comma_at expression;
expressions: /* empty */ | expressions expression;

On a side note, by suitable manipulation of the yyin variable, we can feed the interpreter input from stdin, or from a file of our choosing (e.g. to load the pLisp library).

Once yyparse() has had its way with the input, the interpreter is all set to begin. But we'll delay things a bit more, for a very good reason: in Lisp, code and data are the same (the fancy word for this is homoiconicity), so we get a lot of bang for our buck if we convert an expression_t object to a pLisp object (denoted by OBJECT_PTR) before giving the interpreter the go-ahead. The pLisp object model is the subject of another post.

Building a Lisp Interpreter from Scratch


pLisp now has continuations. It took a lot of effort, slogging through the relevant literature, and a significant rewrite of the code, but it's finally done (I have not updated the GitHub repository yet; plan to do it shortly [Update: Done]).

Before proceeding further with other features, I thought I'd do a series of how-to posts on pLisp. These will serve as a sort of de facto documentation of pLisp (beats the 'You want documentation? Go to The Source, my friend' approach), and also provide pointers to folks looking to do their own projects (there's plenty of material out there on building/embedding an interpreter within a Lisp implementation; in my opinion, while this is good, it's a cop-out; such interpreters are meant mainly for illustrating concepts, trade-offs in design choices, etc. We still don't pierce the veil, so to speak. Not to mention the obvious hit in performance).

Here's a tentative list of posts:
Stay tuned.

Tuesday, March 26, 2013

March 26, 2013

"I personally believe that Hugo Chávez was murdered by the United States"
-- William Blum

I have been meaning to mention this earlier, but got around to it only now: kudos to William Blum for stating something that is on every progressive's mind but not voiced out loud for fear of being accused of tin-foil hattery.  From the referenced essay:
Chávez said he had received words of warning from Fidel Castro, himself the target of hundreds of failed and often bizarre CIA assassination plots. “Fidel always told me: ‘Chávez take care. These people have developed technology. You are very careless. Take care what you eat, what they give you to eat … a little needle and they inject you with I don’t know what.”
 Six words for doubters: Confessions of an Economic Hit Man.

Sunday, March 24, 2013

March 24, 2013

After seeing that their whining full page ads (grammatical errors, misplaced commas and extra-liberal application of exclamation marks and all -- couldn't such a wealthy industrial house afford a decent copywriter?) failed to elicit any support or sympathy for their cause, the Sahara parivar have resorted to more blatant means: flaunting their political connections by publicizing (through full-page ads, natch) pictures of the movers and shakers who attended the rice-eating ceremony of one of their scions (didn't know the rich and the famous celebrated something as mundane -- and yet out of reach for millions of Indians -- as eating rice; maybe that's why they're rich).

Saturday, March 23, 2013

March 23, 2013

From a column (via Deccan Chronicle) about the Sri Lankan issue:
What’s clear is that India’s ability to influence the course of events in the island nation is negligible. Sources close to the powerful first family have told this writer that they see India as an “irritating gnat that can be smacked away at will”.
This is exactly what's wrong with journalism, something Markandey Katju can train his guns on: quotes -- inflammatory ones, at that -- attributed to anonymous sources that only the journalist is privy to. Do we have any way to distinguish genuine quotes from those that are simply pulled out of journalists' asses, journalists serving interests other than that of the public? We don't, so just stop using such quotes. We may lose the insights that genuine quotes provide, but this is a small price to pay to ensure the integrity of the press. On a side note, the incendiary nature of the quote makes it all the more likely that revealing it to the public is meant to elicit reckless action, either from the government or from jingoistic elements outside.

The CBI inquiry scandal throws up an interesting thought: were the raids/investigations initiated by somebody against the UPA? Maybe somebody with leanings towards the BJP? What better way to make the Congress tie itself into knots, trying simultaneously to condemn the action (and protect its erstwhile allies) and to show that it doesn't pull the CBI's strings? Our politicians' actions are a conspiracy theorist's delight, aren't they?

Monday, March 18, 2013

March 18, 2013

The Cyprus bailout fiasco is being described as " the single most inexplicably irresponsible decision in banking supervision in the advanced world since the 1930s.":
[EU officials who engineered this weekend's Cyprus bank bailout] have weakened – perhaps catastrophically – the principal pillar supporting modern banking. This pillar is deposit insurance. Ordinary savers who had received a solemn assurance that deposits up to 100,000 euros were safe are now being asked to take a haircut. This raises questions about deposit insurance throughout the EU and invites runs on banks not only in the most “financially-challenged” nations such as Greece and Spain but even in Italy and France.
Methinks life will go on. They said the same thing about the sanctity of contracts and the credit markets when holders of Greek bonds were made to take haircuts; the haircuts were 'voluntary' to avoid triggering credit default swap payments.

Welcome to Flight Club, where the only rule is "We make up the rules as we go".

Wednesday, March 13, 2013

March 13, 2013

Leaving aside the emotions, jingoism and nationalism on both sides, what could be a possible solution to the Italian Job controversy? Well, here's a part-pragmatic, part-diplomatic and part-mafioso proposal that our MEA boys can reach out to the Italian government with:
  1. Send the two marines back to India (no, hear us out, seriously).

  2. We will pull strings here to make sure that they will return to Italy for good, within two months. You can trust us on this -- after all, we're talking about a sovereign country here, an upstanding member of the international community that honours its commitments... oh wait, never mind. On to the next point, anyway.

  3. As escrow/guarantee, we will depute one of our respected diplomats -- maybe even the head honcho himself -- to spend the two months in Rome, all expenses paid by us, of course. He/She will return to India only when the marines make it back to Italy. Heck, the same flight can do both legs of the journey, with the personnel exchange being witnessed on the tarmac by a designated and disinterested third party. We know we're preaching to the choir, but still: if you have any clarifications, please refer to The Godfather for modalities and variations on the theme.

  4. Coming to how we will pull off #2 above, the case against the two marines is not watertight, anyway. If there's still any uncertainty, leave it to us; we have handled such things before.

  5. To sweeten the deal, and to pacify the natives, please deposit a sum of Rs 20 crores as compensation to the victims' families. The Rs 6 crore bank guarantee can be adjusted against this amount, of course.

  6. If you would like to discuss this further, or propose changes, discuss logistics, etc., please don't hesitate to either call us at our toll-free number 1-800-WE-MAKE-DEALS or email us at mea@top-secret.gov.in. Thank you.

Tuesday, February 12, 2013

February 12, 2013

When we think of our government, what comes to mind is the avuncular and benign face of Manmohan Singh, who means well but is way out of his depth; Sonia Gandhi, who has experienced personal tragedies because of her family's involvement in politics, and who still perseveres in serving the country; venal politicians and bureaucrats, who engage in petty machinations in their quest for power and pelf.

But once in a while, something happens that changes our perspective; we see the government for what it actually is (whether this happens consciously or is, for want of better words, an epiphenomenon, or more accurately, an example of swarm 'intelligence'): a scheming sociopath. A government that keeps the rejection of a mercy petition secret and sets a date for the execution. A government that sends the intimation to the death row prisoner's family by Speed Post one day before the planned execution when it knows that Speed Post only guarantees that articles will be delivered anywhere in India in four to six days. A government that is so paranoid about its survival prospects that it is willing to end a person's life just to send a message to the voters that it is as good as the opposition in some nebulous metric like "Strong/Firm on terror". A government that pretends to be afraid of the backlash that would supposedly arise if news of the planned execution was released, but is strong enough and brave enough to face the backlash -- through curfews, preventive/house arrests and tear gas and lathi charges -- when the execution has been carried out. A government that is engulfed in white-hot rage because somebody dared to attack it in its own den, its seat of power.

Irrespective of how one feels about Afzal Guru's guilt and whether capital punishment should be abolished or not, one thing we don't want our government to be is a relentless, vengeful, all-powerful serial killer who also keeps stealing stuff, while occasionally shooting himself in the foot accidentally.

On a side note, Praveen Swami's demolishing of Arundathi Roy's melodramatic piece on the execution is a must-read, if only to avoid being misled by her half-truths and general BS (I know, I've said nice things about her in the past, so bite me).

Friday, January 18, 2013

January 18, 2012

Well, it looks like beheadings by both sides are pretty common:
Despicable as the alleged beheading of Indian soldiers by the Pak­i­s­t­anis was that led to the present military crisis, the fact is that both armies are or have been in it to­g­e­ther. India’s ace TV anchor Barkha Dutt will do the country and the community of journalists a great service by speaking up at this time. She gave the following eyewitness account of the Kargil War to more or less affirm a tradition of beheading the enemy that unfortunately seems to exist on both sides and pe­r­haps straddles other countries too. And I quote from writer-acti­vi­st Shuddhabrata Sengupta’s web­po­st for the piece Barkha Dutt published in Himal magazine in June 2001. 
“I had to look three times to make sure I was seeing right. Bal­a­nced on one knee, in a tiny alley behind the Army’s administrative offices, I was peering through a hole in a corrugated tin sheet. At first glance, all I could see were some leaves. I looked harder and amidst all the green, there was a hint of black — it looked like a moustache. ‘Look again,’ said the Army Colonel, in a tone that betrayed suppressed excitement. This time, I finally saw. It was a head, the disembodied face of a slain soldier nailed on to a tree. ‘The boys got it as a gift for the brigade,’ said the Colonel, softly, but proudly.”

Friday, January 11, 2013

January 11, 2013

If you gaze into the abyss, does the abyss also gaze into you even if you are an Indian? Is my country always right? If you are a 70-year-old grandmother sneaking into PoK, and nobody knows that you've sneaked in, are you an Azad Kashmiri, and is the ceasefire broken? Does it matter if Reshma Bi ran across the Line of Control 16 months ago or six weeks ago? Can we extradite her to India and request her to give a series of expert lectures on guerrilla warfare to our OTA cadets? Is constructing watchtowers a violation of the ceasefire? Even if the watchtowers are facing inwards? Is intimation through a public address system the only way to let somebody know that they're violating the ceasefire? Who pays the bill for the hot line between the GOCs? Is beheading enemy soldiers so common as to warrant something like "...both sides have engaged in cross border raids, which have on occasion included beheadings", almost as if one were referring to an exchange of sweets on Independence Day ("You must try these rasgollas... Oh, almost forgot..." <chop>)? What is a controlled retaliation? Does Praveen Swami have an inside track with respect to the Indian military establishment? Speaking of the establishment, what are the covert actions that B Raman is referring to as retaliation for the Pakistani action? Who are our prospective allies in Pakistan? Does Sarabjit Singh know what these covert actions are? If he does, what does he think of them? What does Afzal Guru think of all this? What about Rabbani Khar? Ban Ki Moon?

(Apologies to Crispin Glover)

Thursday, December 20, 2012

December 20, 2012

Shame on you, Saina:
Cocking a snook at the Badminton Association of India, a defiant Saina Nehwal chose to withdraw when holding two match-points against Russian Ksenia Polikarpova in the first round of the $120,000 Syed Modi Grand Prix Gold badminton championship here.
The World No. 3 cited a knee-injury that had troubled her from this year’s Denmark Open as the reason for her decision to withdraw when leading 21-17, 20-18 against a rival ranked 165th.
“With many important tournaments lined up next month, I decided not to aggravate the injury,” said a smiling Saina after she waved to the disappointed crowd for cheering her all the way in the 29-minute encounter.
and
“Throughout the year, the BAI does everything that Saina wants. Government allows Saina economy class (airfare) but BAI helps her travel First Class by paying the difference in fare. In return, BAI wants her to play in a couple of events in the country. But that is not happening,” said a senior BAI official on condition of anonymity.
and
By the end of the day, a ‘chastened’ BAI must have realised that it is better to accept a firm ‘no’ than a reluctant ‘yes’ from Saina. As one of the BAI official put it, “Sadly, the truth is, the Indian badminton needs Saina Nehwal more than Saina needing Indian badminton.” 
Methinks somebody's shoes are getting too small for them. To be fair, it could be advice from questionable sources that is causing this kind of behaviour.

Thursday, December 13, 2012

December 13, 2012

It may be possible to test whether we're living in a simulation.

An earlier article that says there may be a 20% chance that we do.

Via Rigorous Intuition, a mind-blowing argument.

Let's see:
  1. This explains the Big Bang. Things started when the simulator program was kicked off.
  2. Things are discrete in the quantum world because the simulation is, by nature, discrete -- whether it's event-driven or time-stepped.
  3. Non-local connections are explained as well -- the 'master controller' is the CPU running the simulation, and it has access to (and is able to maintain) all the simulation objects and their dependencies, irrespective of where they are in the simulated world.
  4. The usual paradoxes like wave-particle duality, the uncertainty principle, and so on are explained by the analogy of mathematical formulas and 'lazy initialization'.
  5. Karma and synchronicity? Global state/memory/logic in the simulator program.
  6. God is the entity running the simulation.
Of course, this still doesn't explain things like ultimate cause (is our God also a simulated entity? How many levels does this go?).

Related: good stuff from Reddit.

Tuesday, December 11, 2012

December 11, 2012

fool  

/fo͞ol/
Noun
A person who acts unwisely or imprudently; a silly person: "what a fool I was to do this".

id·i·ot  

/ˈidēət/
Noun
  1. A stupid person.
  2. A mentally handicapped person.
Effing idiots. Or are they fools? Now I'm confused.
Context: this and this.

Tuesday, December 04, 2012

December 4, 2012

Awfully decent of the Chinese, preferring to pay for stuff rather than pillaging and plundering the to-be-annexed Indian territory:
In 1962, for example, Deak warned the CIA that China was planning to invade India after his company’s Hong Kong branch was swamped with Chinese orders for Indian rupees intended for advance soldiers.

Wednesday, November 28, 2012

November 28, 2012

Sachin Tendulkar:
When I feel it is time, I will take a call. It is going to be a tough call nevertheless. It is going to be tough because this is what I have been doing all my life. It is going to be difficult to suddenly hang up my boots one day.
I have the highest regard for Tendulkar, but somebody please give the man a copy of Who Moved My Cheese?

Reason #1876 why I'm glad I didn't take the civil services exam -- questions like this:
Domestic resource mobilisation, though central to the process of Indian economic growth, is characterized by several constraints. Explain in ten words.
I made up the "ten words" bit, but I think I would have shown myself the door because my ten words would have been roughly divided as below:
  • Babus
  • Netas
  • Corruption
  • Nexus
  • Six words unprintable in a family blog

Monday, November 26, 2012

November 26, 2012

One little-noticed wrinkle in the recent failed no-confidence motion is that it serves as 'inoculation': no other such motions can be brought up against the government for the next six months. Watch out for attempts to push through more audacious policies/legislation, without any worries about the government falling because of such attempts.

Friday, November 23, 2012

November 23, 2012

Even when victorious, let there be no joy,
    For such joy leads to contentment with slaughter.
Those who are content with slaughter
    Cannot find fulfillment in the world.
-- Tao Te Ching

Something entirely lost on these joyous folks. Contrast this with the reaction of Major Unnikrishnan's father.

I think I've said this before, but will say it again: the best way to decide whether somebody gets the death penalty is the Arab/Shariah custom of putting the question to the victim's family. Needless to say, this is not a pardon, but only to decide whether the murderer is put to death or spends the rest of his life (life; not 14 years commuted to 10 on account of Gandhi Jayanti, good conduct, and so on) in prison.

Wednesday, November 21, 2012

November 21, 2012

Yeah, that about sums it up:
Let's clear this up again. The ECB is going to buy bonds of bankrupt banks just so that the banks can buy more bonds from bankrupt governments. Meanwhile, just to prop this up the ESM will borrow money from bankrupt governments to buy the very bonds of those bankrupt governments.
Another interesting tidbit from the report: the demographics are so bad in Japan that they actually have adult diaper fashion shows.

Wednesday, November 14, 2012

Quote of the day

[H]aving the career of the beloved CIA Director and the commanding general in Afghanistan instantly destroyed due to highly invasive and unwarranted electronic surveillance is almost enough to make one believe not only that there is a god, but that he is an ardent civil libertarian.
-- Glenn Greenwald

Tuesday, November 06, 2012

Predicting the English Premier League - Part 3

Having just completed the machine learning course in Coursera, time to put the knowledge to good use. Neural networks seem to be the most promising among the classification algorithms (logistic regression and SVMs being the others covered in the course) -- I did do bit of mucking around with logistic regression, but the results were singularly disappointing.

Since we're dealing with neural networks, no need to be picky with what features to use; in addition to the ten parameters considered the last time, let's throw in as many additional ones that we can think of, and let the algorithm sort it out. Here are the features forming the input layer (the features are normalized -- something I didn't do the last time):
  1. Home record of home team
  2. Away record of away team
  3. Record of home team
  4. Record of away team
  5. Record of home team in last three games
  6. Record of away team in last three games
  7. Record of home team in last five games
  8. Record of away team in last five games
  9. Record of home team in last seven games
  10. Record of away team in last seven games
  11. Record of home team in last three home games
  12. Record of away team in last three away games
  13. Record of home team in last five home games
  14. Record of away team in last five away games
  15. Record of home team in last seven home games
  16. Record of away team in last seven away games
  17. Total goals scored by home team
  18. Total goals scored against home team
  19. Total goals scored by away team
  20. Total goals scored against away team
  21. Position of home team in points table
  22. Position of away team in points table
We use one hidden layer with five activation units -- could've used more hidden layers, but the code I wrote for the course assignments is for a single hidden layer, and I'm too lazy to bother to make the code more general. Not to mention that the efficacy of using more layers is moot.

The examples are a total of 560 matches from the 2010-11 and 2011-12 seasons (we ignore the first few weeks of each season to a) get things to settle down and b) avoid division-by-zero errors for some of the features (e.g. when we're considering the first match a team plays in the season).

350 matches are used as the training set and 30%, i.e. 105, from the remainder form the cross validation set.

After a lot of number crunching, the results are not too good, at least not yet. It looks like I'll be needing more data (as indicated by the results from the learning curve plots). A lambda value of 0.16 or 0.32 seems to be the most promising.


The next step is to get the results for the 2009-10 season -- and earlier if required. More grunt work. Stay tuned.

Update: Well, I went all out and got the results for three seasons -- 2007-08, 2008-09 and 2009-10 -- but no cigar; the prediction accuracy refuses to go above ~50%, whatever values of lambda and feature list I consider (I added two more features to the above list: total games played so far by both teams). It might be possible to squeeze out a bit more by running a genetic algorithm and figuring out the best lambda value and features, but I don't think the effort is worth it. Question: what is the minimal prediction accuracy required to get a 20% return on bets over the long-term, e.g., over an entire season?

Friday, November 02, 2012

Question of the day

"After hundreds of drone strikes, how could the United States possibly still be working its way through a 'top 20' list?"
-- Gen. Ashfaq Parvez Kayani to Adm. Mike Mullen

Sunday, October 28, 2012

October 28, 2012

Imagine a slightly larger-than-life statue of a naked boy-man wearing only the remnants of a pair of jeans and a hat that looks like a flak helmet, his foot resting on the severed, blood-dripping head of a Roman legionary.

Oh wait, you don't have imagine it. Here's an actual picture:


Picture courtesy of the Rock Garden, Malampuzha, Kerala. I'm too lazy to google for it, but I bet there is a back story involving a twisted and diseased mind that spawned the whole house of horrors (the above picture is only a sample; there's a lot more cringe-inducing crap in my vacation pictures folder). 

Saturday, September 29, 2012

September 29, 2012

Comment of the decade (on Business Insider's 1068th Marissa Mayer story):

Is Farrukh Dhondy aware of Nafeez Ahmed's post about Abu Hamza's links with MI6? The sad part is that the visibility such an op-ed column gets is orders of magnitude greater than what Nafeez Ahmed's writing does.

Thursday, September 20, 2012

September 20, 2012

The Hindu on allowing FDI in retail:
Even within the retail trade, the government’s claim that FDI is good for the nation is difficult to defend. The success of large retail cannot be based only on the expansion of the retail space, but requires acquiring a share of the existing space occupied by small retailers. NSSO data for 2009-10 indicate that the occupational category consisting largely of the wholesale and retail trade employed 44 million Indians. The displacement of a substantial number of these workers is inevitable. Since the economies of scale and scope that size delivers in organised retailing are expected to reduce costs by raising labour productivity, the expansion of large retail will not compensate for this employment loss.
Which reminds me of this comment by 'StarmanSkye' at RI:
 I guess the New Politics of neo-Conservative values which we see in the unprecedented official government protection that encourages the power & privilege of the financial criminal class suggests a kind of logical argument can be made that the trend from "Its the duty of every American industry, company, corporation, business person and citizen to maximize their profits by any *legal* means allowed, including evading, deflecting, eliminating or deferring their tax liability" leads to:
"Its the duty of every worker to inhibit productivity by any and all means *legally* allowed so as to stimulate maximal employment of the work force".
Game, set and match.

Thursday, September 13, 2012

September 13, 2012

Rotten meat? More like local traders being undercut by low-cost 'imports' from neighbouring states protecting their turf by siccing the authorities on the pretext of hygiene.

Reminds me of restaurant owners suddenly developing concern for their patrons and trying to protect them from the unhygienic food in roadside eateries some time back.

Thursday, September 06, 2012

September 6, 2012

Well, Mish finally addressed the real estate scenario in India and, as I expected, didn't have nice things to say about it.

There are times when you hear so many good things about something -- be it a book, a movie, or a song -- and when you finally get around to reading/watching/listening-to it, the experience is quite underwhelming because of the raised and unrealistic expectations. Cryptonomicon falls into this category for me. While portions of it were good reading (especially the crypto anarchy bits), overall the book simply rambles on and on for 900+ pages. The fact that I enjoyed Bruce Schneier's appendix on the Solitaire crypto system more than at least 50% of the book says a lot.

Monday, August 13, 2012

August 13, 2012

The Hindu on the trial of Gu Kailai:
However, a detailed account of the prosecutor’s case that emerged late last week has provided rare insights into the dealings of one of China’s most popular politicians, who was a key figure in the 25-member Politburo before his suspension in April. Part of the account was released by the official Xinhua news agency, while other details came from an Anhui student who sat in on the court’s proceedings. His account was independently verified by a lawyer who was present in the courtroom.
Read that again carefully. They're not talking about the lack of transparency regarding the government in China -- contracts, policies, and so on; they're talking about the lengths one has to go to to even know how the trial is being conducted. It's not like state secrets would be laid bare if the proceedings were not held in camera (so to speak); this is just a plain old murder case. But again, this is China we're talking about. There is a good chance that a body double would serve Ms Gu's sentence out.

On a related note, we're once again reminded of the questionable non-merit-based admission policies of Ivy League universities.

Friday, August 10, 2012

August 10,2012

Nicholas Kristof (emphasis mine):
US President Barack Obama's finest moments in foreign policy, like the Osama bin Laden raid or the Libya intervention
Stopped reading right there. Mr Kristof, welcome to the kill file. We have some delightful companions for you there.

Thursday, August 09, 2012

Monday, July 30, 2012

July 30, 2012

The Hindu's policy regarding online comments:
  1. Comments will be moderated
  2. Comments that are abusive, personal, incendiary or irrelevant cannot be published.
  3. Please write complete sentences. Do not type comments in all capital letters, or in all lower case letters, or using abbreviated text. (example: u cannot substitute for you, d is not 'the', n is not 'and').
  4. We may remove hyperlinks within comments.
  5. Please use a genuine email ID and provide your name, to avoid rejection.
I can see where they're coming from with respect to #3 -- they don't want their pages to be polluted by the Neanderthals hanging out at rediff.com -- and find their grammar nazi behaviour naive and endearing, but I still think their backsides need a strong and liberal application of the cluestick.

Tuesday, July 10, 2012

July 10, 2012

Quote of the day: "Next, we'll probably hear that Lloyd Blankfein over at Goldman Sachs has been tinkering with the rotation of the earth in order to gain a few micro-milliseconds of advantage in his firm's high frequency trading rackets."
-- James Howard Kunstler

There has been a lot of commentary about the confusion regarding the name of the Indian prisoner released from Pakistan. In particular, somebody mentioned that the returning (pardoned) prisoner should keep his trap shut and not blab about being a spy for India, as this makes the task of negotiating the release of other such people all the more difficult. Can't really fault this logic, but I have more fundamental issues: why are we sending folks into enemy territory to engage in such acts (not to mention bombings, if the allegations against Sarabjit Singh have any merit)? This may be a naive view of how foreign policy is conducted, but ahem, we are different, aren't we? Ours is the land of Gandhi and the Buddha -- we would never do these things, things that only other countries do, would we? In my rule book, if a fair and impartial trial (best conducted by a disinterested third country like, say, Iceland (I wanted to say Norway, but some folks may remonstrate against this since Norway is -- was? -- involved in mediation efforts in Sri Lanka and may not fully qualify as a disinterested party)) shows that Sarabjit did commit these things he's accused of, he should hang. Period. No 'My country, right or wrong', 'But he was only doing his patriotic bit for the country' business. Patriotism is taking a gun and defending your border against an enemy, not terrorism or other nefarious activities that would get you peremptorily -- and legally, I think -- executed in wartime. One positive fallout of such an action would be that we can mete out the deserved justice to Kasab as well, instead of waiting on him hand and foot in prison. This will also open the eyes of gullible folks who get railroaded into doing James Bond duty for the country.

Friday, June 15, 2012

Quote of the day

"... at times, it was like watching a practice game involving ten green traffic cones as Spain cut Ireland apart.
-- On Ireland's exit from Euro 2012

Ouch.

Wednesday, June 13, 2012

The JEE Controversy

Some thoughts on the JEE controversy (disclosure: I received my bachelor's degree from IIT Madras):
  1. There is merit to the argument that IITs have not fulfilled their mission of making India a science and technology powerhouse. There is a big disconnect between the quality of the undergraduate students (leaving aside the dilution of the standards in recent years) and the quality of the engineering and R&D output produced. Also, a very small fraction of the undergrads take up careers related to their majors (I too am guilty of this). However, this argument is orthogonal to the problem of determining the best way to admit students to engineering colleges in India.

  2. Having each IIT conduct its own entrance examination is not the answer. Subjecting a high school student to, say, 15 entrance examinations borders on child abuse.

  3. The UPA government seems hell-bent on wreaking havoc with the IITs. First it was the increase in the number of IITs, now this. There is a strong lobby of bureaucrats and other elites who want their wards to go to prestigious institutions like the IITs, but are stymied by pesky things like the JEE. The more enterprising of them wangle admissions from top American universities using their connections -- don't even get me started on the backdoor alumni recommendation route that gets somebody like Bush Junior into Yale; god forbid the day such a thing becomes reality in India. The reservation for other backward classes is also an attempt by the elites in this direction. If you can't beat 'em, dilute 'em.

  4. One of the charter goals of the alumni associations should be to protect the IIT brand. I have not been recently involved in the goings-on of the IITM alumni association, so I don't know if this is being taken up. If things continue to progress at this rate, there may come a time when degrees from the IITs are accorded the same respect as those from some of the more infamous colleges in Chennai (one would be surprised to know of the esteem those degrees were held in two or three generations ago).

Friday, June 01, 2012

June 1, 2012

Well, it took three years for my prediction to come true. "We cannot wait forever" -- indeed, how magnanimous of you.

Tuesday, May 29, 2012

May 29, 2012

IPL 5 is over. While the matches provided a lot of excitement, I would be more convinced about the genuineness of the whole thing if someone did an analysis of the numbers and proved that there were no match/spot fixing shenanigans. One thing that comes to mind is no balls: some statistical significance studies on the number of no balls bowled versus the bowlers and at what stage in the match they were bowled, was it a touch-and-go decision or was it blatant overstepping, and so on.

Having recently witnessed the scenes of celebration at the Etihad Stadium, the contrast with the IPL final could not have been starker. The inordinate focus on the owner -- who might as well have worn a clown costume, by the way -- instead of the players who made it happen, the lack of genuine grassroots support (Usha "Look at me, I have a whistle in my mouth" Uthup, Juhi Chawla and other assorted celebrities trying to warm themselves in the spotlights do not count), the contrived joy and enthusiasm of the players who did not figure in the playing eleven -- there is a difference between waiting 44 years for a trophy as compared to five.

Monday, May 14, 2012

May 14, 2012

"Some people believe football is a matter of life and death, I am very disappointed with that attitude. I can assure you it is much, much more important than that"
-- Bill Shankly

You don't care about the quality of the passing, the skills on display, or the individual brilliance. The only thing that matters is that the ball crosses the line between the goalposts, and twice at that. The tears that slowly begin to roll when it looks like it's all over, the look of despair that turns into joy (and vice versa for the United fans -- a bonus if you're a staunch anybody-but-United guy like me), Aguero's shirtless run towards the corner flag, Joey Hart terminating the interview on account of becoming overwhelmed by the situation, the commentator's schadenfreude ("How will the fans face somebody in a red shirt this evening? How will they have the moral fiber to get up tomorrow morning and go to work...?" Fuck you.) turning into astonishment.

The Beautiful Game? No, but this is football.

On a personal note, I'm not even a City fan, but the euphoria I felt when they scored the winner was comparable to what I felt when Del Piero scored in the 2006 World Cup semi-final.

Oh, and by the way, I stubbed my toe quite hard when I jumped up from the couch to celebrate. Still hurts, but totally worth it.

Thursday, May 10, 2012

May 10, 2012

The Times of India might as well rechristen themselves as The Pimps of India.

There is a reason they sell the paper for less than 25 bucks a month: it isn't their readers they make their money from.

Wednesday, May 09, 2012

May 9, 2012

Yesteryear's heartthrob
Is it trademark shake of head?
Is it Parkinson's?


The Havells ad featuring Rajesh Khanna has to be the most depressing thing I've seen on TV for some time.

Monday, April 30, 2012

April 30, 2012

This is probably a hoax, but intriguing all the same.

Staying on the subject of pop culture and hip hop, have you ever watched a movie that was so bad that it went around the world and became good when it came back? Something along the lines of music that gets voted the worst and climbs the chart because of this? Well, I watched such a move yesterday (Torque, in case anyone's interested). Bad (or non-existent, since we're talking about Ice-Cube here) acting, cliched dialogue (case in point: "Don't pick on girls", says the resident bimbo after boinking a bad guy -- my brain cells are still tingling at this repartee), you name it, this movie had it. My only regret is that I couldn't watch it till the end. Just kidding. Maybe not.

Thursday, March 15, 2012

March 15, 2012

I have said this before, but my comment bears repetition in light of today's cartoons. Why do the folks at The Hindu give pride of place (i.e., the op-ed page) to insipid crap like this:


when they have a much better talent on their payrolls, producing stuff like this, stuff which has to languish in the inner pages:

Tuesday, February 21, 2012

Quote of the day

"I am getting out in funny way, like flicking to point"
-- Virender Sehwag on his recent form

Don't know whether to laugh or to cry.

Thursday, February 02, 2012

The Goonda Regiment

The men in uniform are at it again, demonstrating that pesky little things like respect for the rule of law don't apply to them. A couple of questions for them: didn't you swear to protect the country -- which, last time I checked, includes its citizens -- when you signed up in the army? Does beating up innocent civilians who had nothing to do with your tiff with the police jibe with the oath you took? The excuse that the police behaved in an abusive manner does not cut it: two wrongs do not make a right. The particularly galling thing is that the violence was perpetrated not by jawans, but by fricking captains, who are supposed to set an example for the men they command (Update: it looks it was jawans). But then again, I guess this is in keeping with the state of things when you have a Chief of Staff hell-bent on clinging on to his position at any cost.

Tuesday, January 31, 2012

Where are we going?

(Warning: I don't know where I'm going with this post; I guess it ends when it ends)

I used to read Clusterfuck Nation and Club Orlov on and off in the past, whenever somebody in one of my regular haunts made a mention of one of their more noteworthy posts. I subscribed to their RSS feeds a while back (RSS is just like Twitter, except there is no 140 character restriction, and the content is slightly more meaningful than updates about celebrities' breakfasts *snark mode off*). A regular dose of doom and gloom stuff (maybe I should include Mish Shedlock's blog here as well), while fulfilling its disaster porn role, doesn't result in any constructive or positive outcome; for someone in India, being exposed everyday to the 'things have never been better, buy your dream car, your dream house, take your dream vacation, and while you're doing all this, tweet about it to your 1579 Facebook friends in real time using your ultra slim shiny smartphone' hard sell, this seems a world away, but is it really so? What would happen to us if the eurozone crisis finally comes to a head and countries start defaulting? If the price of oil goes through the roof because the USS Enterprise is torpedoed in the Straits of Hormuz? If there is a global ban on travel because of the next outbreak of bird/swine/monkey/rhino flu that came about because some scientist in a lab somewhere was wondering 'Gee, what would happen if I take this test tube of monkey piss and slightly shake it above the head of this disgruntled pigeon who has been looking askance at me since yesterday morning?'? What if the Indian real estate bubble finally bursts? What if the Sensex tanks? What if our exports took a nosedive, taking along with them the aspirations of the newly rich middle class? What if we run out of drinking water? Electricity?

The answer to these questions is pretty simple, really: a lot of people will be screwed, some more so than others. But how many of these scenarios will actually play out within the next year or so (ignoring the bits about electricity and water; I think we're safe on both fronts for another decade)?

One can go about analyzing these issues in a rational manner and doing our research, but this is not really needed; we can figure things out if we keep in mind certain things:

1. If bad things are coming down the pike, they will invariably be dumped on the people at the bottom of the food chain, those who cannot complain too much.

2. People in positions of power and wealth will game the system and get away with it every time.

3. No one can be proven right or wrong when it comes to principles of economics and ideology. The world is too complicated, there are too many variables, you cannot do double blind experiments with control groups, etc. In practical terms, this means that no philosophy or approach can ever be definitively disproved and jettisoned; any pundit worth his salt can rationalize away the failures and non-conformances to the 'model'.

4. People keep expecting the next messiah to solve all their problems. Not going to happen.

5. The kind of hyperinflation or currency crash similar to the experiences of the Zimbabweans or the Wiemar Republic will not happen with either the dollar or the euro.

6. When people in power are in trouble, watch out for distractions, both catastrophic (Iran vs USrael) and merely irritating (retail FDI controversy, Salman Rushdie). Also be prepared for dirty tricks. These people have too much vested in the status quo to go without a fight. They're are also very smart (which is a given considering where they are and how long they have remained there). Cf. Women's reservation bill, Lokpal bill.

7. Everybody has their price.

Applying these, for want of a better term, principles, to all the questions raised above is left as an exercise for the reader.

Friday, December 02, 2011

The Retail FDI Controversy

With all the noise and disruption of parliament over the allowing of FDI in the retail sector, who's now talking about the Lokpal bill? Mission accomplished.

Tuesday, November 22, 2011

pLisp v0.1 released

pLisp (The 'p' stands for 'personal', at least as of now) is an interpreter for a Lisp-1 dialect I have been working on. I had four broad objectives when I started out:
  1. Use the experience to learn Lisp at a much deeper level than what a casual user would attain
  2. Build my own language/development environment, one that I would use for all my personal projects from now on
  3. If I manage to take the project sufficiently forward, build a Lisp development environment for newbies that rivals those of Smalltalk
  4. Use pLisp as a test bed for new research ideas related to programming
I think things are sufficiently mature enough to warrant a 0.1 release, although a not-infrequent assertion failure or segfault cannot be ruled out.

These are the features currently supported:
  1. Basic operators like CAR, CDR, and other language primitives (cf. Paul Graham's 'Roots of Lisp')
  2. Other operators and utility functions written in pLisp itself (there is a rudimentary library at present)
  3. Error handling in the form of an '(error "...")' operator
  4. Garbage collection
  5. A somewhat buggy foreign function interface
  6. Ability to store and load images (aka serialization)
  7. Macros
  8. A rudimentary debugger (step, break, resume, abort)
  9. A package system
TODO list:
  1. More comprehensive error handling; there are a lot of places where sanity checking of parameters is absent, leading to assertion failures or core dumps
  2. Enhancements to the core library
  3. Graphical development environment
  4. Compiler
  5. Continuations and implementations of other 'cool' research ideas
pLisp uses tpl for serialization and libffi for the foreign function interface.

Sunday, October 09, 2011

October 9, 2011

Some random thoughts on the ongoing Rugby World Cup:

1. I've really made an effort to understand the nuances of the game and enjoy it, but it's not easy. The most important thing to keep in mind is that there is only a single line of defence to stop the attacking team from piercing through and running all the way to score a try. This, coupled with the 'no forward passing' and offside rules, pretty much dictates the dynamics of the play. But there is still an element of ugliness to the game, most notably exemplified by the pile of bodies that takes place during a ruck. We have no idea what's happening inside, where the ball is, and so on (wonder how the referee keeps on top of things, short of jumping into the orgy himself). Things are not clean and simple, so to speak (compare this to football: 'you can only kick the ball with your foot; now try and put the ball between the two posts'). The skill displayed by a player is not readily apparent to someone who is not a fan of the sport.

2. Speaking about the refs, it's refreshing to hear the referee (and the adjudicating referee) on the microphone most of the time. More transparency this way.

3. The small number of fouls is quite amazing when compared to, say, football (not talking about technical violations here). My theory is that the 'almost anything goes' nature of the game does away with the need to commit physical fouls. Who needs to break the law when you can legally do a number on your opponent? Rugby players can both dish out and take stuff, unlike footballers who writhe on the ground in feigned agony if an opponent so much as looks at them funnily.

4. Notwithstanding the fact that it takes more strength and stamina to go through 40 minutes of non-stop action than to get through a comparable period in American football, American football is eminently more watchable. The skipping of the heartbeat every time the quarterback is about to pass the ball is missing. There are exhilarating moments in rugby too, like for example when a player dodges the defence and is streaking towards the tryline, but these are few and far between. The strategizing, playbooks, etc. of American football is missing (or maybe I can't figure things out on account of my noobiness).

5. The pre-match war dance (saw the New Zealand team do it today) is extremely silly. Sure, some opponents may get freaked out by a bunch of brutes grunting in tongues, crowing about how they will shove their brawny and tattooed arms up their opponent's asses and punch their intestines black and blue, but any half-intelligent person is more likely to struggle to not double up on the ground with laughter.

Saturday, September 24, 2011

Obama's actually right

Peace will not come through statements and resolutions at the UN. Only wars of aggression, crimes against humanity, and the murder of innocent men, women and children do.

While asking for full membership at the UN is a positive thing, as long as things are decided by the five veto-wielding so-called superpowers, the UN is as good as non-existent. In fact, at least the child-trafficking and other abuse would stop if it were disbanded.

Monday, September 19, 2011

September 19, 2011

One of my pet phobias is large objects. It's not exactly a phobia per se, but more of a slight shiver that runs down (or up?) your spine for a fleeting moment and you quickly think of shining happy thoughts to distract yourself. I think this had its genesis in the movie The Independence Day in which, if I remember correctly, a spaceship a few miles in diameter fills the sky above Washington, DC.

Now just imagine that it's not a spaceship, but the planet Jupiter, and that it's not a few miles in diameter, but is 71,492 fricking miles from one end to the other, and is so big that your entire sky is but a closeup of the planet's terrain.

You don't have to imagine this, actually. You can see a simulation video.

Sweet dreams, here I come.

Saturday, September 17, 2011

Speculators Behind 2008 Oil Shock

Via Rigorous Intuition:
Leaked Documents Reveal Major Speculators Behind 2008 Oil Price Shock

Last month, Sen. Bernie Sanders (I-VT) leaked confidential data about oil speculation to a number of media outlets, including the Wall Street Journal. Ordinarily, the Commodity Futures Trading Commission, the regulatory body that oversees futures trading, does not provide identities of speculators to the public. However, the data leaked by Sanders provides a rare snapshot into the trading volumes by major speculators right before the oil price spike in the summer of 2008.

As experts from Stanford University, Rice University, the University of Massachusetts, and authorities have concluded, rampant oil speculation was the prime driver of the record high prices for crude oil three years ago.
Ahem.

Wednesday, August 17, 2011

August 17, 2011

Simi Garewal's "India's Most Desirable" is my least favourite program on TV, even beating the likes of the 1876th rerun of the documentary "Hum Apke Hain Kaun". Sixty minutes of mindnumbing prattle from celebrities, interspersed with coy, pretending-to-be-hard-hitting questions from Simi (she must be, what, 98? Pity she wasn't born three thousand years ago in Egypt; she would have made a killing licensing the formula for her embalming potion to the pharaohs).

Not content with just Indian celebrities, there are plans to rope in Lady Gaga as well. That ought to be fun to watch: Queen Tut vs Lady Tut Tut...

Friday, August 12, 2011

August 12, 2011

I recently finished reading The Black Swan (well, I've yet to start the extended essay that has been added to the second edition, but still). A moderately interesting read, with a few intriguing and insightful ideas, but there is no satisfaction at the end, the satisfaction that comes from reading a book that puts its key messages in a tight-knit, coherent form and packs a good punch, so to speak. The book would also have benefited from a better editing process -- the language doesn't flow that easily in quite a few places. A good thing I got this book as a gift and didn't have to spend money out of my pocket.

The author's contempt for CEOs, Frenchmen, and academics (economists in particular) also comes through too strongly and bitterly -- this is probably his F*** You Money talking. Somewhat ironical, considering that there is a quote from a trader in the book along the lines of "Be nice to people on your way up, since you'll meet them on your way down". He could also have gone a bit easy on the frequent attempts at cheap titillation through mentions of prostitutes, how many lovers did Catherine the Great have, and so on.

With respect to the meat of the book, can't really disagree with the author's contention: we do not know what we're doing half the time, unknown forces are lining up against us as we speak, it's no use trying to do long-term (maybe even short-term) predictions, and our brains are hardwired to see patterns where none exist and are prone to all kinds of cognitive biases (on a side note, this paper does a more thorough job of this). Scalability is a theme that runs through the book -- be it scalable/non-scalable professions (the relation between the amount of money one makes and the physical number of hours put in -- e.g., doctors/plumbers vs hedge fund managers) or scalable odds (Gaussian vs Mandelbrotian).

While on the subject of scalability and the medical profession, today I learned that one can get an *ahem* discount of Rs 5000 on an MRI scan bill of Rs 8000 if the doctor is kind enough to not ask for his commission from the diagnostics center.

Saturday, July 30, 2011

GitHub

I've finally gotten around to collecting all my code in a single place. This is a pretty much complete collection, except for my JSON implementation for VisualWorks. A recent scare with my home laptop (a faulty chip related to the display) is the reason for this. I have an external drive where I periodically back up stuff, but I was not able to access my files during the absence of the laptop. I could have taken them from the external drive, but didn't want the hassle of again bringing the laptop contents in sync; not to mention I didn't have much time during this period due to a family emergency.

Thursday, July 14, 2011

Predicting the English Premier League - Part 2

As promised, here are the results of the number crunching. Some of the number crunching is still ongoing as I type this -- to figure out which of the parameters give the best results (the code in the AWS instance is running for six days; hopefully it will terminate before I hit the free tier limit of 750 hours).

First, a list of the prediction methods considered:

1. Homegrown method 1: In this method, we consider three parameters: home advantage, total form and recent form (three matches). Whichever team comes out on top on the cumulative score based on these three factors is designated the winner (no draws in this method).

2. Homegrown method 2: This method uses historical (this season only) values for fractions of home wins, draws and away wins; generates a random number between 0.0 and 1.0, and chooses one option based on where the number falls in the spectrum (length of each segment in the spectrum (HW, DR, AW) determined by the historical averages).

3. Random: Generate a random number between 0.0 and 1.0. If this is <= 0.33, it's a home team win; if it's between 0.33 and 0.66, it's a draw; otherwise it's an away team win.

4. Linear (GLM): The generalized linear model with least squares regression.

5. KNN: The K Nearest Neighbours method. There are two variations to this -- one where we simply consider the three classes as home win, draw, and away win; the other where we convert the three classes to real numbers. We also vary the number of neighbours considered from one to three.

Some general notes about the exercise:

1. We use data from match-week 10 to match-week 21 (inclusive) as training data for GLM and KNN

2. Predictions are for match-week 22 onwards

3. All match-weeks do not have the same number of games for various reasons (scheduling, snow, etc.)

4. These are the predictors used:
  • Home record of home team
  • Away record of away team
  • Total record of home team
  • Total record of away team
  • Most recent (three matches) record of home team
  • Most recent (three matches) record of away team
  • Goal difference of home team
  • Goal difference of away team
  • Rank in points table of home team
  • Rank in points table of away team

Here are the results of the prediction, first in table format, followed by graphs (click to enlarge):





As I mentioned earlier, pretty 'meh' results. Maybe the brute force method to identify the best parameters will yield something better. This method basically considers all the combinations of parameters from the above ten, and computes the average accuracy of prediction -- for the same training data and the same prediction period -- for all of them, and picks the combination (there are actually two combinations, one for GLM and one for KNN) with the highest value. But I'm not holding my breath.

Update: The brute force number crunching is finally done and the results are in. KNN (n=3) with classes, with two three parameters -- the away record of the away team and the total record of the home team the most recent records of the two teams and the rank of the home team -- gives the most accurate predictions:

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.”