Wednesday, September 21, 2016

Loser's Game

If you ask students who the "smartest" kid in their class is, it is likely that the person they identify is not the class topper (in terms of GPA). Why?

Toppers are superb test takers. They have mastered the art of error minimization. Sure, they are smart, and they prepare hard. So do many other students. What distinguishes them is caution, and an obsession with avoiding stupid mistakes.

They may not offer the most enterprising solutions to hard problems, or be thought of as the most "creative" people (whatever that term means). But they are good at one thing: controlling error!

Controlling error is important! In many disciplines like accounting, building bridges or spaceships, computer programming etc. it is perhaps the most important thing.

"In Winning the Loser's Game", Charlie Ellis (pdf) talks about difference between amateur and professional tennis. In professional tennis, the winner is the player who outplays the other. Generally, the more skillful player wins.

In amateur tennis the game is not decided by who hits more winners. Rather the winner is the player who makes the least mistakes - commits fewer double faults, hits fewer shots into the net, etc.

He makes an interesting point that investing is also like that. Unless you are a professional, don't swing for the winners. Instead, focus on controlling the things that you can control, and the rest will take care of itself.

Monday, September 19, 2016

On the Political Economy

Many people are not thrilled with the choices available this year's presidential election cycle. Given our moribund Congress, it is easy to get pessimistic.

However, I've been reading a number of interesting proposals to fix the deadlock in our political system.

1. Howards Marks on "Political Reality" (pdf)

I find his take compelling. I think "moderate" and "compromise" are positive words/attributes. Towards the end of the document Marks offers some prescriptions for where to begin. The proposal try to make it easier for moderates, and centrists to win elections.

2. Terry Moe on EconTalk...

... offers a different diagnosis, and a radically different medicine: a stronger presidency.
With some exceptions, Congress has never been capable of crafting effective policy responses to the nation’s problems, a fact that is well documented. Polarization has made a bad situation worse, but it is not the underlying cause of Congress’s core inadequacies—which are baked into the institution and not of recent vintage. Congress is an ineffective policymaker because it is wired to be that way by the Constitution, whose design ensures that legislators are electorally tied to their local jurisdictions and highly responsive to special interests. Congress is not wired to solve national problems in the national interest. It is wired to allow hundreds of parochial legislators to promote their own political welfare through special-interest politics.

Wednesday, September 14, 2016

F2PY Example: Radial Distribution Function

In a recent post, I discussed the use of F2PY for speeding up parts of python code.

The radial distribution function (RDF) or the pair correlation function \(g(r)\) is a statistical mechanical property which quantifies density variation as a function of distance from a reference particle as a function in a system of particles.

It is a fairly fundamental property that can easily be computed from molecular simulations. The Fourier transform of the RDF is experimentally accesible via light scattering.

For the purposes of this demonstration, we are given a bunch of points in a periodic simulation box. Our goal is to find the pair correlation function \(g(r)\), and compare the relative advantage of using f2py to wrap a Fortran 90 subroutine and a vectorized python implementation of the same algorithm.

The details are in this shared iPython notebook on GitHub. You should be able to both (i) see a static html rendition on the linked site, and (ii) download a jupyter notebook for further experimentation.

The bottom line here was that  eventually both python and Fortran gravitated to a \(N^2\) scaling, where \(N\) is the number of particles. Since the Python code exploits vectorization, its performance is not as bad. Indeed, its relative performance in this case seems to improve as the number of particles increase from 500x worse to only 10x worse as the number of particles was increased from 10 to 10000.

Thursday, September 8, 2016

Extraneous Roots

Mr. Honner takes issue with the grading rubric for a math problem:

Mistakes, even if they are made by the examiners, are useful learning grounds. Here are a couple more problems that he unearthed.

James Tanton also addresses some of these issues (issues with domain, extraneous solutions etc.) in a readable essay (pdf).

Tuesday, September 6, 2016

Veil of Ignorance

Recently, a bunch of us were chatting about the relative merits of taxing consumption (sales tax), income, and wealth (estate tax), and how one would go about designing a new tax code if we were not encumbered by existing laws.

A goal was to keep the system as simple as possible, and then coming up with imaginary cases of people who would be much worse off under the new tax code.

During the discussion, the idea of the veil of ignorance kept popping up.

Here is a quick video explainer of the concept:

And a quick introduction to the man who most recently popularized the role of this concept in designing policies with social justice in mind.

Here is a link to an EconTalk podcast (Rawls, Nozick and Justice) on related issues.

Monday, September 5, 2016

Teacher's Day

Long before Hallmark completely littered the calendar with "special days", we celebrated September 5, in India, as Teacher's Day; a day when we paused to reflect over how our teachers had shaped us.

I have been fortunate to have had many wonderful teachers. So I thought it might be a good idea to rekindle the spirit of the day, by highlighting one such teacher, every year.

Today, let me tell you about Ms. Mary Fernandes, who taught us English in 8th and 9th grade.

Like many kids, I liked to read books mostly for the stories they told. I had no appreciation for the art of good-writing until Mary teacher (as we called her) brought it sharply into focus.

The difference between good and mediocre writing is often not content, but how that content is skillfully unwrapped. A good writer understands the state of the reader's mind, which once ensnared, can be coaxed to go wherever the writer wants.

Before Mary teacher, I had no love for poetry; mostly because of how we were tested on them. We had to memorize long quirky poems, including the goddamn punctuation! Any deviation was penalized. It was like memorizing a page of computer code; any small error in reproduction, and the code wouldn't compile. I hated it then, and its memory makes me angry even after all these years.

In 8th and 9th grade, I learnt how to let myself enjoy poems. I still hated the way we were tested; but I began the slow process of forgiving William Wordsworth, John Milton, and their ilk for their years of torture. The most important thing I learnt was that the best way to read poems, was to read them aloud - even if people around you gave you strange looks.

In terms of our writing ability, all of us are a work in progress. We read, we learn, we change. And our writing changes with us. In many ways, it is like our signature. With age, there are subtle shifts, lots of rounding of edges, and a move towards directness and simplicity.

Most of the time, this change is gradual, but sometimes there are drastic  "phase transitions". High-school was like that for me - I heard my own voice for the first time.

Perhaps the most enduring lesson I learnt was the irresistible pull of a story well told. I remember laughing uncontrollably, while we read a Don Quixote story in Mary teacher's class. I wanted to stop laughing; I knew I was embarrassing myself. But I just couldn't. The harder I tried, the worse it got.

The bulk of my writing these days is technical or semi-technical. The goal is to illuminate, rather than to entertain. While this imposes some constraints, narratives are just as important (unless you are writing a manual), in technical writing. It is perhaps the only writing lesson I try to actively cultivate in my students.

People like stories, and scientists are people. The papers I enjoy the most have many elements of good story-telling. How did we get into this bind? Who/what are the key actors/methods? How do things unfold? What is the moral of the story/paper?

For that lesson alone, I am forever grateful to Mary teacher's role!