Thursday, 30 May 2024

How to rule the universe: why I should have learned Git way earlier

A relevant xkcd:


When I first encountered Github as a wee lad, the only thing I knew was how to clone, pull, and push. If anything went wrong, I would genuinely delete everything and start over as I was sincerely clueless how this all worked. It seemed all too complicated. I'm glad I'm not the only one who felt that way.

Imagine my surprise when I work through learngitbranching, perhaps 10 years after seeing Git tools for the first time, and I learn that:

1. Branches are nothing but pointers. `main` branch? `bug_fix` branch? `$important_name` branch? Those are pointers to a commit, which is a node in a tree. Additional commits move the pointer along. At the same time, we can forcibly move the branch pointer to a different start point using `git branch -f `. Branches are like, just an idea.

2. `origin/main` is a remote branch that tracks `main` on the remote. The remote branch is stored locally: your `main` branch is compared with `origin/main` to figure out where new commits (either on remote or local) will go. We can even set `origin/main` to track a local branch that is named something else, like `foo` using `git branch -u`

3. merge and rebase: Merging creates a commit with two parents. This makes sense when merging with pull requests / new feature branches. This can be messy for navigating histories. Rebasing changes the start point for the branching commits e.g. if branch `main` is updated and we want those commits in our `dev` branch, we use a rebase to bring them over. In general. rebase lets us move commits around.

4. pull = fetch + merge. Even better, you can have a cleaner history if you `git pull --rebase`

5. It's all easier with tree view. Seriously. If you have a mental model that looks like this:

this will clearly beat whatever spaghetti you can see with git bash.

- which is probably why VS Code has a nice git tree and I should be using that. That's all for today. Happy surviving.



Monday, 27 May 2024

The briefest possible summary of The Anxious Generation by Jonathan Haidt

Interestingly, both Jonathan Haidt and Scott Galloway are faculty at the NYU Stern School of Business, and I've read both their books recently. I signed up for a book club (!) that was going to discuss The Anxious Generation and I've recently finished the book. A few thoughts:

We live in a world that allowed this to happen: In a world that made gas chambers, leaded petrol, chlorofluorocarbons, and uncontrollable amounts of climate change, perhaps it fits the pattern to have a few technology behemoths take control over the minds (via the attention) of not only an entire generation, but also much of communicable culture. It is also ironic that these technologies steal precisely the attention that would allow someone to realise these technologies' harms by disguising them as pleasure. 

It's not too late: Haidt strategically pushes to introduce four behavioural norms that solve collective action problems - namely, if my child doesn't have Instagram while everyone else in their class does, my child will be the outcast. Alternatively, if my social media company doesn't target 10-year olds, then this other company will and I'll lose out. These norms are: (1) no smartphones before high schools, (2) no social media before 16, (3) phone-free schools, (4) more independence, play and responsibility in the real world. All of these sound wonderful. I think we should have these norms for a start. Parents and school teachers are already worried about these things, which will help grassroot implementations of these norms.

Everyone needs a life outside - or, you should touch grass: Digital Minimalism by Cal Newport was presumably written for working adults - people who didn't grow up in the Anxious Generation. I'm someone who very much had my adolescent years immersed in social media. All I can say is: I think my life growing up would have been a lot better if everyone played with each other and went outdoors a lot more. I wasn't personally obsessed with technology use, but it was present insofar as it appeared to provide a social life that wasn't readily available in school. For a while, I've been trying to reconfigure my life to get those needs met, and I'm curious what new experiences I'll have.

This is an interesting and important book. Even though the story sounds old - a new technology is bad for people - we must recognise that there is a difference not in degree, but in kind. No previous technological development has had the same capability to assault our attention and dopamine circuits as much as smartphones coupled with social media. I'll want to write about this book again with more nuance and detail, but that's for a subsequent day. Until then, happy surviving.


Sunday, 26 May 2024

Fooled by the Winners - David Lockwood

Nassim Taleb's book 'Fooled by Randomness' tackles epistemological questions. What do we know, and what do we not know? This is interested in questions like survivor bias, black swan events, and how random noise is subject to human interpretation and given meaning (see: much of business news, possibly journalism, history, finance, academic publishing involving statistics). 

David Lockwood writes a similarly fascinating book, 'Fooled by the Winners' (Winners), which is singularly focused on the question of survivor bias. The cover of the book features a WW2 airplane, engulfed in smoke and falling from the sky, bringing this lovely image to mind:


For a process that generates survivors and non-survivors, we obtain information from survivors without hearing from the non-survivors, which is discussed in Part I of Winners. This discusses survivor bias in anti-aircraft fire, hedge funds returns, the results of academic publishing that hit a threshold for statistical significance, medical trials, and start ups. 

Part II of Winners is concerned with a slightly bigger questions. What happens when we (the knower) are part of the survivor group without direct knowledge of non-survivors? This delves into bigger existential questions, pertaining to whether life is likely to continue on Earth, and Fermi's Paradox, which has to do with our non-observation of extra-terrestrial life. Part II tackles the nuclear crisis, and the bizarre strokes of luck that allowed civilisation to not evaporate in smoke - that we are able to write about this now is precisely survivor bias. 

It is also interested in the question of climate change - that we've managed to alter the climate so much without catastrophe yet is by no means suggestive that we can continue to do so. If a catastrophe did happen, we wouldn't be here to write about it. Past behaviour does not imply future behaviour, and chances are that it might happen anyway. Bummer. 

I enjoyed this book - it was right up my alley, and it was well written with great links between chapters. I have a specific complaint about academia (relating to survivor bias) that I will write about some other time. Until then, happy surviving.

Wednesday, 22 May 2024

A weird mistake I made a while back

Back when I was working in a seismology lab, I was told to write my own gridsearch procedure as a pedagogical exercise. For context, each physical station receives a seismic signal at timestamp t. However, we don't know how far away the earthquake is, along with the travel time.

To figure that out, we look at the P and S wave arrival times (example): since these two waves travel at different speeds, we can guess what the speed difference is, and hence guess the travel time. 



Given 3 travel times, a guess at the difference between P and S waves, and the strong assumption that earthquakes cannot happen in the sky, we can locate the event center (hypocenter) and its event time. The guess doesn't have to be super accurate - the locations are improved iteratively.

To write a gridsearch program, I computed the theoretical timing misfit for all boxes in a large volume. I made the mistake of assuming Cartesian coordinates instead of using distance calculations for spheres (weird, I know). Subsequently, I obtained misfit contours that looked a little off.



Given that RMS error (the misfit value) is a smooth convex function of distance, it was weird that some circles would look like they have extra error. 

The reason had to do with floating point division and the difference between `round` and `int` - a postdoc in my group figured this out by looking at my data files that were used to interpolate between pre-computed travel times - some of the travel times were blank (default 0).

 



This was not my finest moment. This meant that for my travel time computations, I had some entries which weren't filled, messing up the interpolation, and giving odd looking contours in the colourmap above. 

The first lesson was to perhaps pay attention to how floats are cast. The second lesson was about the importance of code review, which was a mostly alien concept to me. It has to do with the group culture, perhaps - the way they deal with technical debt and operational efficacy.

Tuesday, 21 May 2024

Digital Minimalism by Cal Newport

I first heard about Cal Newport through an episode of 10% Happier that discussed his latest book, Slow Productivity. I might read more of that later next month. I chanced upon Newport's earlier book, Digital Minimalism, published in 2019. I thought I had a good grasp on the hows and whys of approaching technology use, but I turned out to be wrong. A few pointers I picked up:

It's designed this way: Snapchat, LinkedIn, and Instagram were founded by students of a Stanford psychology class. Human brains are easy to manipulate to begin with (cognitive biases). Stack that on top of screens that connect you to a virtual reality and slot machine-style design: pulling down to refresh, pops, little red notification lights, unpredictable "social interactions" - dopamine hit after dopamine hit. 

That being said, it's not that useful to see tech use as an addiction. At worst (or best, if you are in the business of making these things), tech use is a medium-intensity addiction - getting off Instagram probably won't give you physical withdrawals that a smoker or workaholic might get (I'm now imagining a fidgety 9-year old who cannot get their hands off their phone). Rather, Newport takes pains to point out that mitigating the harms of technology use depends on how you use it, without doubling down on the banal perspective of "it just depends". To that end, the book asks us to think intentionally about what we use and how we use it.

Use technology with intention: A digital detox asks us to get away from our phones for say, a month. This is the abstention perspective - we experience a hole in our lives during that month, and we resume using our phones after that month. 

Let's suppose instead that we think carefully about what we use our phone for, and what sort of needs that it might meet. We will then want to ask how we can meet those same needs without using our phones all that much. For instance, perhaps we value social connection with our friends - we want to stay updated on what they're doing. Instead of scrolling through their Instagram Stories, we could schedule a time to meet them in person to catch up - the skin and bone encounter is way more valuable.

By thinking about what we get out of using technology and the needs that it meet, we can see how they fit into our lives. This gives us the space to think about our needs, and to use technology in more limited and specific ways to meet our needs.

Build a life worth living: It's probably no coincidence that the decline of organised community and public life (see: Bowling Alone) facilitates a shift towards the "connection" over the "conversation" - the vague feeling of having been social, without taking on the risk and interaction. There is a void in our lives that social media use fills (as a major subset of technology use). 

The book asks us to do things with our hands and get in touch with the real world, and gives metalworking, taking walks, and playing the guitar as examples. That's pretty male-coded; I could see crochet, cooking, and doing the housework as examples of doing things with your hands too.

The book also asks us to take part in structured social activities. While we don't necessarily have to go to church, we can join communities (CrossFit, board gaming, book clubs), or even make them ourselves (giving the example of Ben Franklin, though meetup.com would be a pretty good example today). By giving ourselves the opportunities for thick social interactions where we have to read complex social cues, we exercise the social part of our brain, which happens to be our default brain. This meets the need that social media initially promised to fill, and hence sets us free from its grasp.

This tackles the heart of the problem - we are social beings that need a social life. While we could duct tape over some of it with social media, it doesn't really plug the whole. We can't confront and reduce technology use if we don't think of way to meet our own needs. 

This is an interesting book, and offers many suggestions that can be put into practice. I'll try some of them (quarterly and weekly plans, dumbphone, structured social activities, crafts, walks) and see how it goes.

Monday, 20 May 2024

Monkeys, slot machines, and mindfulness

A story I heard from Radiolab: William Schultz et al. (1993) gives juice to monkeys, and learns that the dopamine in monkey brains are initially coincidental with the juice giving. Over time, the dopamine spike shifts earlier and earlier in response to cues that come before the juice giving - when the room light turns on, or when the researchers' footsteps are audible in the hallway.

My reading of this story: as animals, humans too, are wired to anticipate rewards. Dopamine is not simply a reward chemical, but primes us (our monkey brains) for nice rewards (juice). We daydream about success - a mate, the admiration of our peers, lunch, or having croissants - way before any of those happen. We are wired to think about the future, and it is real work to live in the present (mindfulness).

The second idea: reward variability feels amazing. When we pull a slot machine, we anticipate a reward that is variable, since slot machines are programmed to have negative expectation value, while appearing to give random outcomes. When the numbers land on a special combination, the lights and sounds go off, and coins start to trickle out from the machine (I think? I've not played slots before). 

It turns out that our brain really loves variable rewards - we want to figure out the pattern behind them so that we can get more of the reward (a mate, admiration of our peers, lunch, or having croissants). This is also the basis of addiction - we have an irresistible itch (anticipation) for an action (say, pulling a slot machine, checking your phone, playing a video game) that gives rewards (money, social standing, croissants).

All this to say that we really are so many monkeys chasing so many rewards in our careers, schools, online forums, and video games. Some are more useful than others - some of these even help you pay the bills. What I would like to reflect on is our wonderful capability to be so caught up in this world - this is a nice angle to start thinking about mindfulness and being in the present. 

As creatures of anticipation, we receive our object (juice), and start to anticipate the next reward. The point is to sit down and drink the juice - this is not a call to enter a stupor of self-reflexivity and not achieve anything in your life. Rather, it is an invitation (to myself, mostly) to sit back and think critically about what drives us, what gives us meaning, and what orientates and moves us as we exist in this world. 

Dan Harris, in his book 10% Happier, relates the story of a meditation teacher who tells his students to be simple. The narrator then observes the teacher screaming red-faced at a biscuit seller who the teacher believes to be overcharging him. When asked, the teacher says: be simple, not a simpleton.  

The point is to be simple. Achievement, focus, and success are alright. They are desirable. I should apply ourselves to what I do. At the same time, there must be a way to be less caught up with the whims of the world - to experience the present moment more clearly, and to act wisely. To be simple, but not a simpleton. 

Sunday, 19 May 2024

A sketch of topics I'd cover in a graduation speech

I haven't had quite enough opportunities to be self-aggrandising in front of large crowds. In preparation for a hypothetical session at the podium, I'd give the following advice, informed by a few books I've read (How to Fail at almost everything by Scott Adams, Algebra of Wealth by Scott Galloway, Fooled by Randomness by Nassim Taleb).

Passion sucks because of survivorship bias: passion was never a reason why successful people succeeded. Postdocs are typically passionate - not all of them become a tenured academic. Interns in investment banking are typically passionate - not all of them will obtain a return offer. Most entrepreneurs are passionate - most of them will fail their first few startups too. People who tell us that passion matters are survivors who do not know the non-survivors. Look at the entire population to see what matters.

Figure out your talent, and talk to many people: If passion doesn't matter, we should figure out what we're good at (our talent) by trying many different things. This exposes us to rejection (good practice) and gives us novel information on what we're good at. On that theme, we should talk to many people to ask for guidance on what we'd like to do. I reached out to so many people to talk about graduate school, which was incredibly helpful since all the information I obtained told me to do anything else. There's a fear of rejection associated with talking to new people - we welcome rejection in search of useful connections and conversations.

Protect your attention and energy: we exist as finite and cranky human beings. However, a legion of Silicon Valley tech prophets is hiring psychologists and conducting endless A/B tests to figure out how to hack your attention - emotionally charged and depressing news, infinite updates from people you barely know, and short-form videos supercharged by algorithmic selection. Your attention and energy are the most important things you have, and the only person who can take care of yourself is you - billion-dollar companies are uniquely unsuited for that task. To that end, reduce the clutter in your digital life (Digital Minimalism by Cal Newport). Stay healthy, exercise, and go on walks. Manage the amount of energy you have to live the life you want.

These main beats should be appropriate in an advice-giving setting. That being said, I think there's so much more to talk about for survivorship bias - it represents a sort of anti-knowledge in forcing us to pay attention to what we cannot see and what we cannot know.