Sunday, May 21, 2017


Everything that irritates us about others can lead us to an understanding of ourselves.
Carl Jung
The value of a prototype is in the education it gives you, not in the code itself.
Alan Cooper

Saving money is a non-socially-rewarded, non-observable, 1 player game. Spending money is a socially rewarded, observable, multiplayer game

Eric Jorgenson

Academic life is 10% what happens to you, and 99% making it count for multiple sections on your CV.

Shit Academics Say

"Most papers in computer science describe how their author learned what someone else already knew."
Peter Landin

"Do I not destroy my enemies when I make them my friends?"
Abraham Lincoln

Friday, May 19, 2017

Smart Machines, Complexity, and 42

In Hitchhiker's Guide to the Galaxy, there is a poignant moment when a machine is asked the answer to the ultimate question of life, the universe, and everything.

It crunches numbers for millions of years, and returns the baffling answer "42".

The scenario that Douglas Adams concocted might be amusing, but given our increasing reliance on machines, it has ripples in today's world.

Computers can often provide answers, without providing insight. For meaning-seeking humans, this can be deeply unsatisfying. Witness the unease surrounding computer-assisted proofs.

Machine learning can help us deduce models to navigate complex systems. Neural network models might start with simple rules for learning. But the models they "learn" or end up with, are anything but simple.

To keep things specific, consider programming a self-driving car. The model may start simple ("keep between the lanes"), but get hellishly complicated as numerous edge cases ("dog jumps into the road", "many people don't check their blind spot", "the night is foggy") are subsumed.

Even if the car works reasonably well, how it responds to a "black swan" situation (one it has never seen before) might be anybody's guess.

Practical models for complex systems might be insanely complicated.

A recent "Rationally Speaking" podcast touched upon many of these issues. In particular, I found the discussion of "physics thinking", which emphasizes universal models by ignoring details, and "biological thinking", which celebrates the diversity of phenomenon by focusing on details, incredibly fascinating. From the transcript:
The physics approach, you see it embodied maybe in like an Isaac Newton. A simple set of equations explains a whole host of phenomena. So you write some equations to explain gravity, and it can explain everything from the orbits, the planets, the nature of the tides, to how a baseball arcs when you throw it. It has this incredibly explanatory power. It might not explain every detail, but it maybe it could explain the vast majority of what's going on within a system. That's the physics. The physics thinking approach, abstracting away details, deals with some very powerful insights.
On the other hand, you have biological thinking. Which is the recognition that oftentimes in other types of systems, in certain types of systems, the details not only are fun and enjoyable to focus on, but they're also extremely important. They might even actually make up the majority of the kinds of behavior that the system can exhibit. Therefore, if you sweep away the details and you try to create this abstracted notion of the system, you're actually missing the majority of what is going on. The biological approach should be that you recognize the details are actually very important. And therefore they need to be focused on. 
I think when we think about technologies both approaches are actually very powerful. But oftentimes I think people in their haste to understand technology, oftentimes because technologies are engineered things, we often think of them as perhaps being more the physics thinking side of the spectrum. When in fact, because they need to mirror the extreme messiness of the real world, or there's a lot of exceptions, or they've grown and evolved over time, often it's a very organic, almost biological fashion. They actually end up having a great deal of affinity with biological systems. And systems that are amenable to biological thinking and biology approaches.

Tuesday, May 16, 2017

Purdue-Kaplan: Is Disruption Knocking?

Last month Purdue University announced they were going to acquire Kaplan University, an online for-profit institution. The NewU ...
... will be distinct from others in the Purdue system, relying only on tuition and fundraising to cover operating expenses. No state appropriations will be utilized. It will operate primarily online, but has 15 locations across the United States, including an existing facility in Indianapolis, with potential for growth throughout the state. Indiana resident students will receive a yet-to-be-determined tuition discount.
The deal has the potential to bring down tuition costs, enhance access, and provide Purdue's solid brand name. Here are some reactions to news:

1. Purdue's official statement is, of course, positive.
Former U.S. Secretary of Education Arne Duncan said, “I’ve always had great respect for Gov. Daniels, and I’m excited by this opportunity for a world-class university to expand its reach and help educate adult learners by acquiring a strong for-profit college. This is a first, and if successful, could help create a new model for what it means to be a land-grant institution.”
2. However, questions are being raised (NPR).
The deal is eye-catching, but also part of a trend. Over the past decade dozens of nonprofit universities have contracted with private companies to expand their online offerings. For example, Arizona State University works with Pearson, and the University of Southern California with a company called 2U. Florida A&M and South Carolina State, both historically black institutions, have partnered with the University of Phoenix. In an atmosphere of ever-skinnier state budgets, these programs enable universities to reach a global market, cater to working adults, and potentially increase revenue without expensive capital investment.
3.  The faculty at Purdue is not happy (InsideHigherEd)
No faculty input was sought before the acquisition decision was made, and no assessment of its impact on Purdue’s academic quality was completed, according to the resolution. The resolution proceeded to fault a lack of transparency and a lack of an impact study on how the acquisition will affect faculty, curriculum, students and staff at Purdue. The resolution also wondered what will happen to faculty governance and academic freedom at Purdue’s newly acquired university. And it said previously Purdue’s administration has gone through University Senate structures -- which include faculty input -- when pursuing program restructuring or creation.
4.  An interview with the seller, Donald Graham, chairman of Graham Holdings.

[Q:] I see what Purdue gets from the arrangement—a jumpstart into providing online courses. But what does Graham Holdings get out of this deal? 
Graham: [...] You asked about when Graham Holdings shareholders might be rewarded. The only way we would be rewarded, the only way we would get a growing stream of revenue, would be if Purdue continued over the years to add students. In other words if the university became a big success under Purdue's leadership, we'll be part of that success. But we will not be a participant in any profits. We're out of the for-profit education business here. We will be paid for our services, and the profits if any will go to Purdue, and hopefully back into the whole educational system.
5. Some older links to universities, MOOCs and online education

Friday, May 12, 2017

Computational Thinking Classes

Here is a collection of "Computational Thinking for non-majors" type of classes:

1. My department's very own

2. Another list which links to classes from Berkeley, and Harvey Mudd.

3. A self-study course package

4. This essay by Stephen Wolfram on how to teach computational thinking 

Tuesday, May 9, 2017

Wait But Why

I first came across Tim Urban, through his interview with Julia Galef. The interview was one of my favorite episodes of Rationally Speaking.

His website "Wait But Why" is an amazing resource. It is well thought out, and provides historical, scientific, and philosophical context to many contemporary issues.

Listen to this TED talk for a quick introduction.

Sunday, April 30, 2017

Google Autodraw

Imagine playing pictionary with a computer.

Google Autodraw let's you do just that. You doodle/sketch on a board, and the computer continuously tries to guess what you are drawing. In a short amount of time, my guess is that it is going to get pretty good!

Here's an example:

Friday, April 28, 2017

History of the Logarithm of Negative Numbers

Not too long ago, I did a blog post on how matlab and python have different responses to logarithms of negative numbers.

It turns out that the history of the logarithm of negative numbers is truly fascinating, and had Leibnitz, Bernoulli, Euler, and the other greats embroiled. Take a look at this article (pdf) by Deepak Bal.

Here is the abstract:
In 1712, Gottfried Leibniz and John Bernoulli I engaged in a friendly correspondence concerning the logarithms of negative numbers. The publication of this correspondence in 1745 sparked an interest in the mathematical community on the topic. In this paper I will discuss the evolution of the logarithmic concept in the time leading up to their discussion. I will then give a synopsis of the correspondence followed by a description of a paper by Leonhard Euler in which he addresses the issue.

Sunday, April 23, 2017

End of The World

As I sat bewildered and amused, I knew it was a story that I had to be save for her wedding reception.  Next to me, my older daughter was sobbing inconsolably, "why does it all have to end this way?"

Rewind ten minutes. It was not a conversation that was supposed to go like this.

You see, my dad is absolutely fascinated by the night sky. I thought I'd play the role of a good son and father, by testing whether talking about space would ignite my daughter's interest in the subject. Perhaps, next time they met, they could obsess over a shared interest.

Me: Do you know the name of our galaxy, M.?
M.: Of course, the Milky Way!
Me: Good! They teach you good stuff in school. Now, harder question; do you know which galaxy is right next to ours?
M.: No, which is it, Baba?
Me: Andromeda. And I bet you haven't heard this. Billions of years later, Andromeda and the Milky Way are going to smash into each other. It is going to be spectacular!

M.: (troubled) Can't we do anything to stop it?

I cracked open a laptop, and fired up a browser.

Me: Look this is Tallahassee. This is Florida. This is the Earth. This is the solar system (zooming out each time). This is the Milky Way, and this is Andromeda. We are too tiny to do anything meaningful.
M.: (definitely worried) What does that mean? Does it mean we all die?
Me: (scoffing) Oh, don't worry about that. This is going to happen after BILLIONS of years. We will all be dead long before that. In fact, perhaps the Earth will be gone before that.
M.: What do you mean, Baba?
Me: You know how the sun is a star, right?  Like all stars, it shines by burning gas. It has tons of gas, kinda like Baba's tummy. But once it runs out of most of that gas, it might expand to about 3 times its size, and gobble up Mercury, Venus, and probably Earth.

I noticed tears streaming down her cheeks. I had to console her. And I had do it fast.

Me: But don't worry. Dont' worry! This is not going to happen for  BILLIONS of years more. We will all be gone by then.
M.: (now sobbing inconsolably) why does it all have to end this way?

After a few minutes, she regained her composure. I was debating whether it would be tone-deaf to talk about the real things to be scared of, like global warming, or pandemics, or..., when she interrupted me with a plea.

"Baba, can we please not talk about space, anymore?"

Tuesday, April 11, 2017

Strogatz and Art of Mathematics

For some reason, these Steve Strogatz' columns from 2015 on the "Art of Mathematics" have resurfaced.

Here are two blog posts, which explains the origins, inspiration, and mechanics.

The associated website is chock full of useful resources and ideas designed to help liberal arts students appreciate the art and joy of mathematics.

Thursday, March 30, 2017

Statistics and Gelman

Russ Roberts had a fantastic conversation with Andrew Gelman on a recent podcast. It covered a lot of issues and examples, some of which were familiar.

A particularly salient metaphor "the Garden of Forking Paths" crystallized (for me) some unintentional p-hacking by people with integrity.
In this garden of forking paths, whatever route you take seems predetermined, but that’s because the choices are done implicitly. The researchers are not trying multiple tests to see which has the best p-value; rather, they are using their scientific common sense to formulate their hypotheses in reasonable way, given the data they have. The mistake is in thinking that, if the particular path that was chosen yields statistical significance, that this is strong evidence in favor of the hypothesis.
This is why replication studies in which "researcher degrees of freedom" are taken away have more reliable scientific content. Unfortunately, they are unglamorous. Often, in the minds of the general population, they do not replace the flawed original study.

Gelman discusses numerous such examples on his blog. These include studies on "priming" and "power poses" that have failed to replicate. Sure there is the element of schadenfreude, but what I find far more interesting is the response of scientists who championed a theory react to new disconfirming data. For instance, Daniel Kanheman recently admitted that he misjudged the strength of the scientific evidence on priming, and urged readers to disregard one of the chapters devoted to it in his best-seller "Thinking Fast and Slow". Similarly, one of the coauthors of the original power poses work, Dana Carney, had the courage to publicly change her mind.

That is what good scientists do. They update their priors, when new data instructs them to do so.

This brings me to another health and nutrition story doing rounds on the internet. It suggests a 180-degree turn on how to deal with rising incidence of peanut allergies. Instead of keeping infants away from nuts, it urges parents to incorporate them into early, and often. I haven't looked at the original study carefully, but my instincts on retractions and reversals of consensus tells me to take the findings seriously.

Monday, March 27, 2017

Logarithms of Negative Numbers

A plot of log(x) looks something like the following:

As x decreases to zero log(x) approaches negative infinity. For negative values of real x, the log function is undefined. For example, consider the following numpy interaction:

>>> import numpy as np
>>> np.log(1)
>>> np.log(-1)
__main__:1: RuntimeWarning: invalid value encountered in log

If I try to do the same in Octave, I get something different, and interesting.

octave:1> log(1)
ans = 0
octave:2> log(-1)
ans =  0.00000 + 3.14159i

The answer makes sense if we expand the scope of "x" from real to complex. We know Euler's famous identity, \(e^{i \pi} = -1\). Logarithms of negative numbers exist. They just exist in the complex plane, rather than on the real number line.

Octave's answer above just takes the logarithm of both sides of Euler's identity.

We can make python behave similarly by explicitly specifying the complex nature of the argument. So while log(-1) did not work above, the following works just as expected.

>>> np.log(-1+0j)

For x < 0, if we plot the absolute value of the complex number, then we get a nice symmetric plot for log(x).


  • In matlab, the command reallog is similar to np.log

Thursday, March 23, 2017

Housel on Writing

Morgan Housel is one of my favorite writers on the subject of economics and finance. He offers three pieces of writing advice in this column.


1. Be direct
2. Connect fields
3. Rewrite

Tuesday, March 21, 2017

Try a Pod

I am an avid podcast listener; over the past 6 years, they have enriched commutes, workouts and chores, immeasurably. There has been a concerted call to evangelize for the platform ("try a pod") in the past few weeks. In 2013, I already shared what I was listening to then. Podcast that I currently follow:

  • BackStory
  • My History Can Beat Up Your Politics
  • Hardcore History with Dan Carlin
  • CommonSense with Dan Carlin
  • Revisionist History
Science and Tech
  • Radiolab
  • Skeptics Guide to the Galaxy
  • Science Vs
  • a16z
  • Above Avalon
  • Full Disclosure
  • Note to Self
  • Recode Decode
  • Rationally Speaking
  • Reply All
  • 50 Things That Made the Modern World
  • Snap Judgement
  • The Moth
  • Criminal
  • This American Life
  • Found
  • 99% Invisible
  • The Allusionist
  • And Eat it Too!
  • A Way with Words
  • EconTalk
  • Five Good Questions
  • FT Alphachat
  • How I Built This
  • Invest like the Best
  • The Knowledge Project
  • Masters in Business
  • Rangeley Captical Podcast

  • Audio Dharma
  • Philosophize This
  • Educate
  • Commonwealth Club of California
  • Fareed Zakaria GPS
  • Frontline audiocast
  • In Our Time
  • Intelligence Squared
  • Intelligence Squared US
  • Left Right and Center
  • Please Explain
  • More Perfect

Tuesday, March 14, 2017


1. Doug Natelson's compilation of "advice" blog-posts (nanoscale views)

2. Are Polar Coordinates Backwards? (John D. Cook)

3. Learning Styles are baseless? (Guardian)

4. 5 Unusual Proofs (PBS YouTube Channel)

Friday, March 10, 2017

QuickTip: Sorting Pairs of Numpy Arrays

Consider the two "connected" numpy arrays:

import numpy as np
x = np.array([1992,1991,1993])
y = np.array([15, 20, 30])

order = x.argsort()
x     = x[order]
y     = y[order]

x = array([1991, 1992, 1993])
y = array([20, 15, 30])

Wednesday, March 8, 2017

Perverse Incentives and Integrity

Edwards and Roy write about scientific integrity in the face of perverse incentive systems (full citation: Edwards Marc A. and Roy Siddhartha. Environmental Engineering Science. January 2017, 34(1): 51-61. doi:10.1089/ees.2016.0223.)

Here is a table from the paper, which grapples with incentives and unintended consequences.

Worth a look!

Monday, February 27, 2017

Not so Golden?

We discussed Golden section search method for optimizing functions in 1D last week. Naturally, we had to talk about the golden ratio (GR) and its appearance in the cultural zeitgeist.

However, there are many misconceptions/misunderstandings about the golden ratio, as researched in this eminently readable 1992 article by George Markowsky (pdf). For example:

  • neither the great pyramid of Cheops, nor the Parthenon, were designed to conform to the GR
  • da Vinci did not use the GR in his paintings
  • the golden rectangle is not obviously the most aesthetically pleasing rectangle
  • connection with the dimensions of the human body are exaggerated,
  • etc.

Keith Devlin explores this misconception in this video:

Saturday, February 25, 2017

Interesting Links

1. The Overpopulation Myth (video)

2. Is Bill Belichick lucky? (Russ Roberts on medium)

3. Math and the Good Life (quanta)
If I learn mathematics and I become a better thinker, I develop perseverance, because I know what it’s like to wrestle with a hard problem, and I develop hopefulness that I will actually solve these problems. And some people experience a kind of transcendent wonder that they’re seeing something true about the universe. That’s a source of joy and flourishing.
4. Indian snake catchers in Florida!

Thursday, February 23, 2017

Split a Text File using csplit

Suppose you have a large "sectioned" text file which looks like the following

> cat bigfile.txt



csplit bigfile.txt /data/ {*}

splits it into a bunch of files xx0, xx1, xx2, ..., where each of the "xx" files holds a section. Thus,

> cat xx1

and so on. Can be just the quick tool you need at times.

Friday, February 17, 2017

Google N-Grams for Keywords in Journals

Google Ngram Viewer allows us to visualize popularity of keywords as a function of time. It uses books archived on Google Books as its corpus.

However, it doesn't work quite as well on some domain specific scientific keywords.

The best tools for this is Web of Science, if you are lucky enough to have institutional access to it.

Once you search a keyword, scroll to the bottom left and look for the "Analyze Results" button. Then choose "Publication Years" in the "Rank the records by this field" window.

Here I looked for "tube model", which is a popular model in polymer melt dynamics.

You can export the result and play with it.

Thursday, February 9, 2017

QuickTip: Reducing PDF Size using GhostScript

The command is:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf


Wednesday, February 1, 2017

Neat Little Integral Trick

John D. Cook writes about a useful integration trick by rewriting trigonometric functions as complex variables. He recasts the integral \[\int e^{-x} \sin(4x) dx,\] using \(e^{ix} = \cos x + i \sin x\) as the imaginary part of \[\int e^{-x} e^{4ix} dx.\]

The derivation is cleaner (no integration by parts), and you don't have to remember any trig formulae. You can do pretty much any trig integral:\[\begin{align} \int \cos x dx & = \int e^{ix} dx \\
& = e^{ix}/i \\ & = -i e^{ix}. \end{align}\] The real part of the last expression is \(\sin x\).

Saturday, January 21, 2017

The Post-Statistics World

A wonderful long form essay by William Davies, "How statistics lost their power – and why we should fear what comes next"
The declining authority of statistics – and the experts who analyse them – is at the heart of the crisis that has become known as “post-truth” politics. And in this uncertain new world, attitudes towards quantitative expertise have become increasingly divided. From one perspective, grounding politics in statistics is elitist, undemocratic and oblivious to people’s emotional investments in their community and nation. It is just one more way that privileged people in London, Washington DC or Brussels seek to impose their worldview on everybody else. From the opposite perspective, statistics are quite the opposite of elitist. They enable journalists, citizens and politicians to discuss society as a whole, not on the basis of anecdote, sentiment or prejudice, but in ways that can be validated. The alternative to quantitative expertise is less likely to be democracy than an unleashing of tabloid editors and demagogues to provide their own “truth” of what is going on across society. [...]
In many ways, the contemporary populist attack on “experts” is born out of the same resentment as the attack on elected representatives. In talking of society as a whole, in seeking to govern the economy as a whole, both politicians and technocrats are believed to have “lost touch” with how it feels to be a single citizen in particular.
Some thoughts:

Some clear-cut questions can be adjudicated, purely based on observation, measurement, and statistics. For example, "how far is the sun?", "what is the average life-span of a human?", etc. Other questions, especially those that arise from inherently complex systems, often resist simple interpretation of numbers. These include questions about nutrition, ecology, macroeconomics etc. It is difficult to interpret measurements and facts, without an underlying theory or story.

Such numbers need compelling narratives to hang on. In such cases, a single counter-example doesn't disprove a thesis: a chain smoker who lives to be 100, doesn't disprove the claim that smoking is bad for you. Likewise, good narratives need numbers to ground them (think any pseudo-scientific claim). 

Calculations and stories go together; it is not one or the other. It has to one and the other.

Friday, January 13, 2017

The Need for Narratives

Neal Koblitz writes in the Chronicle:
The common element in all of this is knowing how to tell a story. Contrary to popular misconceptions about science and technology, a good piece of technical work is not a disembodied sequence of formulas and calculations, but rather is part of a narrative that has a long plot line and a large cast of characters. [...] Story-telling is a fundamental part of being human, from the time we are little children.
I couldn't agree more. The ability to weave a compelling story through a presentation or journal article makes a truly memorable one stand out from the run-of-the-mill kind.

You should check out the rest of the opinion for why STEM majors need grounding in the humanities.

Tuesday, January 10, 2017

An Adventure in Active Learning

I decided that I finally wanted to give this flipped classroom thing a shot. When I found out that I was scheduled to teach a Matlab/Mathematica class, a couple of years ago, I figured it was ideally suited for this experiment.

I spent the previous summer thinking through the format, reimagining the material, and the pacing. The idea was simple.

There were excellent 15-minute videos on the Mathworks and Wolfram sites, which students would watch before class. They would take a quick, but super-easy, quiz at the start of every class to ensure that everyone watched the videos. We’d then spend class time doing actual modeling, programming, and discussing common pitfalls and misconceptions.

I was very excited at the start of the semester. If I were a student, I would have loved the class I put together. Without a doubt. That's what I thought!

The excitement drained away quickly.

About 1/3 of the class was super-engaged. They watched videos, they were active in class, and I felt that they truly got something out of the class. If all of my class did as well, I would have thought that the experiment was successful. Grudgingly though, I had to admit that this 1/3 would have mastered the subject, even if I did not show up to class.

The middle 1/3 tried to keep up. They were somewhat inconsistent. In some classes, they were very active, and in others, they struggled. Would they have done better in a traditional class? Who knows!

About 1/3 of the class did not watch the videos. Consistently. I exhorted them, unsuccessfully, to come see me after class, so that we could work on the gaps in their understanding. Class time was miserable for them. They hid behind the terminals, doing their homework, while the rest of the class was busy solving problems.

After about a month I realized I had completely lost them.

Overall, I felt terrible about the experiment. It failed.

I haven’t tried flipping my classroom, since.

I have tried to do several post-mortems to figure out what went wrong; if there was something I could have done differently to fix the problem I saw, fairly early on.

The whole process relied heavily on students doing their homework. I was open to them not getting all the material in the videos. We could discuss that stuff in class. That would have been wonderful.

But flipped classrooms are still relatively rare in my university. Their novelty meant that students hadn’t realized the importance of keeping up with assigned material.

This was an undergrad class. The distribution of “work ethic” is often wider than in grad classes. From my experience flipped classrooms can work well even with a wide distribution in ability, given relatively high appetite for hard work.

But, vice versa, is another story.