Computer science and psychology

This morning, when I got back from the gym, my wife and daughter were playing 20 questions, with my wife having just taught my daughter the game.

Given that this was the first time they were playing, they started with guessing “2 digit numbers”. And when I came in, they were asking questions such as “is this number divisible by 6” etc.

To me this was obviously inefficient. “Binary search is O(log n)“, I realised in my head, and decided this is a good time to teach my daughter binary search.

So for the next game, I volunteered to guess, and started with “is the number \ge 55“? And went on to “is the number \ge 77“, and got to the number in my wife’s mind (74) in exactly  7 guesses (and you might guess that \lceil log_2 90 \rceil (90 is the number of 2 digit numbers) is 7).

And so we moved on. Next, I “kept” 41, and my wife went through a rather random series of guesses (including “is it divisible by 4” fairly early on) to get in 8 tries. By this time I had been feeling massively proud, of putting to good use my computer science knowledge in real life.

“See, you keep saying that I’m not a good engineer. See how I’m using skills that I learnt in my engineering to do well in this game”, I exclaimed. My wife didn’t react.

It was finally my daughter’s turn to keep a number in mind, and my turn to guess.

“Is the number \ge 55?”
“Yes”

“Is the number \ge 77?”
“Yes”

“Is the number \ge 88?”
“Yes”

My wife started grinning. I ignored it and continued with my “process”, and I got to the right answer (99) in 6 tries. “You are stupid and know nothing”, said my wife. “As soon as she said it’s greater than 88, I knew it is 99. You might be good at computer science but I’m good at psychology”.

She had a point. And then I started thinking – basically the binary search method works under the assumption that the numbers are all uniformly distributed. Clearly, my wife had some superior information to me, which made 99 far more probable than any number between 89 and 98. And s0 when the answer to “Is the number \ge 88?”turned out to by “yes”, she made an educated guess that it’s 99.

And since I’m used to writing algorithms, and  teaching dumb computers to solve problems, I used a process that didn’t make use of any educated guesses! And thus took far many more steps to get to the answer.

When the numbers don’t follow a uniform distribution, binary search works differently. You don’t start with the middle number – instead, you start with the weighted median of all the numbers! And then go on to the weighted median of whichever half you end up in. And so on and so forth until you find the number in the counterparty’s mind. That is the most optimal algo.

Then again, how do you figure out what the prior distribution of numbers is? For that, I guess knowing some psychology helps.

 

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.