The first seed was sown in my head by Harish “the Psycho” J, who told me a few months back that nobody reads blogs any more, and I should start making “analytics videos” to increase my reach and hopefully hit a new kind of audience with my work.

While the idea was great, I wasn’t sure for a long time what videos I could make. After all, I’m not the most technical guy around, and I had no patience for making videos on “how to use regression” and stuff like that. I needed a topic that would be both potentially catchy and something where I could add value. So the idea remained an idea.

For the last four or five years, my most common lunchtime activity has been to watch chess videos. I subscribe to the Youtube channels of Daniel King and Agadmator, and most days when I eat lunch alone at home are spent watching their analyses of games. Usually this routine gets disrupted on Fridays when the wife works from home (she positively hates these videos), but one Friday a couple of months back I decided to ignore her anyway and watch the videos (she was in her room working).

She had come out to serve herself to another serving of whatever she had made that day and saw me watching the videos. And suddenly asked me why I couldn’t make such videos as well. She has seen me work over the last seven years to build what I think is a fairly cool cricket visualisation, and said that I should use it to make little videos analysing cricket matches.

And since then my constant “background process” has been to prepare for these videos. Earlier, Stephen Rushe of Cricsheet used to unfailingly upload ball by ball data of all cricket matches as soon as they were done. However, two years back he went into “maintenance mode” and has stopped updating the data. And so I needed a method to get data as well.

Here, I must acknowledge the contributions of Joe Harris of White Ball Analytics, who not only showed me the APIs to get ball by ball data of cricket matches, but also gave very helpful inputs on how to make the visualisation more intuitive, and palatable to the normal cricket fan who hasn’t seen such a thing before. Joe has his own win probability model based on ball by ball data, which I think is possibly superior to mine in a lot of scenarios (my model does badly in high-scoring run chases), though I’ve continued to use my own model.

So finally the data is ready, and I have a much improved visualisation to what I had during the IPL last year, and I’ve created what I think is a nice app using the Shiny package that you can check out for yourself here. This covers all T20 international games, and you can use the app to see the “story of each game”.

And this is where the vlogging comes in – in order to explain how the model works and how to use it, I’ve created a short video. You can watch it here:

While I still have a long way to go in terms of my delivery, you can see that the video has come out rather well. There are no sync issues, and you see my face also in one corner. This was possible due to my school friend Sunil Kowlgi‘s Outklip app. It’s a pretty easy to use Chrome app, and the videos are immediately available on the platform. There is quick YouTube integration as well, for you to upload them.

And this is not a one time effort – going forward I’ll be making videos of limited overs games analysing them using my app, and posting them on my Youtube channel (or maybe I’ll make a new channel for these videos. I’ll keep you updated). I hope to become a regular Vlogger!

So in the meantime, watch the above video. And give my app a spin. Soon I’ll be releasing versions covering One Day Internationals and franchise T20s as well.


Volatility and price differentiation

In a rather surreal interview to the rather fantastically named Aurangzeb Naqshbandi and Hindustan Times editor Sukumar Ranganathan, Congress president Rahul Gandhi has made a stunning statement in the context of agricultural markets:

Markets are far more volatile in terms of rapid price differentiation, than they were before.

I find this sentence rather surreal, in that I don’t really know what Gandhi is talking about. As a markets guy and a quant, there is only one way in which I interpret this statement.

It is about how market volatility is calculated. While it might be standard to use standard deviation as a measure of market volatility, quants prefer to use a method called “quadratic variation” (when the market price movement follows a random walk, quadratic variation equals the variance).

To calculate quadratic variation, you take market returns at a succession of very small intervals, square these returns and then sum them up. And thinking about it mathematically, calculating returns at short time intervals is similar to taking the derivative of the price, and you can call it “price differentiation”.

So when Gandhi says “markets are far more volatile in terms of rapid price differentiation”, he is basically quoting the formula for quadratic variation – when the derivative of the price time series goes up, the market volatility increases by definition.

This is what you have, ladies and gentlemen – the president of the principal opposition party in India has quoted the formula that quants use for market volatility in an interview with a popular newspaper! Yet, some people continue to call him “pappu”.

Tigers and Bullwhips

Over three years ago, well before our daughter was born, my wife’s cousin had told us that she likes to watch her daughter’s TV shows because they contained “morals”, which were often useful to her at work. While we never took to the “moral” TV show she mentioned (Daniel Tiger – it is bloody boring), I have begun to notice that there are important management lessons in other popular children’s stories.

So I hereby begin this blog series on what I call the “Kiddie MBA” – basically business lessons from kids’s stories. And we will start with that all-time classic, The Tiger Who Came To Tea, by Judith Kerr. 

The basic premise of this story that remains a classic fifty years after being published is what operations managers call the “bullwhip effect“. Sometimes a business, possibly in trading, can be subject to a sudden demand, which the business will not be able to fulfil given its current inventories.

As a result of this sudden one-time spurt in demand, the business increases its future forecasts of demand, and starts keeping more inventory. This business’s supplier sees this increased demand and increases its own forecasts upward, and increases its own inventory. Thus, this one-time demand “shock” percolates up the supply chain, giving the illusion of higher demand and with each layer in the chain keeping higher and higher inventory.

And then one day the retailer will realise that this demand shock is not replicable and moves forecasts downwards, and this triggers a downward edge in the forecasts up the value chain, and demand at the source comes crashing down.

Being a children’s book, The Tiger Who Came To Tea eschews the complexity of the supply chain and instead keeps the story at one level – at the level of the household of the protagonist Sophie (not to be confused with Sophie the Giraffe).

The premise of the story is the demand shock for supplies in Sophie’s home – a tiger comes home for tea and eats up everything that’s at home, drinks up all that’s there to be drunk (including “all the water in the tap”) and leaves, leaving nothing for Sophie and her family.

Assuming that the tiger will return the next day, Sophie’s family stocks up heavily, including “lots of tiger food”. And the tiger never arrives.

My guess is that the rest of the supply chain is left as an exercise to the reader – how the retailer who sold Sophie the tiger food will react to the suddenly higher demand for food (and for tiger food), how this retailer’s supplier will react, whether the tiger visits some other household for tea the next day (making this demand “regular” at the retailer’s level), and so forth.

Perhaps this is what makes this such as great book, and an all-time classic!

Government and markets

It’s been a while since I wrote a post like this one – I remember a decade ago, I used to flood my blog with such stuff.

In any case, last week, in response to the “10yearchallenge” meme, Nitin Pai of Takshashila wrote an Op-Ed in the Print on how India has changed in 10 years. While he admits that the country has grown and the lives of people has improved in some ways, the article leads with the headline that India should be be ashamed of what has happened in the last 10 years. This paragraph is possibly representative of the article:

While individual Indians seem to have done well over the past decade, India is more or less where it was. Worse, politics and policy priorities seem to have regressed to 1989.

Reading through the article (I encourage you to read it, it’s good – never mind the headline), I found a clear and distinct pattern in the kind of things where things have gotten better in India and where things have gotten worse.

Everything where markets function, or where the government doesn’t have much of a role, things have changed significantly for the better. Everything where the government has an outsized role, either because it is the government’s job or the sector is overregulated, things have gotten worse. So our cities have gotten more crowded. Infrastructure has gotten worse. Law and order has regressed. And this has had little to do with the party in power – whatever the government touched has regressed.

Looking at it in another way, Indians seem to be highly capable of making their lives better by coordinating using the invisible hand of the market. However, we seem incapable of making our lives better by coordinating using the government process.

From this perspective, there is one easy way to progress – basically reduce the government. Get rid of the overregulations. Get the government out of things where it shouldn’t be. Give a freer hand to the market.

Unfortunately, ahead of general elections this year, we see most parties taking a highly statist line. This is a real tragedy.

Back to methylphenidate

I can’t remember the last time I was unable to fall asleep. I mean I’ve lost sleep on several days in the last month or two, but on all occasions it’s been after I’d gotten woken up in the middle of my sleep. Today is different – it’s nearly 1 am, and I’ve been in bed for two hours tossing and turning, and completely unable to fall asleep.

I think I left it until it was a bit too late today to restart my methylphenidate, after a three year gap. The dosage is half of what I was used to in 2012-13 and 2015-16. Just 5 milligrams to be taken twice a day. This convinced me that it would be okay to take it in the afternoon. Big mistake. I’ve been completely unable to switch off this evening.

The good thing is that this afternoon ever since I took the tablet I’ve had the kind of hyperfocus I hadn’t been able to achieve for I don’t know how long. I continue to get distracted, but it’s easier to get back to where I was. The big change is that I no longer feel the constant need for stimulation. The need to “feel accelerated”, as I call it, which would result in my opening dozens of tabs on my browser and checking websites one by one without any need to do so. Sometimes it would end in the rabbithole of playing online chess, and wasting hours at a time.

I’ve written about ADHD before on this blog, and elsewhere. I’ve written it as a condition where you’re unable to hold attention on what you are doing, and getting distracted easily. In the past I’d come off medication because I missed being distracted – in my methylphenidated state, I have missed the ability to think laterally which I’m so capable of in my “ground state”.

Thinking about it, though, it’s not distraction or the lack of it that’s the problem with ADHD. It’s the constant need for “stimulus”. It’s the constant need to “keep doing something” that makes me fidgety. It’s possibly the same feeling that made me run out of class when I was in kindergarten and do somersaults. The same feeling that would make me open my computer and open a dozen chat windows upon coming home from work a decade ago. Well the latter had its good parts – a lot of the time, one of those dozen chat windows would involve the person who I later married.

It’s funny how I got here today, in this methylphenidated state. As you might know, I’ve been living in London for nearly two years now. And the medical system here is government-run.

In October 2017, when I was in the middle of my last (and largely unsuccessful) full time job, I felt the need to get back on to ADHD medication. I got an appointment with, and met my general practitioner in November 2017. He asked me to share with him my diagnosis of ADHD from back home. In December 2017 I was back in India, and I got back my medical records, and shared a copy with him in January 2018.

In February 2018 I got a call to set up an appointment with the mental health practice. It was at a clinic some distance away from home, and I met the psychiatrist in March 2018. I was administered the usual ADHD questionnaire and told that I would be contacted by the “national ADHD centre” in a “couple of months”.

It was finally in January of 2019 that I heard back about this. It was my GP once again, saying my prescription for methylphenidate was ready, and I should start taking it asap. The next day I got a call asking me to meet the psychiatrist again, in the faraway mental health clinic. And today I started taking the medication. And I’ve been so unable to switch off that I’m unable to sleep!

PS: I’m publishing this a day late. I wrote this last night but couldn’t publish it since daughter started crying and I had to rush back to bed. Hopefully I’ll be able to sleep well tonight

The problem with spider charts

On FiveThirtyEight, Nate Silver has a piece looking ahead to the Democratic primaries ahead of the presidential elections in the US next year. I don’t know enough about US politics to comment on the piece itself, but what caught my eye is the spider chart describing the various Democratic nominees.

This is a standard spider chart that people who read business news should recognise, so the appearance of such a chart isn’t big news. What bothers me, though, is that a respected data journalist like Nate Silver is publishing such charts, especially in an article under his own name. For spider charts do a lousy job of conveying information.

Implicitly, you might think that the area of the pentagon (in this case) thus formed conveys the strength of a particular candidate. Leaving aside the fact that the human eye can judge areas less well than lengths, the area of a spider chart accurately shows “strength” only in one corner case – where the values along all five axes are the same.

In all other cases, such as in the spider charts  above, the area of the pentagon (or whatever-gon) thus formed depends on the order in which the factors are placed. For example, in this chart, why should black voters be placed between the asian/hispanic and millennials? Why should party loyalists lie between the asian/hispanics and the left?

I may not have that much insight into US politics, but it should be fairly clear that the ordering of the factors in this case has no particular sanctity. You should be able to jumble up the order of the axes and the information in the chart should remain the same.

The spider chart doesn’t work this way. If lengths of the “semidiagonals” (the five axes on which we are measuring) are l_1, l_2, ... l_n, the area of the polygon thus formed equals \frac{1}{2} sin \frac{360}{n}  (l_1.l_2 + l_2.l_3 + ... + l_n.l_1). It is not hard to see that for any value of n \ge 4, the ordering of the “axes” makes a material difference in the area of the chart.

Moreover, in this particular case, with the legend being shown only with one politician, you need to keep looking back and forth to analyse where a particular candidate lies in terms of support among the five big democrat bases. Also, the representation suggests that these five bases have equal strength in the Democrat support base, while the reality may be far from it (again I don’t have domain knowledge).

Spider charts can look pretty, which might make them attractive for graphic designers. They are just not so good in conveying information.

PS: for this particular data set, I would just go with bars with small multiples (call me boring if you may). One set of bar graphs for each candidate, with consistent colour coding and ordering among the bars so that candidates can be compared easily.

High command and higher command

Last week a friend messaged me early in the evening and asked if we could meet for drinks later in the evening. I almost replied to him saying that I’ll get back to him once I’d “checked with High Command”, but then realised that I now have not one but two high commands.

Just the previous day, I had watched Liverpool FC play at Manchester City. This was the first time I was watching live football this season, primarily because we don’t have cable at home. Since I didn’t want to “jinx Liverpool“, I waited for a game where they were not the favourites to make my watching debut, and Manchester City away seemed like the best bet for that.

When I told the senior high command that I wanted to go watch this game, and if she could take care of the junior high command during the duration of it, she had no objections. Just as I was about to leave for the game, though, the junior high command (or maybe I should call her the higher command) decided to throw a tantrum. Some distractions and the promise to watch endless episodes of Bing and Pablo were required to allow me to step out.

The next day, I was pretty sure that the high command would be cool with me going out for evening drinks. We had discussed our lives at the turn of the year, and had agreed that we should meet more people, and I had specifically made it a point that I’d go out more on evenings and weekends. Still being early in the year, I knew the high command would be okay with me going out. I wasn’t sure if the higher command would be okay though.

The story played out the same way as the previous day. I picked up higher command from the nursery. High command then returned from office, and it was time for me to step out. And higher command wasn’t pleased at all. Once again it took distractions to allow me to step out. And it turned out that the price of the bribe was rather high that evening. When I returned, the higher command was watching Bing, and didn’t even turn around to look at me (normally she’s all over me when I come home from anywhere).

Another friend just asked me if we can meet on Wednesday evening. Again I was about to type “let me check with the high command”, and then decided it is prudent to make that plural. Once again I know the high command will be okay with this but the higher command may not be.

Training to be a quizzer

Eleven days before our daughter was born in September 2016, the wife and I attended the annual Family Quiz organised by the Karnataka Quiz Association. We ended up doing fairly well in the quiz, and placed third.

Unfortunately, despite the quiz having been described as “for teams of three and under from the same family”, we only got two book coupons as a prize. If they had given us three prizes instead, I could’ve claimed that our daughter won her first quiz even before she was born.

Two years and four months on, I’ve greatly disappointed my wife in terms of how much I’ve taught our daughter. According to some sort of an agreement we had come to ages back (maybe even before we were married), I was supposed to have taught our daughter calculus by now. As it happens, she can barely count to twenty, and still hasn’t fully got the concept of counting objects.

However, there are other areas of development where, despite me not putting any sort of effort whatsoever, she has done rather well in terms of her learning. I had written last month that she had proved adept at showing off her Quantum Physics for Babies in front of visitors. And before that she had shown promise by reading bus number boards.

Now, an anecdote from last night suggests she is already gearing up to be a quizzer.

Back in May, a friend and business associate gifted her this illustrated book of nursery rhymes (I don’t have the copy with me as I write this, but it was possibly this one). Since each page contains a full rhyme and maybe one or two illustrations, we don’t use the book too much – the daughter prefers books that have a higher picture-to-word ratio.

In fact, the fact that I’m not even sure what the book precisely looks like should tell you that we don’t use the book too often. Once in a while, my wife reads out poems from that just before bedtime, but I normally don’t read from it.

Anyways, last night as I was putting the daughter to bed, she picked out this book and asked me to read it to her before she fell asleep. And then she showed off her prowess as a quizzer.

Being two and a third years old, she can’t yet read (she knows the numbers and a few letters of the English and Kannada alphabets, but not much more). However, the way she was recognising the poems from the illustrations suggested that she was actually reading!

Guessing “Humpty Dumpty” by looking at an egghead sitting on a wall was rather easy. Some of the other poems she guessed correctly were, however, stuff I surely wouldn’t have  gotten from the illustrations. In fact, this included poems whose existence even I wasn’t aware of before I saw them in the book. I was so impressed that I didn’t really mind that she didn’t go to bed until it was eleven o’clock last night!

Now, this might be a false alarm. In the past she seems to have answered arithmetic questions correctly which later turned out to be a fluke. The sheer proportion of poems she got correct last night suggested this is not the case. The other doubt is that she might have seen the book elsewhere, and thus mugged up the picture-poem associations.

The way she was guessing, however, suggested to me that she was simply recognising the objects in the pictures and the actions they were exhibiting, and then working out the name of the poem from these figures and actions (obviously she knew it’s a book of rhymes, so the sample space was finite). And that is exactly how your mental process goes when you’re attempting a (good) quiz.

Now I don’t mind so much that she still has a long way to go before she can learn calculus.

Kader Khan and Slippery Fish

Until I read his obituaries, I didn’t know that the just-deceased actor Kader Khan was also a dialogue writer, having written the dialogues for several iconic Amitabh Bachchan movies such as Laawaris, Muqaddar Ka Sikander and Agneepath (I highly recommend his obituaries by GreatBong and by The Economist. Both are brilliantly written and highly informative).

When I found that Kader Khan wrote the dialogues for Agneepath, I was reminded of this old piece written by Nitin Pai, Director of the Takshashila Institution, that referenced a particular dialogue from Agneepath. In that, he talks about international relations and the “law of the jungle” that operates there. In fact, I recommend you see that dialogue from Agneepath. It’s on youtube:

Major level up in terms of my respect for Kader Khan after having re-watched this. I only knew him as a masterful comedian and actor as I mentioned. Now I want to go back and watch more of the movies for which he wrote dialogues.

In any case, if you watched the above video from Agneepath, you see that Amitabh Bachchan talks about the law of the jungle in the form of a food chain. I don’t know the Hindi names of animals precisely, but he talks about a frog being eaten by a snake, and a wolf being killed by lions, etc.

The talk of the food chain reminded me of another song which is my daughter’s favourite nowadays.  This talks about the marine food chain. Watch the song here:

I had no idea about this song until the daughter started singing it. In fact, since she liked the third stanza of the song best (“tuna fish, tuna fish”), it had also caused us a bit of a problem one weekend when she kept requesting for it but we couldn’t find it on any streaming service (you should ask for “slippery fish”).

I’m pleasantly surprised that they teach about the food chain to children as young as two years old, since it introduces to them the concept of death, and the fact that animals eat other animals to survive. Somehow I had thought that kids are told that all animals co-exist like they do in Peppa Pig (as an aside, I wonder what will happen to Peppa Pig and friends when it’s time for them to grow up and start dating), and that the concept of death is also taboo in some circles.

Anyway I’m glad my daughter likes the song. Maybe it’s time to let her graduate to the Amitabh Bachchan dialogue? But that would involve her learning Hindi, which is my wife and my “secret language” (when we’ve to say something we don’t want the daughter to understand) !

Podcasts to replace books

Yesterday I listened to an excellent podcast episode with Steven Pinker at Amit Varma’s Seen and Unseen podcast. In this, they discuss concepts from Pinker’s latest book Enlightenment Now.

Pinker is an author I’ve found difficult to read. Based on glowing recommendations, I bought his books The Stuff of Thought  and The Language Instinct a decade ago, but couldn’t get beyond the first ten pages of both, despite trying several times. As a consequence, I’ve declared that his writing style is not suited for me, and I won’t bother reading his books any more.

However, since I’ve heard good things about the book, listening to a podcast episode which covered the major concepts in the book was damn useful.

It is similar with poker player and author of Thinking in Bets Annie Duke. She’s highly regarded by the “finance twitter circlejerk” that I follow (I follow her as well), and she appears on several podcasts with members of this circlejerk. However, a friend whose opinions I trust told me that the book itself isn’t particularly great, and that there wasn’t that much in the book about thinking in bets per se.

A quick reading of the Kindle sample confirmed this hypothesis, so I didn’t bother with the rest of the book. Instead, I substituted for it by listening to a couple of podcasts that Duke has recorded, to get the best of her insights. This combined with following her on twitter, I don’t think I’ve done too badly.

I’ve found this “podcast trumping book” concept work in other cases and other ways as well. Beyond the first chapter, I found Ray Dalio’s Principles unreadable, but then I realised that I had got most of the concepts in the book from his podcast recording with Shane Parrish of Farnam Street.

Jordan Peterson’s 12 rules for life again is extremely insightful, but a very boring read. So for someone who doesn’t have the patience to plough through all his philosophy and religion stuff (which are weak compared to his psychology stuff which is incredible), I would just recommend that they listen to his podcast recording with Russ Roberts.

In some ways this takes me back to my old concept of how a lot of non-fiction books simply don’t have that much information content and just keep repeating the same points over and over. The antidote to this, I’ve argued, is to pack the book with a sufficient number of “side stories” so that there is more information packed in it. I think, and hope, that I’ve done this with my own book.

When an author records a podcast to promote a book, the intent is to get a potential reader to be attracted to the book, and hence the best concepts in the book get put out there. Also, as long as the podcast interviewer is good (Amit Varma, Russ Roberts and Shane Parrish are all very good podcast hosts), the podcast will never be boring and you’ll be able to get the information content in an easy way. So unless you want depth (I’m glad I ploughed through Jordan Peterson’s book since I found it has some depth, but not everyone would feel the same), just listening to the book-related podcasts should serve you well.

Oh, and I’ve recorded some five or six podcast episodes with Amit Varma’s seen and unseen podcast to discuss the book. I guess a lot of those listeners thought like me, so they didn’t bother buying my book!