Songs for sleeping

As I write this, Berry is fast asleep next to me. It took a long time, and a fair amount of effort, to get her to sleep, as has become the routine everyday. Finally, she fell asleep as Pink Floyd’s Comfortably Numb was playing. This was no coincidence. This is part of a careful sleeping routine I’ve developed over the last month.

It started with a bit of what I can describe as “reinforcement learning”. We were on the way to the airport sometime last month and Berry was getting cranky in the cab, so I started singing to her. On a whim I started singing Pink Floyd songs (maybe because I know the lyrics of a lot of them). She passed out halfway through Wish You Were Here. A couple of hours later on the flight, she felt drowsy during the same song, and then slept when I started singing Comfortably Numb.

So every time I found that she would sleep to a particular song, I started singing that the next time I was putting her to sleep. Obviously it didn’t work like that – her falling asleep was a random event, which I chose to infer was a cause of my singing. And I’m someone who gives lectures on not mistaking correlation for causation.

Singing got tiring, so soon enough I had created a playlist. The playlist to which she invariably falls asleep every day nowadays is called “lullabies“.

Here is what it looks like.

Now, you might just think that it’s a random list of Pink Floyd songs, with one LedZep song thrown in. It’s not. The songs have all been carefully selected.

The first set of songs have been chosen because they are heavy on lyrics, don’t have long instrumentals and are easy to sing along to. These are songs that play when Berry is about to fall asleep, and I sing them while patting her. And invariably she falls asleep during this time.

The next few songs are long soothing songs, that will keep her asleep until she gets into deep sleep. As I write this, Atom Heart Mother is playing.

But getting Berry to sleep is not easy. I don’t start the evening with these lullabies – they come in only when I know that Berry is sufficiently sleepy and will sleep in the next 10-15 minutes (like the closer in Baseball). When she comes into the bedroom, I start with this playlist that I created a couple of months back, and which I had then named as “Berry’s Education“. 

As you can see, Black Sabbath’s Iron Man heads this list. It is Berry’s favourite song. In fact, when she gets on to the bed, she says “has he lost his mind, appa”.

This playlist is not intended for sleeping, and I randomly choose a few songs to play. When Berry gets into the next stage of her slumber, where she is now ready to sleep, but not sleepy enough, she needs some lullabies. And it’s the time for Iron Man again, except this time it’s the version by RockaBye Baby.

This is the song she used to fall asleep to when she was a baby, from the time when she was barely a couple of days old. And from there I let the album play for a while until she is really ready to sleep. Which is when the lullabies playlist takes over.

As you might imagine, having multiple playlists is a pain. I normally use the kinda old iPad4 to play, and changing playlists means entering my passcode, going up one folder and then going into another playlist. You might wonder why I haven’t created one integrated playlist.

The reason is randomness, on two counts. The amount of time Berry takes to pass each stage of sleepiness is variable. So I don’t know how long I will have to play each kind of music. Also, she is moody and the way she reacts to each kind of music is a bit random. So I need to switch back and forth between the kinds of music, and so having multiple playlists is better.

On good days, I will have my phone with me, which makes it easier to switch playlists (one hand operation, touch ID to login etc) – though it’s invariably the iPad that plays the music.

So as you might have figured out, putting babies to sleep is not an easy task, which is why I’m sharing my method with you, in the hope that it might help you. What do you do to make your baby sleep?


The utility of utility functions

That is the title of a webinar I delivered this morning on behalf of Kristal.AI, a company that I’ve been working with for a while now. I spoke about utility functions, and how they can be used in portfolio optimisation.

This is related to the work that I’ve been doing for Kristal, and lies at the boundaries between quantitative finance and behavioural finance, and in fact I spoke about utility functions (combined with Monte Carlo methods) as being a great method to unify quantitative and behavioural finance.

Interactive Brokers (who organised the webinar) recorded the thing, and you can find the recording here. 

I think the webinar went well, though I’m not very sure since there was no feedback. This was by design – the webinar was a speaker-only broadcast, and audience weren’t allowed to participate except in terms of questions that were directly sent to me.

In the first place, webinars are hard to do since it feels like talking to an empty room – there is no feedback, not even nods or smiles, and you don’t know if people are listening. In most “normal” webinars, the audience can interject by raising their hands, and you can try make it interactive. The format used here didn’t permit such interaction which made it seem like I was talking into thin air.

Also, the Mac app of the webinar tool used didn’t seem particularly well optimised. I couldn’t share a particular screen from my laptop (like I couldn’t say “share only my PDF, nothing else” which is normal in most online chat tools), and there are times where I’ve inadvertently exposed my desktop to the full audience (you can see it on the recording).

Anyways, I think I’ve spoken about something remotely interesting, so give it a listen. My “main speech” only takes around 20-25 minutes. And if you want to know more about utility functions and behavioural economics, i recommend this piece by John Cochrane to you.

Linearity of loyalty rewards

So I’ve taken to working a lot in cafes nowadays. This is driven by both demand and supply. On the one hand I’ve gotten so used to working for my current primary client from home that I’m unable to think about other work when I’m at home – so stepping away helps.

Also on the demand side is the fact that this summer has been incredibly hot in London – houses here are built to trap in the heat, and any temperature greater than 25 degrees can become intolerable indoors. And given that cafes are largely air-conditioned, that’s an additional reason to step away from home to work.

On the supply side, there are three excellent hipster cafes within 200 meters of my house. Yes, I live in a suburb, though my house is very close to the suburb’s “town centre”. And all all these cafes make brilliant coffee, and provide a really nice ambience to work.

So far I’ve discovered that two of these cafes offer loyalty cards, and given my usage, neither makes a compelling reason to be loyal enough. The “problem” (in terms of retaining my loyalty) is that the loyalty card at both these places offer “linear rewards”.

Harris+Hoole has an app, which offers me a free drink for every six drinks purchased. Electric Coffee has a physical card, which offers me a free drink for every ten drinks I purchase. Now, the rate of reward here (I’m writing this sitting in Electric) is lower, which suggests that I’m better off patronising Harris+Hoole, but some variety doesn’t hurt – also I’m queasy about ending up and parking in the same cafe more than once in a day.

Even when I was writing my book in Barcelona two years ago, I would never go to the same cafe more than once a day, alternating between Sandwichez, Desitjos and this bar whose name I could never figure out.

Ordinarily, if I were a low intensity user, one drink for every N drinks ($math 6 \le N \le 10 $) would have been a sufficient reason to be loyal. Given my rate of consumption, though, and the fact that I go to both these cafes rather often, the incremental benefit in staying loyal to one of these cafes is fairly low. I can peacefully alternate knowing that sooner or later the accumulated ticks on my card or app are going to provide their reward.

It wasn’t like this last year, when I was briefly working for a company in London. Being extremely strapped for time then, I hardly patronised the cafes near home, and so the fact that I had an Electric card meant that I stayed loyal to it for an extended period of time. At my higher level of usage, though, the card simply is not enough!

In other words, rewards to a loyalty program need to be super-linear in order to retain a customer beyond a point. The current linear design can help drive loyalty among irregular customers, but regulars get indifferent. Making the regulars really loyal will require a higher degree (no pun intended ) of rewards.

PS: Given the amount of real estate hours I occupy for every coffee I buy, I’m not sure these cafes have that much of an incentive in keeping me loyal. That said, I occasionally reward them by buying lunch/snacks or even a second coffee on some visits.

PS2: As a consumer, loyalty card versus app doesn’t make that much of a difference – one clutters the wallet while the other clutters the phone (I don’t like to have that many apps). A business, though, should prefer the app, since that will allow them to know customers better. But there’s a higher fixed cost involved in that!


Scott Alexander, Bryan Caplan and Nitin Pai on fighting crime (feat. Matt Levine)

The basic idea is that coming down hard on a small number of high-profile crimes can have disproportionate effects in terms of curbing crime

It all started with the pseudonymous blogger Scott Alexander, in what seemed like a justification of outrage. Or maybe it started earlier – with a post by Bryan Caplan deploring outrage. Caplan was commenting about the propensity of people to jump on to bandwagons deploring seemingly minor crimes while not caring enough about worse crimes that were not in the public spotlight already. Caplan had then written:

I can understand why people would have strong negative feelings about the greater evil, but not the lesser evil. But I can’t understand why people would have strong negative feelings about the lesser evil, but care little about the greater evil. Or why they would have strong negative feelings about one evil, but yawn in the face of a comparable evil.

Now, while “Alexander”‘s response seems to justify outrage (and I’m no fan of online outrage), he did so with an interesting analogy, on how to curb crime when the police has limited resources. He writes:

[…] the police chief publicly commits that from now on, he’s going to prioritize solving muggings over solving burglaries, even if the burglaries are equally bad or worse. He’ll put an absurd amount of effort into solving even the smallest mugging; this is the hill he’s going to die on.

Suppose you’re a mugger, deciding whether or not to commit the first new mugging in town. If you’re the first guy to violate the no-mugging taboo, every police officer in town is going to be on your case; you’re nearly certain to get caught. You give up and do honest work. Every other mugger in town faces the same choice and makes the same decision. In theory a well-coordinated group of muggers could all start mugging on the same day and break the system, but muggers aren’t really that well-coordinated.

The police chief’s public commitment solves mugging without devoting a single officer’s time to the problem, allowing all officers to concentrate on burglaries. A worst-crime-first enforcement regime has 60 crimes per day and solves 10; a mugging-first regime has 30 crimes per day and solves 10.

And then it is again Caplan’s turn to respond. I’m bad at detecting satire, so I’m not sure if he is being serious (I don’t think he is). But he proposes a “sure fire way to end all crime”:

Step 1: Credibly announce that all levels of government will mercilessly prosecute the firstcrime committed in the nation each day.

Step 2: There is no Step 2.

But then, I’m sure that Nitin Pai is being serious in proposing a similar method to curb the spate of violent crime in India based on WhatsApp forwards. In his piece for the Quint, he writes:

the Home Ministry ought to use its considerable powers to tackle the problem. It’s not hard either. One well-advertised arrest, prosecution and sentencing will deter the cowards that comprise lynch mobs. Three high profile arrests and prosecutions – and see how quickly lynchings stop. The smallest police station in the remotest village can stop lynchings if the local sub-inspector has received clear political messages against it.

Finally, the reason why I figured Caplan’s “solution” is satire is because of this passage from Matt Levine’s excellent Money Stuff newsletter (likely it’s behind a Bloomberg paywall, but it’s free if you subscribe by email). Commenting about high frequency trading, Levine writes:

But the answer in actual U.S. market structure is, come on, there is no such thing as “the same time.” Do you know how many nanoseconds there are every single second? (A billion.) The odds that each of us would hit the “Buy” button at the exact same nanosecond are infinitesimal. So if I put in my order to buy the stock at 10:45:06.543210876 a.m., and you put in yours at 10:45:06.543210987 a.m., then I got there first and I win.

Is this a good answer? It has a simple appeal. It just gets rid of the question “who gets the stock if we put our orders in at the same time?” It replaces an economic question about how to allocate the stock with an empirical question of who got there first.

So the problem with fighting the first crime of the day, or year, or whatever, is that a criminal will know fully well, given a reasonably high enough crime rate, that the probability of his crime being recorded as the first in the year or day or whatever is less than one. And the higher the crime rate, the lower the probability that his crime will be recognised as the first one. And so there is a high chance he can get away with it.

And that is where Nitin’s idea scores. Rather than going after the “first crime”, pick a few crimes arbitrarily and “go after them like hell”. Since in this case most of the people who are forwarding dangerous forwards are “ordinary people”, this will likely shake them up, and we’ll see less of these dangerous forwards.

Cross posted from Pragati Express

Why AI will always be biased

Out on Marginal Revolution, Alex Tabarrok has an excellent post on why “sexism and racism will never diminish“, even when people on the whole become less sexist and racist. The basic idea is that there is always a frontier – even when we all become less sexist or racist, there will be people who will  be more sexist or racist than the others and they will get called out as extremists.

To quote a paper that Tabarrok has quoted (I would’ve used a double block-quote for this if WordPress allowed it):

…When blue dots became rare, purple dots began to look blue; when threatening faces became rare, neutral faces began to appear threatening; and when unethical research proposals became rare, ambiguous research proposals began to seem unethical. This happened even when the change in the prevalence of instances was abrupt, even when participants were explicitly told that the prevalence of instances would change, and even when participants were instructed and paid to ignore these changes.

Elsewhere, Kaiser Fung has a nice post on some of his learnings from a recent conference on Artificial Intelligence that he attended. The entire post is good, and I’ll probably comment on it in detail in my next newsletter, but there is one part that reminded me of Tabarrok’s post – on bias in AI.

Quoting Fung (no, this is not a two-level quote. it’s from his blog post):

Another moment of the day is when one speaker turned to the conference organizer and said “It’s become obvious that we need to have a bias seminar. Have a single day focused on talking about bias in AI.” That was his reaction to yet another question from the audience about “how to eliminate bias from AI”.

As a statistician, I was curious to hear of the earnest belief that bias can be eliminated from AI. Food for thought: let’s say an algorithm is found to use race as a predictor and therefore it is racially biased. On discovering this bias, you remove the race data from the equation. But if you look at the differential impact on racial groups, it will still exhibit bias. That’s because most useful variables – like income, education, occupation, religion, what you do, who you know – are correlated with race.

This is exactly like what Tabarrok mentioned about humans being extremist in whatever way. You take out the most obvious biases, and the next level of biases will stand out. And so on ad infinatum.

Jordan Peterson’s Chapter Eleven

So I read Jordan Peterson’s 12 Rules For Life last month. It took a bit of an effort, and there were a couple of occasions when I did wonder if I should abandon the book. However, my stated aim of reading at least 50 books this year made me soldier on, and in the end I’m glad I finished it. Especially for Chapter Eleven of the book (Do not bother children when they are skateboarding).

Now, this is a long chapter, and Peterson spends considerable time rambling about various controversies he has got involved in over the last few years – such as his stand on political correctness, or his stand on environmentalism (in fact, he has an interesting take on the latter – that environmentalism and climate change worries have an adverse impact on mental health of people, so I didn’t mind reading him on that!).

The chapter is about risk – one thought (which has also been expressed by Nassim Nicholas Taleb in one of his books – which one I can’t remember), is that people have a “natural level of risk”. And if you, for whatever reason, prevent them from taking that risk, they will find other ways to take risk, perhaps indulging in riskier activities.

And in order to explain why we are fundamentally wired to take risk, Peterson talks about gender, and relationships. He talks about friend-zoning, for example:

Girls aren’t attracted to boys who are their friends, even though they might like them, whatever that means. They are attracted to boys who win status contests with other boys.

And winning these status contests involves taking risk! Peterson goes on about relationships, about the crisis in the United States nowadays where women are more educated than men (on average), and then choose to remain single rather than “marrying down”.

This is the bit which really caught my attention – the apparent contradiction between the desire for women to do well, and this desire resulting in their not being able to find partners for themselves. And there are no easy solutions here. The desire for a woman to “marry up” is biological, and nobody can be faulted for being ambitious and wanting to do well for themselves in life.

Now, it is easy to go all ad hominem about this argument, calling Peterson a chauvinist and a traditionalist (as his opponents, mostly on the political left, have done), but the problem he mentions is real, and as the father of a (rather young) daughter, it hit hard for me – obviously I want her to do really well in life and make a mark professionally; but I also want her to propagate my genes, and do a good job of that.

I’m hopeful that as the daughter of Marriage Broker Auntie, she’ll be able to sort things out. But them, she may not want to listen to her mother – at least in these matters!

There were other places where the book was really inspirational. Chapter Twelve had a simple message – that there are times when you go through shit, and a way to get through them is to appreciate the smaller joys of life. In fact, Peterson is at his best when he talks about clinical psychology – which is the topic of his everyday research.

He does a fantastic job in Chapter One as well, and I may not be exaggerating by saying that the chapter was thought-provoking enough to make me analyse how I might have ended up with depression, and then make a conscious effort to avoid those actions that either betrayed depression, or made me feel more depressed. And that makes me get why people contribute so much to him on Patreon. Some of his advice can indeed be life changing.

However, I have no plans to pay him anything more than the £9.99 I paid Amazon for the book. And that is partly because the psychology parts of the book are indeed brilliant, he frequently goes on long rambling thoughts on religion (Christianity in particular, since that is the religion most familiar to him) and philosophy. And in those parts (there’s an especially long sequence between chapters 7 to 10 of the book), the book gets incredibly laboured and boring.

I recommend you read the book. The clinical psychology parts of it are nothing short of brilliant. There’s a lot of religion and psychology you will need to go through as well, and I hope you find more insight there than I managed to!

Here are the notes and highlights I made from the book.


Beer Gardens

A lot of “local” pubs in London advertise that they have a “beer garden”, which is usually a grassy backyard that has a few outdoor tables. Having been to Munich, though, I would claim that these guys (in London) don’t know what they are doing, or at least that they can’t do it at scale.

On Friday evening we met a friend from IIT who has recently moved to Munich. Considering that there would be “a lot of kids” (three of his, along with Berry), he suggested that we meet at this particular “beer garden“, which was on the outskirts of town, a small distance away from the Isar river.

We got there following a ride in the metro followed by a tram ride and then a ten minute walk. And what a place it was. It was a massive ground in what appeared to be the middle of a forest, with one massive screen set up in one corner to show the Football World Cup. The entire ground was filled with long tables (eight of us (four adults and four kids) could easily fit in on one of the smaller tables), and on the edges there were play area for the kids.

The highlight of the place for us was that on a rare occasion of dining out, we didn’t need to worry that much about the kids. There were no high chairs for them to sit on, but we didn’t need to bother keeping them in one place, given the play areas and the gravel-lined ground that made it conducive for them to run around.

There was no table service for food and drink – there were a number of stalls at one end of the garden, where you could buy food and drink and get them to your table. After eating, it was your responsibility to clear your table and deposit used dishes at a central area (this was similar to other “self-service” restaurants in Munich). Food was mostly typical Bavarian fare, and it was pretty good. Once again, I overate.

In one sense, the upside of the lack of table service is that it eliminates the problem of how to split bills. Each person/ family can go get what they want, and eat and drink comfortably without the fear or under or over-ordering, and what others would think of them. And freed from both keeping kids in check and wondering about dynamics, and fueled by beer, you can focus on the conversation!

After dinner, we went down to the Isar river. It was already getting dark on our way down the wooded path to the river, but when we reached the river, it was suddenly bright again! Unfortunately it was getting dark, so we couldn’t spend too much time there, but it was a fantastic experience being there. It was already dark by the time we were walking back to the beer garden, and our path was lit up by fireflies!

We were wondering why this concept hasn’t travelled, not even till Britain. I mean, we have beer gardens here, but none at this scale. And most restaurants here rely on keeping kids tied in to their high chairs, colouring into the restaurant’s advertising material, rather than giving them a run about (which can potentially make them more hungry and make them eat more!).

One reason why beer gardens don’t travel is that they work well at scale, and that kind of real estate is hard to come by in most cities. Another is cultural – in India, for example, a lot of people don’t like drinking with their families, so places that combine drinking with kids’ play areas may be taboo. I can’t think of any more! Can you?

That said, when you visit Munich, don’t forget to go to one of the beer gardens (there are two massive ones in the middle of the city itself, in the middle of the English Gardens). It’s quite an experience!