Bayesian Reasoning and Indian Philosophy

I’m currently reading a book called How the World Thinks: A global history of philosophy by Julian Baggini. I must admit I bought this by mistake – I was at a bookshop where I saw this book and went to the Amazon website to check reviews. And by mistake I ended up hitting buy. And before I got around to returning it, I started reading and liking it, so I decided to keep it.

In any case, this book is a nice comparative history of world philosophies, with considerable focus on Indian, Chinese, Japanese and Islamic philosophies. The author himself is trained in European/Western philosophy, but he keeps an open mind and so far it’s been an engaging read.

Rather than approaching the topic in chronological order, like some historians might have been tempted to do, this book approaches it by concept, comparing how different philosophies treat the same concept. And the description of Indian philosophy in the “Logic” chapter caught my eye, in the sense that it reminded me of Bayesian logic, and a piece I’d written a few years back.

Talking about Hindu philosophy and logic, Baggins writes:

For instance, the Veda affirms that when the appropriate sacrifice for the sake of a son is performed, a son will be produced. But it is often observed that a son is not produced, even though the sacrifice has been performed. This would seem to be pretty conclusive proof that the sacrifices don’t work and so the Veda is flawed. Not, however, if you start from the assumption that the Veda cannot be flawed.

In other words, Hindu Philosophy starts with the Bayesian prior that the Veda cannot be flawed. Consequently, irrespective of how strong the empirical evidence that the Vedas are flawed, the belief in the Vedas can never change! On the other hand, if the prior probability that the Vedas were flawed were positive but even infinitesimal, then the amount of evidences such as the above (where sacrifices that are supposed to have produced sons but fail to do so) would over time result in the probability of the Vedas being flawed increasing, and soon tending to 1.

In 2015, I had written in Mint about how Bayesian logic can be used to explain online flame wars. There again, I had written about how when people start with extreme opinions (probabilities equal to 0 or 1), even the strongest contrary evidence is futile to get them to change their opinions. And hence in online flame wars you have people simply talking past each other because neither is willing to update their opinions in the face of evidence.

Coming back to Hindu philosophy, this prior belief that the Vedas cannot be flawed reminds me of the numerous futile arguments with some of my relatives who are of a rather religious persuasion. In each case I presented to them what seemed like strong proof that some of their assumptions of religion are flawed. In each case, irrespective of the strength of my evidence, they refused to heed my argument. Now, looking at the prior of a religious Hindu – that the likelihood of the Vedas being flawed is 0 (not infinitesimal, but 0), it is clear why my arguments fell on deaf ears.

In any case, Baggini goes on to say:

By this logic, if ‘a son is sure to be produced as a result of performing the sacrifice’ but a son is not produced, it can only follow that the sacrifice was not performed correctly, however much it seems that it was performed properly. By such argument, the Ny?ya S?tra can safely conclude, ‘Therefore there is no untruth in the Veda.’

Biases, statistics and luck

Tomorrow Liverpool plays Manchester City in the Premier League. As things stand now I don’t plan to watch this game. This entire season so far, I’ve only watched two games. First, I’d gone to a local pub to watch Liverpool’s visit to Manchester City, back in September. Liverpool got thrashed 5-0.

Then in October, I went to Wembley to watch Tottenham Hotspur play Liverpool. The Spurs won 4-1. These two remain Liverpool’s only defeats of the season.

I might consider myself to be a mostly rational person but I sometimes do fall for the correlation-implies-causation bias, and think that my watching those games had something to do with Liverpool’s losses in them. Never mind that these were away games played against other top sides which attack aggressively. And so I have this irrational “fear” that if I watch tomorrow’s game (even if it’s from a pub), it might lead to a heavy Liverpool defeat.

And so I told Baada, a Manchester City fan, that I’m not planning to watch tomorrow’s game. And he got back to me with some statistics, which he’d heard from a podcast. Apparently it’s been 80 years since Manchester City did the league “double” (winning both home and away games) over Liverpool. And that it’s been 15 years since they’ve won at Anfield. So, he suggested, there’s a good chance that tomorrow’s game won’t result in a mauling for Liverpool, even if I were to watch it.

With the easy availability of statistics, it has become a thing among football commentators to supply them during the commentary. And from first hearing, things like “never done this in 80 years” or “never done that for last 15 years” sounds compelling, and you’re inclined to believe that there is something to these numbers.

I don’t remember if it was Navjot Sidhu who said that statistics are like a bikini (“what they reveal is significant but what they hide is crucial” or something). That Manchester City hasn’t done a double over Liverpool in 80 years doesn’t mean a thing, nor does it say anything that they haven’t won at Anfield in 15 years.

Basically, until the mid 2000s, City were a middling team. I remember telling Baada after the 2007 season (when Stuart Pearce got fired as City manager) that they’d be surely relegated next season. And then came the investment from Thaksin Shinawatra. And the appointment of Sven-Goran Eriksson as manager. And then the youtube signings. And later the investment from the Abu Dhabi investment group. And in 2016 the appointment of Pep Guardiola as manager. And the significant investment in players after that.

In other words, Manchester City of today is a completely different team from what they were even 2-3 years back. And they’re surely a vastly improved team compared to a decade ago. I know Baada has been following them for over 15 years now, but they’re unrecognisable from the time he started following them!

Yes, even with City being a much improved team, Liverpool have never lost to them at home in the last few years – but then Liverpool have generally been a strong team playing at home in these years! On the other hand, City’s 18-game winning streak (which included wins at Chelsea and Manchester United) only came to an end (with a draw against Crystal Palace) rather recently.

So anyways, here are the takeaways:

  1. Whether I watch the game or not has no bearing on how well Liverpool will play. The instances from this season so far are based on 1. small samples and 2. biased samples (since I’ve chosen to watch Liverpool’s two toughest games of the season)
  2. 80-year history of a fixture has no bearing since teams have evolved significantly in these 80 years. So saying a record stands so long has no meaning or predictive power for tomorrow’s game.
  3. City have been in tremendous form this season, and Liverpool have just lost their key player (by selling Philippe Coutinho to Barcelona), so City can fancy their chances. That said, Anfield has been a fortress this season, so Liverpool might just hold (or even win it).

All of this points to a good game tomorrow! Maybe I should just watch it!

 

 

Big forward, little forward

When most teams play a front two, it comprises of a small quick guy (called the Number Ten) and a big guy (called the Number Nine). The convention is that when the team is defending, one of these two stays up ahead (just beating the off-side mark, wherever the opposition defence line is), while the other tracks back in order to help out with the defence. The worldwide convention in this regard is for the Number Nine to stay up front in anticipation of an attack while the Number Ten drops back to defend.

Liverpool, of late, however, have played differently. Their Number Ten (figuratively, since he wears seven on his back) Luis Suarez is the one usually left alone upfront when the team is defending, while the number Nine Andy Carroll tracks back to help out in defence.

The logic of this policy is two-fold. One, an additional big player coming back to defend means greater ability to win defensive headers within the box (think of it in terms of winning rebounds in basketball). Secondly, Liverpool under Dalglish have preferred a pass-the-ball-out-of-defence method rather than clearances. This means that when the offence breaks and a counterattack is to be launched, the ball is more likely to be played along the ground to the forward rather than up in the air. And Suarez is the more likely of the pair of forwards more likely to make use of that.

So what is the concept behind the conventional wisdom of leaving Nine upfront with Ten dropping back into defence? The typical strategy in English football is to clear the ball out of defence rather than passing it out, and the big number nine is well positioned to receive it upfront. The big nines usually also have the ability to ‘hold up’ the ball, to allow his team-mates to join him. The number ten, being quick, is able to quickly join the number nine in attack.

The other factor behind leaving the number nine upfront is that they are usually one-dimensional players, with the only abilities being to win headers and hold up the ball. They are either no good in defence, or have big strikers’ egos that prevents from joining defence effectively. Number tens, on the other hand are more skilled all-round and are more likely to come of use in defence.

In this sense, Carroll is not bad at defence, and more importantly he is young and out of form, which makes it easy for Dalglish to force him to track back while defending. So far, it seems to be working.

Coding

Back when I was in school (11th/12th) I think I was an awesome coder. I think I was especially good at what they called as “logic coding”, i.e. coming up with algos. I used to experiment quite a bit (as much was possible with TurboC) and had a lot of fun too. I remember doing graphics in TurboC, making a “pong” game, brick breaker, and a lot of other cool stuff. For our 12th standard project, Hareesh and I built this totally awesome cricket scoring program, which we unfortunately didn’t take forward (and went to college instead).

It was my love for coding that meant I fought with my parents (who wanted me to study Electrical) and decided to study Computer Science at IIT Madras. And then I lost it. Somewhere along the way. I didn’t enjoy coding any more. Soon, I began to hate coding. I would love coding when I would write the odd program in “pure” C, or when I would participate in contests such as BITWise. But I’d completely lost it.

So over the last six to seven years (after I graduated from IIT) there have been occasions when I have thought I’ve regained my coding mojo, only to lose it again very soon. I’m still very proud of that Excel+VBA model that I had written in the very first week of my third job. But a couple of months later, I was hating coding again. And so it was while debugging a complicated piece of code at work this morning that I realize why I have this love-hate relationship with coding.

It’s simple – basically I hate coding for others. I hate writing code that others will read or use. I don’t mind writing code that others would use as a black box, of course. But I think writing code that others will read or use puts too many constraints on the way you code. My instinct is always to stop doing something when I’m personally satisfied with it, and with code it seems like I’m satisfied sooner than others would be satisfied with my code.

At a fundamental level, I like coding and I think I’m pretty good at it, so it isn’t something I want to give up. But then the formal processes and endless testing involved with writing code for others really kills joy (as does GUI, and Java). Code saves a lot of time, and helps “studdize” what might be otherwise fighter work, so I like doing it.

In an ideal world, I would be writing code that I would alone be using, AND profiting from it (I never intend to sell code; I intend to sell the results of the said code, however; that would mean no one else would read/use my code per se, so I can write it the way I want). Hopefully I’ll get there, sometime.

Road Widening is NOT the solution

The other day, walking down Dr. Rajkumar Road in Rajajinagar, I saw several signboards on the road, on shopfronts, on buildings, etc. protesting against plans for widening the road. Apparently they want to widen the road and thus want to demolish shops, parts of houses, etc. Looking outside my own apartment building the other day, I saw some numbers written on the compound wall. Digging deeper, I figured that they want to widen the road I live on and hence want to claim part of the apartment land.

Now, the logic behind road widening is not hard to understand – due to increase in traffic, we need more capacity on the roads and hence increasing their width results in increased capacity in terms of vehicles per unit time and so it is a good thing . However, before going headlong into road widening and land acquisition for the purpose, road architecture in the city needs to be studied carefully.

There are two primary reasons why trafffic bottlenecks happen. The more common reason at least in western nations is road capacity. Roads just don’t have the capacity to take more than a certain number of cars per hour and so when more cars want to go that way, it results in pile-ups. The other problem, which I think is more common in India is intersections.

It is going to be a tough problem to model but we should split up roads into segments – one segment for each intersection it is part of, and one segment for each segment between intersections (ok it sounds complicated but I hope you get it). And then, analyzing capacities for these different segments, my hypothesis is that on an average, “capacity” of each intersection is lower than the capacity of road segments between intersections.

Now how does one calculate capacity of intersections? Assume an intersection with traffc coming from all four directions. Suppose traffic approaching the intersection from north sees green light for fifteen seconds a minute. And in each fifteen second interval, 25 cars manage to make it past the intersection. So the capacity of this intersection in this direction becomes 25 cars per minute. I hope you get the drift.

I’m sure there will be some transportation engineers who will have done surveys for this but I don’t have data but I strongly believe that the bigger bottleneck in terms of urban transport infrastructure is intersections rather than road width. Hence widening a road will be of no use unless flyovers/underpasses are built across ALL intersections it goes through (and also through judicious use of road divider). However, looking at the density of our cities, it is likely to prove extremely expensive to get land for the widened roads, flyovers etc.

I don’t see private vehicle transportation as a viable solution for most Indian cities. Existing road space per square kilometer is way too small, and occupation way too dense for it to be profitable to keep widening roads. The faster we invest in rapid public transport systems, the better! I’m sure the costs borne in that direction will be significantly lower than to provide infrastructure to citizens to use their own vehicles.