Saturday, November 12, 2011

Major Pieces in 7th Heaven

Of late, I have been pitting my modest chess skills against the AI Factory Free Chess on my mobile. Finally, I am getting the upper hand at Level 9, recording a 55% success rate.

In this game, orchestrating the Black pieces, I piled pressure on the half-open b-file and infiltrated the 7th rank with the major pieces, after which the enemy King fell swiftly on the other side of the board.

[pgn height=500 initialHalfmove=28 autoplayMode=none showMoves=justified]
[Event "Man vs Mobile"]
[Site "Kogarah, NSW"]
[Date "2011.11.12"]
[White "AI Factory Free Chess"]
[Black "RL"]
[Result "0-1"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. d3 d6 6. c4 Be7 7. Nc3 Bg4 8. Be3 0-0 9. Bxc6 bxc6 10. h3 Bh5 11. g4 Bg6 12. c5 Re8 13. Rc1 Bf8 14. Bg5 h6 15. Bxf6 Qxf6 16. 0-0 Qe6 17. Nd2 d5 18. Nb3 a5 19. a4 d4 20. Nb1 Reb8 21. Nb1d2 Be7 22. f4 exf4 23. Rc4 Bf6 24. Nxd4 Bxd4+ 25. Rxd4 Rxb2 26. Nf3 Rab8 27. Qc1 Qf6 28. h4 Ra2 29. h5 R8b2 30. hxg6 Qxd4+ 31. Kh1 fxg6 32. Qxf4 Qxd3 33. Rc1 Qe2 34. Rg1 Qxf3+ 35. Qxf3 Rh2++ 0-1
[/pgn]

Wednesday, October 12, 2011

Computational Model of Peace Predicts Social Violence, Harmony

"A systems model of how ethnic tensions flare into violence has passed a test in Switzerland, where harmony prevails except for one region flagged by the analysis," writes Brandom Keim at wired.com.

"The model runs census data through an assembly line of high-powered mathematical processes, but at its root is one basic assumption: that community-level violence is primarily a function of geography, modulated by the overlap of political, topographical and ethnic borders."

Click here to read more.

Sunday, June 5, 2011

Monte Carlo Simulation to Estimate pi

Imagine a person randomly throwing darts at a square board with a unit circle inscribed on it. The proportion of darts that land in the circle multiplied by 4 gives an estimate of the value of pi. The point (x, y) hit by the dart is in the circle if x^2 + y^2 <= 1.

What follows is my implementation of this idea in Teradata sql, with the value of pi estimated to two decimal places. The resource at the end of this post has a nice discourse on this topic, with Python implementations and a video on Monte Carlo simulation.
/* Create a table with a random point (x,y) on the board */
CREATE VOLATILE TABLE tblTemp AS
(SELECT RANDOM(-100,100)/100.00 AS x
,RANDOM(-100,100)/100.00 AS y
,CASE WHEN x**2+y**2 <= 1 THEN 1
ELSE 0
END AS inCirc
)WITH DATA PRIMARY INDEX (x)
ON COMMIT PRESERVE ROWS;

/* Generate a sufficiently large (but not too large!) number of random points (x,y) on the board */
CREATE VOLATILE TABLE tblRndPts AS
(WITH RECURSIVE tblRnd (lvl, x, y, inCirc) AS
(SELECT CAST(1 AS DECIMAL(18,0)) AS lvl, x, y, inCirc
FROM tblTemp

UNION ALL

SELECT lvl+1
,RANDOM(-100,100)/100.00 AS x1
,RANDOM(-100,100)/100.00 AS y1
,CASE WHEN x1**2+y1**2 <= 1 THEN 1
ELSE 0
END AS inCirc
FROM tblRnd AS t1
WHERE t1.lvl < 10000 /* total number of points (x, y) */
)
SELECT *
FROM tblRnd
) WITH DATA PRIMARY INDEX (lvl)
ON COMMIT PRESERVE ROWS;

/* Calculate pi and the diff from the actual value */
SELECT 4.00 * SUM(inCirc)/COUNT(*) AS pi, CAST(pi() - pi AS DECIMAL(4,2)) AS diff
FROM tblRndPts;

Click here to read more about this topic.

Monday, May 2, 2011

Pacquiao Was Inspired by Bruce Lee

pacquiao

On the eve of his fight with Shane Mosley this Saturday US time, The New York Times reports that the Filipino boxing sensation Manny Pacquiao was inspired by Bruce Lee.

"The boxing genius of Manny Pacquiao includes feet that belong in Riverdance, calves the size of grapefruits and deceptive power generated from his core. His movement is unorthodox, scattered and perpetual, as if designed by a jazz musician. He creates angles unlike any other fighter, past or present, appearing, disappearing, shifting, striking; on balance, off balance, even off one foot.

"It is this style — part performance art, part technical wizardry, unique to Pacquiao— that defines perhaps the best boxer of his generation. And it started with a videotape of the martial artist who became his idol. It started with Bruce Lee.

"Last month, as Pacquiao molded his style specific to Shane Mosley, his welterweight opponent on Saturday in Las Vegas, he wrapped his hands inside the dressing room at the Wild Card boxing gym here. To explain the way he fights, he settled on three words.

“Like Bruce Lee,” he said.

Saturday, April 30, 2011

Thinking About CMM

Some things learned in the academia can have practical significance. One thing I learned in a dry, theory-laden unit was the concept of Capability Maturity Model (CMM). It is summed in the following diagram.

[caption id="attachment_804" align="aligncenter" width="480" caption="Capability Maturity Model"]Capability Maturity Model matrix[/caption]

The CMM can help locate where an organization or a unit within an organization is in relation to a particular process or functional capability.

In a sense, CMM does for organizations what Maslow's hierarchy of needs does for human beings. The latter claims that lofty human needs cannot be fulfilled before satisfying baser needs.

By helping organizations assess their capabilities or lack thereof, CMM can point out where an organisation or a team needs to pour its resources before planning grand but doomed schemes.

Thursday, April 14, 2011

Thus Spake HAL

Dissociated press is a computer program that generates text based on another text. Here is an example of dissociated press based on the US presidential inaugural addresses:
Fellow - Citizens of the world. Abroad and at the same mistake. In a great river system, purified and made self. And there is a privilege which he has shown that our Government together and laugh together and save the lives of our civilization secure. In our time, a pleasing guaranty that the actual equality of rewards or possessions so long bled and suffered, we have fought not for themselves. Mindful of these States, was out of the Ohio or of rank have been distinguished by some from a fever of words

A computer would have apparently written The Book of Genesis thus:
In the day when they were both the daughters of Lot with him, at the first born; I bare the loss of it; for a possession of flocks, and she called his name Onan. And Hamor communed with him for righteousness. And her brother and her damsels, and possession of herds, and at night he shall be fruitful and multiply thee, then the other end thereof. And Terah took Abram his son with the sword? Wherefore didst thou flee away secretly, and where thou art yet alive,

I was curious how Gandhi would come out. The following text is based on a collection of Gandhi's writings at Project Gutenberg. I did not remove the Project Gutenberg copyright notice before feeding it to the computer, and the effects are pleasing:
Project Gutenberg is a grand doctrine of life. With them it is to weld India into one, he instanced Scotland's poverty of the Government whenever it needed their help. Their resistance consisted of disobedience of the copyright holder, your use and distribution of Project Gutenberg-tm eBooks are often created from several printed editions, all of them fellow cranks--if in similar circumstances I acted towards them differently from my own family. It were better to concentrate my effort upon the subject before us. I was hard put to it that the co-operative movement. " In his opinion

 

Saturday, March 5, 2011

Bruce Lee Comes To Town

Move over, Mundine! The real Man has come to town. The Man who could stop bullets with a nunchaku. The Man who could move faster than electricity!

[caption id="attachment_768" align="alignright" width="350" caption="Bruce Lee's statue at the Kogarah Town Square."]Bruce Lee[/caption]

A statue of Bruce Lee in his familiar martial arts pose was unveiled at the Kogarah Town Square yesterday. The statue was presented by the City of Shunde, China, to the City of Kogarah to mark the first anniversary of their Friendship City Agreement.

Among the boys of a certain generation to which I myself belonged, Bruce Lee was bigger than the Beatles. Before we learnt to dream of becoming engineers and doctors, we aspired to become a Bruce Lee and kick ass.

And the legend of Bruce Lee! He could fell a bull by a single punch on its forehead thrown from an inch away. He could block machinegun bullets with his trademark weapon, nunchaku. In fact, it was de riguer to have a nunchaku, and learning to wield it was a rite of passage for many.

Bruce Lee was believed to be so quick that he could flick the switch off, dash to his bed and lie on it before the light went out.

Many an afternoon would be spent discussing the endlessly fascinating question of what would have happened if Bruce Lee and Mohammed Ali had met in a fight. The consensus was either a win for Bruce Lee or a draw as Ali also belonged to our pantheon of superheroes.

Bruce Lee's death at a young age only served to enhance his mystique.

Later on, as we grew older, we, or at least I, came to view Bruce Lee as an embodiment of the wisdom of the East.

The unveiling of Bruce Lee’s statue at the Kogarah Town Square tells  me that the man who used to break bones is now helping build bridges between peoples and cultures.

Sunday, February 27, 2011

And the Grass Grows by Itself



The movie Eat Pray Love, which I finally watched on DVD, reminded me of an old Buddhist poem:
Sitting silently
Doing nothing
The Spring comes
And the grass grows by itself

So, as the protagonist of Eat Pray Love learns, the Italians have distilled the aesthetic of doing nothing in an even more exquisite phrase: il dolce far niente or the sweetness of doing nothing.

The idea of rejuvenating the spirit and body through inaction is nothing new. The Abrahamic religions bestowed the idea of sabbath. Buddhist masters set aside time for doing nothing, except perhaps brewing tea and watching the cassia flowers fall.

Time for me to do nothing!

Saturday, February 26, 2011

Musings

botticelli venus

That archetypal American inventor, Thomas Alva Edison, reportedly said genius is one percent inspiration and ninety-nine percent perspiration.

When the Spanish violinist Pablo de Sarasate (1844 – 1908) was hailed as a genius, he quipped, “A genius! For 37 years, I’ve practised fourteen hours a day, and now they call me a genius!”

The Irish writer James Joyce meets a friend in a bar. The friend asks how he is doing.

“I’m exhausted,” Joyce says.

“Why?” the friend enquires. “What did you do today?”

“I wrote a sentence,” Joyce says.

Thursday, February 24, 2011

The Jury is Still Out

Recently, I served on jury duty in a trial involving alleged assault, malicious wounding and intent to rob. After almost two and a half day of intense deliberations, the outcome was a hung jury. In reality, the outcome was always going to be either a guilty verdict or a hung jury as at least one juror never wavered from his initial position in favor of a guilty verdict.

Although the jury experience has reinforced my faith in the judicial system, I came away with mixed feelings about the jury system itself. What happened was that a couple of jurors basically made the decision for the vast majority of the jurors. These dominant jurors were vocal, confrontational and forceful, at one point reducing a dissenting gentle old lady to tears.

One of the vocal jurors had recently finished law school but not been admitted to bar yet. The juror clearly thought the law degree gave a license to ride roughshod over the rest of the jurors, often playing what I considered to be vain intellectual games. The juror would support one side of the argument and suddenly switch to the other as if to dazzle the jury with the rhetorical skills picked up at the law school.

For most of the deliberations, the jury was split almost 50-50. Towards the end of the day two of the deliberations, there was a dramatic shift to 11-1 in favor of a guilty verdict but still not a unanimous decision as required by law. When informed of the deadlock, the Judge instructed the jurors to spend some more time to try to reach a unanimous verdict.

Next morning, after another intense session of deliberations during which the law graduate argued for a not-guilty verdict, a snap poll was taken. By this time, nothing should have surprised me but I was still surprised when the law graduate voted for a guilty verdict after arguing for a not-guilty verdict throughout the morning session. The snap poll result was 8-4 in favor of a guilty verdict.

Clearly, the deadlock had worsened. When informed again, the Judge instructed the jury to try to see if an 11-1 verdict was possible. Another session of deliberations began, and, of the four who had voted in favor of a not-guilty verdict, two quickly fell in line. When it became clear that the remaining two would not budge from their position, something startling happened.

Throughout the deliberations, there was this feeling that returning a hung jury was somehow a betrayal of the trust the Crown Prosecutor and the Judge had placed in the jury. So, when it became clear that a guilty verdict was not possible, the law graduate asked everyone how many could vote for a not-guilty verdict without feeling ‘morally compromised’. Ten hands went up. This meant the accused was just one vote shy of acquittal.

If so many jurors felt that they could vote for a not-guilty verdict without feeling morally compromised, perhaps the Crown had not done enough to prove beyond reasonable doubt that the accused was guilty. In fact, many jurors would complain that the Crown Prosecutor could have done a better job and then go on to vote in favor of a guilty verdict.

In the end, the Judge decided that the impasse was beyond resolution and dismissed the jury. Before dismissal, the jury was informed that the Crown would try the accused again at an unspecified date.

At various times, I felt that some jury members struggled with the fundamental concept of the presumption of innocence. They gave the impression that the mere fact of being charged is a sufficient reason for conviction.

One jury member - the same one who from the start never once wavered in his belief in the guilt of the accused - at one point argued that the accused had proven his guilt by exercising the right to silence when interviewed by the police. This was despite the Judge's instruction not to hold this fact against the accused.

The defense case largely rested on an alibi, which was shown to be very shaky by the Crown Prosecutor. However, the demolition of the alibi did not automatically establish the guilt of the accused, another fact reminded by the Judge to the jury members a few times. However, some jury members did not seem to grasp this fact either.

The trial by jury may be one of the crown jewels of the human civilization but it clearly has its flaws. But, then, what does not?

Friday, February 18, 2011

End is Nigh for the Puppet Show

As if further proof was needed of the impending annihilation of the NSW Labour Government in next month’s state election.

In the large assembly hall of a government building where a crowd of people from all walks of life were watching Channel 7, every time NSW Premier Kristina Keneally appeared in the ad with the drivel about legislating to help struggling families if returned next month, she was greeted with hearty guffaws.

This state Labour Government’s goose is cooked. The only reason that it was not dumped in the last couple of elections was the disarray in the Opposition ranks thanks to the internecine factional warfare in the state Liberal Party. All that Barry O’Farrell and company now have to do is sit tight and do nothing. Their winning election strategy boils down to a single magic word: inaction.

Will NSW voters fare better under O’Farrell? They certainly seem to think so if opinion polls are anything to go by.

Keneally herself is an affable politician who inherited a poisoned chalice and the unflattering tag of  'puppet' of the NSW Labour machine thanks to the parting shot of her predecessor, Nathan Rees. On March 26, she will be the innocent lamb led to the slaughter house to atone for the sins of her party, which has been in power for far too long for its own good.

Monday, February 14, 2011

Mahatma and the Naked Fakir

Gandhi’s admirers perform all sorts of rhetorical contortions to defend some of his more bizarre ideas and practices. One such practice that became public knowledge in the twilight of his life shocked even his most dyed-in-wool devotees.

On the eve of Independence, Gandhi marched through the paddy fields of Bengal on foot with a wooden staff and a train of followers to calm seething Hindu-Muslim hostility with nothing more than the sheer force of his personality. A mobile toilet carried by his admirers along with the more familiar Gandhian prop, the spinning wheel, accompanied the great man during this celebrated journey.

It was during this time that one of Gandhi’s more controversial practices became public knowledge.  Ostensibly to test his long-standing vow of brahmacharya (celibacy), Gandhi was found to be in the habit of sharing his bed with young women.

There is no suggestion that Gandhi in any way violated his sleeping partners, many of whom selflessly ministered to his physical well-being and acted as his confidantes. However, the incongruity of the old, ascetic Gandhi sleeping naked with young women scandalised the sensibilities of his puritanical Hindu followers as well as those of more secular bent in the Congress Party.

Gandhi’s achievement in Bengal that year turned out to be nothing short of miraculous. While Punjab and the rest of the Subcontinent was seized by collective madness, with Hindus and Muslims indulging in an orgy of tit-for-tat murders that ultimately claimed millions of lives, Bengal held its peace thanks only to Gandhi’s commanding presence and towering moral authority.

Gandhi camped with his followers in an old, decaying bungalow in a Muslim neighbourhood in Calcutta as Hindu-Muslim tensions threatened to boil over. A Muslim mob moved into the neighbourhood and started to attack Gandhi, hurling stones and abuses and ordering him to move out. Gandhi pacified and won over his attackers by declaring that he would not leave the place as long as a single Muslim in the neighbourhood felt threatened and insecure from Hindus.

Some of Gandhi’s ideas about social reform, such as his rejection of industrialisation in favour of an agrarian utopia that supposedly existed in India’s imagined past or his re-categorization of the Hindu untouchables into ‘Harijans’ (God's people), can be charitably dismissed as quixotic or misguided. If only deep-rooted social evils such as the Hindu caste system could be magically eradicated by re-labelling its victims!

However, Gandhi’s lifelong struggle against injustice and colonialism, first in South African and then in India, justifies his undisputed standing as a giant of the 20th century.

As the British broadcaster Mishal Husain argued in a recent three-part BBC documentary, Gandhi’s admirers do him a great disservice by placing him on a pedestal.

A Gandhian female academic that Husain interviewed in India for the documentary was asked about Gandhi’s controversial practice of sleeping naked with his young female followers.
 
Instead of admitting the possibility that Gandhi, Mahatma though he was, could have made errors of judgement, the academic trotted out the familiar argument about Gandhi testing his resolve and self-control by sleeping with nubile women. Even more disingenuously, she claimed the women would have been enriched morally by the experience notwithstanding the fact that Gandhi used them as mere foil to his dubious spiritual exercises. In his followers’ eyes, Gandhi could do no wrong and was above reproach.
 
What if the Mahatma had lost his self-control?

But if we forget Gandhi the legend, there is a lot to like about the man.
 
Though many know that Gandhi sought solace and inspiration in the ancient verses of the Hindu scripture Geeta, few are aware of the eclectic influences of his youth that shaped his mature worldview.

While studying law in London, he read Geeta for the first time. However, he also read the Sermon on the Mount and Tolstoy, and socialised with Theosophists and London’s vegetarians, giving up meat.

He sailed to London despite threats from his clan elders to strip him of his caste status and its attendant privileges. By sailing to London, Gandhi violated the ancient Hindu taboo against crossing seas. His later attempts to recover his caste status by performing prescribed ceremonies failed, apparently because his clan elders had not forgiven his transgression.

He cut his political teeth by fighting racism against Indians and blacks in South Africa. He mobilised the Indian mass against the British Empire on the principle of non-violence and succeeded to wrest freedom for them. 

Just before and in the aftermath of Independence, Gandhi protected Muslim minorities and their properties from murderous Hindu mobs, first in Bengal and then in New Delhi. He paid for his ecumenicalism and vision of universal brotherhood with his life at the hand of a Hindu fanatic.
 
Gandhi’s puritanism and bizarre spiritual experiments in old age, his insistence on interfaith goodwill to address Muslim minority concerns in place of concrete political concessions, his refusal to support any special treatment to Hindu outcasts, his uncritical apotheosis in modern India, and his stern gaze from the pedestal can be quite off-putting.

However, bring him down from the pedestal and Gandhi, with or without his loincloth, starts to look much more attractive.

Sunday, January 16, 2011

Institutions Matter

Why is it that some countries continue to be poor despite being blessed with abundant natural resources, human capital and technology transfer from developed countries?  Many resource-rich African countries mired in poverty and bloody civil wars come to mind. Even India, despite its much lauded economic growth of recent years, can be added to the list of these underachievers. 

According to Tim Harford in The Undercover Economist (2006), the answer lies in the poor nations' institutions or lack thereof.  As he puts it succinctly, "institutions matter".

Most resource-rich poor countries lack institutions capable of holding executive power in check and making them accountable to the people. As a result, the ruling cliques and their cronies can cream off the proceeds from the resources with impunity and become obscenely rich while the vast majority of their compatriots sink deeper into poverty.

"Institutions matter".  This phrase popped into my mind again when reading about the 1843 British annexation of Sindh (Punjab) in John Keay's India: A History (2000). One of the last so-called princely states to be bullied into Pax Britannica, Sindh had been able to keep the British at bay with diplomacy and a modern military under the inspired rule of Maharaja Ranjit Singh.

On the eve of the First British Afghan War in which the British Raj suffered one of its most disastrous losses, Ranjit Singh, the Bonaparte of Sindh, the Lion of Punjab, died, in 1839.   

Keay writes: "A philander of many wives and more women, he was not without potential successors. Yet so personal had been his rule and so absolute his authority that the institutions of sovereignty and government through which a successor might establish himself scarcely existed."

The result was predictable. In the midst of the succession crisis that engulfed Sindh, the British, in the words of the victorious British general, pulled off a "very advantageous, useful, humane piece of rascality."

'Rascality' actually sums up the Indian, or perhaps any human, history.

Keay opens his narrative with the ancient Indian concept of Matsya-Nyaya or 'fish law' according to which big fish devour small fish. The subsequent laundry list of dynasties great and small that subjugate various parts of the Indian sub-continent through the millennia appears like a rogue’s gallery of history.

When the various dynasties are not oppressing their wretched subjects by imposing extortionate taxes to finance their ego-boosting monumental extravagances, they are at each others' throats, pillaging the defeated kingdoms’  treasuries and polluting their women.

This gives lie to the myth of a golden age, the so-called ‘Ram Rajya’, to which many people of certain persuasion look back with great nostalgia in the Indian sub-continent.  

Keay has a slippery grasp of Sanskrit words and phrases but he, nevertheless, convincingly demolishes many cherished mytho-historical sacred cows of India. For example, he cogently argues that the epic Mahabharata predates Ramayana, a startling proposition only an outsider like Keay could perhaps make.

After reading about the umpteenth petty cutthroat performing a ritual digvijaya or world conquest and assuming the title of Maharajadhiraja ,  one starts to contemplate the august personages of surviving Maharajadhirajas with fresh eyes.

Sunday, January 2, 2011

How Many Springs Do We See?


Pear blossoms pale white, willows deep green,

When willow fluff scatters, falling petals will fill the town,

Snowy boughs by the eastern palisade set me pondering -

In a lifetime, how may springs do we see?