Sunday, August 30, 2015


1. Aatish Bhatia and Robert Krulwich explore the relationship between heat conservation and animal size in their new blog.

2. Scott Adams on better writing. As an example, the essay begins with lines that draw you in:
I went from being a bad writer to a good writer after taking a one-day course in “business writing.” I couldn’t believe how simple it was.
3. Matt Might answers a question on getting tenure and raising a disabled child at the same time., with grace and optimism. Amazing perspective!

4. Who said doing science was easy? An interactive experience from 538. Science is strong because it is willing to make errors and fix them.

Wednesday, August 19, 2015

Analogy: Matrix As a Tree

When many of us first encounter matrices, we see them as a glorified table of numbers stuffed into special square brackets.

This is analogous to looking at a tree as a collection of biological cells.

It is not incorrect; but it is perhaps a tad too granular.

One can ask, "what is the function or application of a tree or a matrix?".

For a tree, the answer may be fruits, lumber, home for birds and animals etc.

For a matrix, it may be to flip a vector, stretch it, rotate it, or some combination thereof. Here we are thinking of the tree or the matrix in terms of its relationship with other things.

One could ask what the main structural parts are.

For a tree, it may be roots, trunk, branches, and leaves.

For a matrix, it may be useful to think of it in terms of a collection of column or row vectors, and the vector spaces that they define.

One could then ask a category question: "What kind of a tree is this?"

Is it an oak tree, a fruit tree, an evergreen, a gymnosperm, etc focusing on its distinguishing properties, and the categories that it belongs to.

Similarly, one can identify different types of matrices. Is a matrix symmetric? Invertible? Triangular? Sparse? What other trees and matrices are they related to.

Monday, August 17, 2015

Error Propagation in Python

The uncertainties package makes it extremely easy to perform numerical error propagation. If you have numbers with associated uncertainties like \(x = 1 \pm 0.1\), and you want to find how the uncertainty propagates to functions of \(x\).

Simple Example

from uncertainties import *

x = ufloat(1,0.1)  # x = 1 +/- 0.1

y = ufloat(2, 0.1)

print "x = ", x
print "x^2 = ", x**2
print "x/y =", x/y


x =  1.00+/-0.10
x^2 =  1.00+/-0.20
x/y = 0.50+/-0.06


Installing the package is extremely easy with "pip".

sudo pip install  --upgrade uncertainties

Bigger Example

I had a datafile called "stiff.dat", which had data in columns. The first column was bp (base-pairs), the second and third columns were the contour length \(L\) and the associated uncertainty \(\Delta L\), and the last two columns were a quantity \(D^2\) and \(\Delta D^2\).

$ cat stiff.dat

25    5.31    0.18    42.25     4.36
50   15.07    0.84   108.46    23.03
75   24.99    2.26   129.92    29.36
100  36.05    3.85   169.35    20.40
125  49.91    4.91   263.68    88.00
150  58.04    5.82   354.27    66.53
175  80.64    6.89   508.11   132.49
200  85.61    7.73   651.71   234.54
250  129.23  10.16  1018.93   322.32
300  158.55   7.45  1240.22   474.75
425  267.88  13.32  7129.34  5050.29

What I wanted to compute was \[s = L/\sqrt{D^2}.\]
import numpy as np

data = np.loadtxt('regular.dat')
bp   = data[:,0]
N    = len(bp)

for i in range(N):
    L, dL = data[i,1:3]
    D2, dD2 = data[i,3:5]

    s = ufloat(L, dL)/(ufloat(D2, dD2)**0.5)
    print("{0:3d} {1:.4f} {2:0.4f}".format(int(bp[i]), s.n, s.s))

The ".n" and ".s" give access to the nominal value and the standard deviation.

 25 0.7746 0.0603
 50 1.4261 0.2046
 75 2.2058 0.2223
100 2.4951 0.2947
125 2.7341 0.5820
150 3.3198 0.3114
175 3.6405 0.4322
200 4.1599 0.6252
250 4.7373 0.6742
300 5.1782 0.7471
425 5.4803 1.3160


The package has a lot of features. It has some native support for arrays types, correlation of variables, etc.

Here are links to additional tutorial pages

Friday, August 14, 2015


1. Ten beautiful images from the winners of the 2015 National Geographic traveller photo contest (The Atlantic)

2. After Shashi Tharoor's viral video on whether Britain owes reparations to its former colonies, here is a brief history of the British East India Company (The Guardian)
 One of the very first Indian words to enter the English language was the Hindustani slang for plunder: “loot”. According to the Oxford English Dictionary, this word was rarely heard outside the plains of north India until the late 18th century, when it suddenly became a common term across Britain.[...]

There are more Mughal artefacts stacked in this private house in the Welsh countryside than are on display at any one place in India – even the National Museum in Delhi.
3. John D. Cook has a list of life lessons from studying differential equations. They include gems like:
  • Some problems simply have no solution
  • Some problems have no simple solution.
  • Some problems have many solutions.
 4. Google is in the news quite a bit this week; this article explores "why Google doesn’t care about hiring top college graduates?"
Short answer: intellectual hubris, and a bad attitude towards failure.

Monday, August 10, 2015


1. Does Facebook really for more video views than YouTube? (Hank Green doesn't think so)

2. A short portrait of Theodor Gisel or Dr. Seuss.

3. Romeo, Juliet and differential equations (a short suggestion, and an NYT blog)

4. Python is the new BASIC.
When I say that Python is the new BASIC, I mean it as a compliment, to say that Python is in the best position to become a lingua franca for non-programmers to learn programming. I didn’t mean to imply that Python was an inelegant kludge.

Multiple Secondary Axes in Veusz

In this quick tutorial, I will revisit the topic of "how to plot a graph with two different y-axes" in Veusz.

1. Load in the datafile as usual. Click on images to see an enlarged version.

2. Add an axis. By default is called "axis1" and is oriented horizontally. Since we want a secondary "y-axis" we will align it "vertical"ly.

3. You can click on the secondary y-axis and move it to the desired location. For precision, you can choose the "axis position" link and numerically enter the desired position.

4. Add your charts. By default, both the charts use the primary y-axis (called "y"). The example below shows how we can change this for a particular "xy" chart. We'd have to choose "axis1" instead of the default "y".

5. If the labels on the secondary y-axis go off-page limits, you can resize your graph.

6. I like to color code the axis and the corresponding dataset, so that it is visually apparent. You could also use arrows, if you like.

Monday, August 3, 2015

DeflateGate Links

What have we learned from the Wells Report? One of the things we have learned is that measuring the pressure of a football is not as straightforward as one might think. The head referee for the game, Walt Anderson, was alerted before the game that there was a possibility that the Patriots might be under-inflating balls. Yet the gauge he brought to the game and that he remembers using, systematically overestimated the pressure in the ball by about .35 psi. This inaccuracy is roughly the amount of tampering the Patriots are accused of. We have learned that temperature and changes in temperature along with moisture have a huge effect on pressure, 2-3 times greater than the magnitude of deflation the Patriots are accused of.
Brady can say, “I know I have legal risk but I am not settling because I didn’t do anything. Or I am settling for a fine to make this go away but no admission of guilt.”

The NFL can say, “I know I have legal risk but I am not settling because of um I need to Make This Right™…um er integritude… the doctrine of cheater cheater pumpkin eater??!?”
Disclaimer: I am a Patriots and Brady fan, so I probably suffer from confirmation bias.