Sunday, December 26, 2010

Warren Buffett on Gold

Following up on gold, here are a couple of interesting perspectives on gold from the world's most famous investor.
Gold gets dug out of the ground in Africa, or someplace. Then we melt it down, dig another hole, bury it again and pay people to stand around guarding it. It has no utility. Anyone watching from Mars would be scratching their head.
And another:
You could take all the gold that’s ever been mined, and it would fill a cube 67 feet in each direction. For what that’s worth at current gold prices, you could buy all — not some — all of the farmland in the United States. Plus, you could buy 10 Exxon Mobils, plus have $1 trillion of walking-around money. Or you could have a big cube of metal. Which would you take? Which is going to produce more value?”

Thursday, December 23, 2010

Is gold a good investment at these prices?

Here (pdf) is a balanced viewpoint by Howard Marks of Oaktree. You can suspect a bona fide attempt to look at all sides of the argument, when he starts with:
In 1952, Noah S. “Soggy” Sweat, Jr., a member of the Texas House of Representatives, was asked about his position on whiskey.  Here’s how he answered: 
If you mean whiskey, the devil’s brew, the poison scourge, the bloody monster that defiles innocence, dethrones reason, destroys the home, creates misery and poverty, yea, literally takes the bread from the mouths of little children; if you mean that evil drink that topples Christian men and women from the pinnacles of righteous and gracious living into the bottomless pit of degradation, shame, despair, helplessness, and hopelessness, then, my friend, I am opposed to it with every fiber of my being.  
However, if by whiskey you mean the oil of conversation, the philosophic wine, the elixir of life, the ale that is consumed when good fellows get together, that puts a song in their hearts and the warm glow of contentment in their eyes; if you mean Christmas cheer, the stimulating sip that puts a little spring in the step of an elderly gentleman on a frosty morning; if you mean that drink that enables man to magnify his joy, and to forget life’s great tragedies and heartbreaks and sorrow; if you mean that drink the sale of which pours into Texas treasuries untold millions of dollars each year, that provides tender care for our little crippled children, our blind, our deaf, our dumb, our pitifully aged and infirm, to build the finest highways, hospitals, universities, and community colleges in this nation, then my friend, I am absolutely, unequivocally in favor of it.  
This is my position, and as always, I refuse to compromise on matters of principle. 
Sweat’s response shows, depending on how you look at it, either how views can diverge on a given subject or how differently a tale can be spun.  Thus it serves well to introduce the topic of this memo: gold.  
And a little further on:
My view is simple and starts with the observation that gold is a lot like religion.  No one can prove that God exists . . . or that God doesn’t exist.  The believer can’t convince the atheist, and the atheist can’t convince the believer.  It’s incredibly simple: either you believe in God or you don’t.  Well, that’s exactly the way I think it is with gold. Either you’re a believer or you're not.
 It is a great read. Check it out.

Friday, December 17, 2010

Least Squared or Absolute Errors

It is almost impossible to escape linear regression: the act of fitting straight lines through scattered data.

The question of whether it is more appropriate to use minimization of squared or absolute error to determine the straight line, popped up yet again in a recent reviewer comment.

It feels "natural" to use least-squared error, since we have all done it so many times. However, it should be borne in mind that the popularity of this criterion usually arises from the convenience it affords, and not because it lays any special claim to uncovering the truth.

Here is a nice post (+comments), which explores the issue more fully. To nudge you to check out the post, here is a fascinating picture.

Friday, December 10, 2010

Renaming Linux files in bulk using wildcards

Until yesterday, I was completely unaware of a useful linux utility called rename. In its place, I used either mv, or mv embedded in a shell script. But clearly, it is a cleaner way of renaming files in bulk.

And it is never to late to discover a useful tool.

Here is one situation where rename is handy. If you had a bunch of files file1, file2, ..., file500, and you wanted to pad zeros to rename these files to file001, file002, ..., file500, you could do that easily with:

rename file file00 file?
rename file file0 file??

or alternatively using regular expressions:

rename ’s/file/file00/’ file?
rename ’s/file/file0/’ file??

It essentially has the following syntax

rename oldname newname *.files
rename "regex-rule" files


Check out these tutorials which explain the rename command with some examples.

One tip I discovered is that the regex syntax works well with Debian based distros (like Ubuntu). Since my desktop at work runs CentOS (RedHat based), it doesn't work quite as well (the other syntax works just fine).

To circumvent the problem, you could download the rename.pl file and run it as shown here.

Thursday, December 2, 2010

Links:

(i) Ten questions science must answer: Another top-ten list on some of most enduring scientific questions, compiled this time on the occasion of the 350th anniversary of the Royal Society. Somewhat superficial.

(ii) Are complex economic models the answer?: Aswath Damodaran offers a counterpoint to a recent WSJ piece on the need for more complex economic models.
To those who believe that complex models with more variables are the answer to uncertainty, my response is a paper by Ed Lorenz in 1972, entitled Predictability: Does the flap of a butterfly's wing in Brazil set off a tornado in Texas?, credited with creating an entire discipline: chaos theory. In the paper, Lorenz noted that very small changes in the initial conditions of a complex models created very large effects on the final forecasted values. Lorenz, a meteorologist, came to this recognition by accident. One day in 1961, Lorenz inputted a number into a weather prediction model; he entered 0.506 as the input instead of 0.506127, expecting little or no change in the output from the model. What he found instead was a dramatic shift in the output, giving rise to a Eureka moment and the butterfly effect.

(iii) The sayings of Mikhail Zhvanetsky: Some precious one-liners. Not all are new, and some may have priority issues. But fun anyway. Here are some:
  • I drive too fast to worry about cholesterol.
  • The highest degree of embarrassment? Exchanged glances in a keyhole.
  • Of two evils, I choose the one I haven’t tried before.
  • Good always wins over evil. Hence, the winner is always good.

Thursday, November 18, 2010

More Shadow Scholar

A few days ago I posted a link to a popular article in the Chronicle called the Shadow Scholar. One of my friends sent it around an email list, which prompted an inquisitive colleague of mine ("Garret") to solicit their services, just as an experiment.

In his own words:
I went online and found several sites that write papers for students - even Ph.D. dissertations!. I was intrigued, so I wrote in asking to see if they could write a term paper for me on the topic that one of my Ph.D. students (name deleted) is looking at "use of energy functions to evaluate structural integrity of ancestral proteins estimated under Likelihood using IID models"

They just replied this morning. :-0)
Their reply:
Dear Customer,
Thank you for placing an inquiry with our company.
We have reviewed the preliminary information available from your inquiry and are glad to inform you that we have several writers who specialize in your field of study. 
Nevertheless, we will need more detailed instructions for your assignment in order to find the most suitable writer.
Please make sure to send your paper requirements in a note to admin, upload them in the Files section of your personal order page or send them to our email. 
It would be also appreciated if you specify your final deadline for the order. To provide us with more instructions and proceed with the payment, please click here.

Tuesday, November 16, 2010

Reptate

Recently I went on my annual pilgrimage to the Society of Rheology meeting in Santa Fe. A colleague (Alexei Likhtman at Reading) talked briefly about a nifty piece of software that he and Jorge Ramirez had put together called Reptate (Rheology of Entangled Polymers: Toolkit for Analysis of Theory & Experiment).

For somebody who works with entangled polymers, it is a great resource (for both theorists and experimentalists), since it obviates the need to code up different theories, worry about visualization, do time-temperature superposition etc.

It is free, works on Windows, and has some very nice tutorials.



Saturday, November 13, 2010

The Shadow Scholar

Interesting article in the Chronicle called the Shadow Scholar - the man who writes your students' papers tells his story.

I liked this part:
From my experience, three demographic groups seek out my services: the English-as-second-language student; the hopelessly deficient student; and the lazy rich kid.

For the last, colleges are a perfect launching ground—they are built to reward the rich and to forgive them their laziness. Let's be honest: The successful among us are not always the best and the brightest, and certainly not the most ethical. My favorite customers are those with an unlimited supply of money and no shortage of instructions on how they would like to see their work executed. While the deficient student will generally not know how to ask for what he wants until he doesn't get it, the lazy rich student will know exactly what he wants. He is poised for a life of paying others and telling them what to do. Indeed, he is acquiring all the skills he needs to stay on top.
I also found this line strangely reassuring :).
As long as it doesn't require me to do any math or video-documented animal husbandry, I will write anything.

Thursday, November 11, 2010

Why are there so many chemicals in our food?

I recently ate some great Fuji apples from Sam's Club.

Shiny red, extremely crunchy, with just the right hint of sourness to lift the underlying sweetness.

My curiosity drove me to the label (they came boxed). There, hidden in fine print (our farmers have learned from our bankers!), were the following items:
Treated to maintain freshness with one or more of the following: diphenylamine, thiabendazole, o-phenylphenol, ethoxyquin, 1-methylcyclopropene.
Coated with food grade vegetable and/or shellac based wax.
So I thought I'd structure my regular stroll through WikipediaLand, on a fine Saturday morning, by trying to learn more about these chemicals, and their adverse effects, if any.

Diphenylamine is used as a pre- or postharvest scald inhibitor for apples. Scald, or storage scald, are irregular brown patches of dead skin that start appearing within a week after warming fruit that has previously been preserved cold. Diphenylamine prevents oxidation, which is the principal cause of scald, and hence minimizes storage scald.

The MSDS sheet has the following to say regarding toxicity: "Toxic. Possible mutagen. Possible teratogen. Harmful in contact with skin, and if swallowed or inhaled. Irritant."

Next I turned to Thiabendazole, which apparently is used to control mold, blight, and other fungally-caused diseases. It appears to be relatively innocuous, with slight toxicity in higher doses. There seems to be no evidence for mutagenic or carcinogenic effects.


Similarly, ortho-phenylphenol is also a fungicide, and is apparently found in low concentrations in some household products including spray disinfectants and aerosol or spray underarm deodorants. Its toxicity seems to be controversial, with suppliers insisting that it is safe, while watch-groups suggest otherwise.

Ethoxyquin is another antioxidant, and apparently has been shown to cause mortality in fish. It does seem to present some toxicity concerns.

1-Methylcyclopropene (1-MCP) is an interesting one. From the wikipedia entry:
It is structurally related to the natural plant hormone ethylene and it is used commercially to slow down the ripening of fruit and to help maintain the freshness of cut flowers. The use of 1-MCP in agricultural products including apples, kiwifruit, tomatoes, bananas, plums, persimmons, avacados and melons has been approved and accepted for use in more than 34 countries including the European Union and the United States. Although there are benefits to the consumer including fresher produce and lower cost, there is some concern that consumers may be purchasing fruit that is older than expected.
Based on studies with laboratory animals, no adverse effects are expected to humans who are exposed to end products that contain 1-MCP, although eye irritation may occur if a user does not follow label directions. 1-MCP as a gas is not toxic to test animals.
Moral of the story: Never, ever forget to wash.

And yeah, the title of the post is misleading.

Saturday, November 6, 2010

More Untrained Minds

I recently posted some of my thoughts on untrained minds. They constantly impress me.

I found out another interesting instance on a recent post at Tanya Khovanova's blog. She was teaching one-way functions (functions which are easy to compute but hard to invert - like the product of two large prime numbers), which are useful in cryptography, to eighth-graders.

Her simple "phone-book" example of encoding something like "sun" would be to find last names in a given phonebook that started with the letters "s", "u" and "n", and concatenating the corresponding phone numbers. Putting them together is easy, but inverting is non-trivial.

Here's what happened in her own words:
And one of my 8th graders said, “If I were Bob, I would just call all the phone numbers and ask their last names.”

Friday, November 5, 2010

Lecture on Bottled v/s Tap Water

In this nearly hour long video lecture, delivered at the California Academy of Sciences, the speaker talks about how bottled water is really not as safe as we think it is.

Consumption of bottled water in the US has grown nearly exponentially since the 1970s. Interestingly consumption over the last couple of years seems to have abruptly declined (not merely a decrease in the rate of growth).

Check it out, although you may not learn anything that you didn't already know or suspect.

Thursday, November 4, 2010

Is academic research a good investment?

The recent financial crisis has seen increasing pressure on research universities to justify the cost/benefit ratio for the "goods" they deliver, as seen through numerous "viral" articles such as this WSJ story from Texas A&M (see a response, H/T nanopolitan).

Last week, our college dean emailed us another article (pdf) from a conservative Texas think tank called Texas Public Policy Foundation. The article is not new (circa 2008), but given the wave of austerity measures hitting Europe, and a likely round of further spending cuts in the US, it is timely.

To summarize, the article thinks academic research is an extraordinary waste of tax-payer money, and it comes up with some recommendations.
  1. emphasize teaching
  2. separate useful and esoteric research
  3. review the PhD "glut"
While the article oversimplifies complicated issues, like a toy model of a complex physical phenomenon, the oversimplified model still provides some lessons.

Personally, I do think higher education needs some fixing. Some of the issues mentioned in the article are issues that have bothered me before. I hope academia takes a good hard look at itself, and really tries to institute reform from within (instead of publishing it as a paper!).

For if we don't change it from the inside-out, then it may be destroyed from the outside-in.

Saturday, October 30, 2010

Tallahassee in the news

Two completely different alumni from my university, Florida State, were in the news the last couple of weeks. And only one of them had anything to do with football.

Jenn Sterger, a model and TV personality, was the object of football legend Brett Favre's lewd text messages. Her wikipedia entry recalls the moment she first shot to fame during the 2005 Florida State-Miami football game on national TV, when a commentator said (as the camera turned to her) "1500 red-blooded Americans just decided to apply to Florida State."

The other alumni in the news was hedge-fund manager Todd Combs, who was hired at Berkshire Hathaway to phase in as a/the chief investment officer - a position currently occupied by Warren Buffett. Not much is known about him at the moment (he graduated in 1993), but the spotlight is surely going to turn on him very hard, very soon.



Thursday, October 21, 2010

Should journalists have tenure too?

I just learned that NPR fired veteran journalist Juan Williams for supposedly making anti-Muslim remarks during his appearance on O'Reilly's show on Fox. Here's what he said:
"Look, Bill, I'm not a bigot. You know the kind of books I've written about the civil rights movement in this country. But when I get on the plane, I got to tell you, if I see people who are in Muslim garb and I think, you know, they are identifying themselves first and foremost as Muslims, I get worried. I get nervous."
Being a longtime listener and supporter of NPR, I must confess I was surprised both by Williams remark, and by NPRs decision to terminate him. While William's remark is obviously politically incorrect, having listened to him for so long, it is hard for me to imagine that he is the kind of bigot, he is being made out to be.

As Jacob Heilbrunn comments in the Huffington Post.
Williams won't be the loser for leaving NPR. NPR will. At some point political correctness overwhelms common sense. Yes, their [sic] should be taboos when it comes to public discourse. Some taboos are necessary and even vital.
[I also think he means "At some point common sense overwhelms political correctness."]

Not the greatest day for NPR.

Wednesday, October 20, 2010

Computing the eigenvectors of a 3x3 symmetric matrix in C++

Every once in a while Google makes me wonder how people ever managed to do research 15 years ago.

Just today, I had to find a quick C++ routine to compute the eigenvalues and eigenvectors of a well-behaved symmetric matrix (principal components of the gyration tensor of a 3D random walk, this time). I found it here.

It took me less than 5 minutes to google it down, download it, and test it.

Amazing.

Sunday, October 17, 2010

Untrained minds

I recently came across this interesting xkcd comic:


It reminded of me of an instructive personal incident from a long time ago, which serves to keep me humble as a teacher, to this day.

When I was in middle school, my school had this tradition of letting seniors teach juniors, a single class on Teacher's Day (September 5, in India). I distinctly remember that day, when I was teaching a bunch of second graders the difference between living and non-living things.

I neatly divided the board into two columns, and put "living things" on one side, and "non-living things" on the other, and proceeded to list their differences.

Living things move, non-livings things don't.
Living things grow, non-livings things don't.
Living things reproduce, non-livings things don't.
Living things die, non-livings things don't.

And so on.

Pretty vanilla, huh.

After I had smugly transcribed the contents of my memory, I turned around to see if there were any questions. I wasn't expecting any, really, so I was surprised when an eager hand shot up.

This kid asked me if a smart robot (like Giant Robot, from Johnny Sokko and his flying robot which aired on National TV) was living or non-living. Clearly, it could move, it could add stuff to itself, create new stuff, and be destroyed.

My response was something along one of the lines, in the comic above.

Of course, I now know the right answer should have started with "I really don't know."

PS: As a teacher now, I find the ability of untrained minds to ask penetrating questions extremely refreshing. They keep the fire alive.

Wednesday, October 13, 2010

Smoothing noisy data with GNU Octave/Matlab

Every once in a while, I find the need to summarize simulation or experimental data that are noisy using a smooth function. Smoothing splines try to pose the required regression as a least-squares problem.

A nice free program is the excellent Matlab version of Jerome Friedman's "supersmoother" by Douglas Schwarz. The program works fine without any tweaks on GNU Octave.

Take it out for a ride.

Saturday, October 9, 2010

Blackboards v/s Technology

Yesterday, I sat through a talk by one of my former colleagues, Srinivas Palanki entitled "eLearning: An Engineering Professor's Viewpoint".

He sketched out a very brief history of education starting from the times of Socrates, during which one teacher under a tree would engage in a dialogue with four or five students, through the Nalanda University, in which the idea of "classrooms" was developed, to about 1801 when James Pillans introduced the blackboard, which served as a focal point, and allowed class sizes to swell even more. It solved the classroom analog of the question (source: Joey from Friends) "You don't have a TV? What does all your furniture point to?"

The rest of the entertaining talk was a demonstration of the practical tools one could use such as, how to easily make videos (Camtasia), annotate slides using a tablet PC, and track usage using a learning management software (Moodle). For a motivated student (like someone who works, and likes the asynchronous aspect of learning), this development can really be a blessing. We already see some of this via MIT OpenCourseWare and Khan Academy.

My only remark at the end of the talk was how far we seem to have come from the "Socrates model", where learning was primarily question-directed, to increasingly more industrialized, efficient, and unidirectional models.

As a counter-point, check out this blog in support of traditional classroom teaching. Crudely summarizing, it suggests two important points: (i) just because something is old doesn't mean it is out-dated, and (ii) so much of communication is non-verbal.

Wednesday, October 6, 2010

The Todd Henderson controversy

You may already have heard of the University of Chicago Law professor (Todd Henderson) who posted (now deleted, but available cached here) a blog called "We are the Super Rich".

Although he and his wife make more than $250,000/year, in the process of attacking the upcoming tax hikes, he argues why he doesn't think of himself as rich.

Of course the response to that has been huge, with everybody from the Wall Street Journal dishing out advice on how to balance his budget, to Nobel Laureate Paul Krugman calling him the "whining Chicago professor", and many less-charitable folks in between, not holding anything back.

My initial response was "he's got to be kidding, right?", but as I read through the comments and his first few responses, I actually felt quite sympathetic for the guy.

Everybody can solve all problems, except their own.

Saturday, October 2, 2010

Mohandas Karamchand Gandhi

When I was in school, my favorite freedom fighters were Bhagat Singh, Veer Savarkar, and Subhash Chandra Bose. As a young boy, their courage was raw and palpable.

They refused to bow their heads, even before an empire that easily outmatched them. They possessed the ability to send shivers of fear down the enemy's spine, however temporarily.

The idealism of Mahatma Gandhi on the other hand, was outlandish. Nonviolence seemed like a cloak for impotence. The "turn-the-other-cheek" mantra was very hard to understand, let alone practice.

Passive civil disobedience and satyagraha seemed like self-flaggellation.

Why would you take injustice with a smile?

Well into my 20s, I believed that Mahatma Gandhi's leadership and India's independence from Britain were not causally connected. It was pure coincidence. And perhaps there is a grain of truth to that. Many countries got their independence post-WWII. Most did not have Mahatma Gandhis.

It was not until grad-school, that some of my long held beliefs against the man, slowly started softening. The trigger was a particular MLK day talk in Ann Arbor given by Prof. Rajmohan Gandhi (grandson).

I realized that anyone who could just land from South Africa, and integrate a fractured independence movement had to be special. Before Gandhi, the movement was essentially a fringe operation. Most people would grumble and complain, and stop there.


There must have been something mysteriously powerful about him, to persuade ordinary people to give up their comfortable enslavement, go on fasts, burn their clothes, and court arrest. He harnessed the collective idealistic zeal of men and women, young and old, and sculpted it into a potent force.

Non-violence itself is a pretty sophisticated concept. I had completely misunderstood it.

The key idea, which my school textbooks overlooked, is that non-violence appeals directly to the conscience of the oppressor. As Gandhi remarked, real "strength does not come from physical capacity. It comes from indomitable will."

Many oppressors are not heartless (there are exceptions, Hitler comes to mind), and you turn the mirror towards them, and force them to take a good hard look at their own misdeeds. Chances are, the oppressor will be shamed into guilt. Thus, you win the war against the oppressors, without really making enemies out of them. In fact, you make the oppressor himself feel good about the whole affair.

Gandhi knew war and violence are poor means even when directed towards exalted goals.

As he once said, "What difference does it make to the dead, the orphans and the homeless, whether the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?"

Wednesday, September 29, 2010

Malcolm Gladwell: Why the next revolution won't be tweeted

Just yesterday, I was browsing an older Malcolm Gladwell article on the fragility of things. This morning, I saw this new article in the New Yorker on why social network sites won't trigger the next revolution.

He makes an interesting point. High-risk activism which is required to establish the nucleus of a revolution orginates from strong-ties - friends we can depend on, as opposed to the weak-ties that social media specialize in.

Interesting read.

Friday, September 24, 2010

// Best source code comment

I stumbled onto this exchange on stackoverflow, regarding great source code comments via WalkingRandomly. Many of them are absolutely precious, some nice (short) ones include:

// sometimes I believe compiler ignores all my comments

//When I wrote this, only God and I understood what I was doing
//Now, God only knows

/* This is O(scary), but seems quick enough in practice. */

// somedev1 - 6/7/02 Adding temporary tracking of Login screen
// somedev2 - 5/22/07 Temporary my ass

#define TRUE FALSE //Happy debugging suckers

/* I did this the other way */

double penetration; // ouch

// I don't know why I need this, but it stops the people being upside-down
x = -x;

// I am not sure if we need this, but too scared to delete.

options.BatchSize = 300; //Madness? THIS IS SPARTA!

// no comments for you
// it was hard to write
// so it should be hard to read

Saturday, September 18, 2010

Charlie Munger Talk at Michigan

Charlie Munger is an endlessly fascinating guy, better known for being Warren Buffett's partner at Berkshire Hathaway. He is less known, as I chronicled here, for having attended the Math department at my alma mater, the University of Michigan at Ann Arbor.

Recently he spoke at length, at the Ross School of Business. This nearly two hour video is quite interesting. Unfortunately, it requires Silverlight. He sprinkles verbal gems as usual:
Envy is a really stupid sin because it's the only one you could never possibly have any fun at.

Sunday, September 12, 2010

Art of approximation in science and engineering

An interesting-looking course taught by Sanjoy Mahajan. According to the website:
Simple reasoning techniques for complex phenomena: divide and conquer, dimensional analysis, extreme cases, continuity, scaling, successive approximation, balancing, cheap calculus, and symmetry. Applications from physical and biological sciences, mathematics, and engineering. Examples include bird and machine flight, neuron biophysics, weather, prime numbers, and animal locomotion. Emphasis on low-cost experiments to test ideas and on fostering curiosity about phenomena in the world.
He has a working draft of an interesting reading book on the site.

Friday, September 10, 2010

The Underdog

I was recently on a long-haul trans-Atlantic flight, and saw Clint Eastwood's movie "Invictus" starring Morgan Freeman and Matt Damon, two of my favorite actors. It chronicles the story of how an underdog South African rugby team stunned the world, and unified a nation, in 1995 by winning the Rugby World Cup. Despite the poor audio and constant interruption throughout the flight, I thoroughly enjoyed the movie.

The title of the movie is derived from a poem on self-mastery by William Henley, which inspired Nelson Mandela while he was in prison. In the movie, Mandela (played by Morgan Freeman) shares it with Francois Pienaar, the captain of the rugby team (played by Matt Damon).

It is a beautiful poem.
Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul.
In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed.
Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds and shall find me unafraid.
It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate:
I am the captain of my soul.

Wednesday, September 8, 2010

OOoLaTeX: Getting fonts to work

I've previously written about my enthusiasm for OOoLaTeX, a plugin that lets you typeset LaTeX equations in OpenOffice. I love it because the equations look beautiful, and I can cut paste from my LaTeX manuscripts (and wikipedia sources for lectures).

Recently, my office computer which runs Linux went through an upgrade, and you guessed it right, among the many things that broke was OOoLaTeX.

Getting and installing the plugin was a breeze, as I outlined in my previous post. However, it could not print AMS characters like \mathbf{v} or \boldsymbol{\tau} as it used to (and was supposed to).

But what I had forgotten in the time since I last installed it was how to get the right fonts. My older notes (contained in the previous blog) were not very helpful. Since one of the underlying motivations for this blog goes along the lines of Linus Torvalds' quote "Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it" I thought I'd make more careful notes this time.

1. Download Bakoma fonts from CTAN. They are available as a set of files here, and save them.
2. I saved mine in a newly created directory ~/.fonts/bakoma
3. Since some of the characters are off in the original font set, replace them with the corrected ones found here in a tar-zipped file.
4. Untar, unzip and paste these files in ~/.fonts/bakoma, replacing some of the faulty older ones.
5. Type "fc-cache /panfs/panasas1/users/sshanbhag/.fonts/bakoma" in the terminal

And you should be good to go.

Friday, September 3, 2010

"Publish"ing in Matlab

I use GNU Octave as the glue to post-process and make preliminary visualizations most of the time. Every once in a while, however, I need to use its commercial cousin, Matlab.

This Fall, I am teaching an undergrad numerical analysis class, and realized that Matlab has this interesting documenting feature called "Publish", which lets you use a double percent sign %% in addition to the regular % sign used to begin a comment. Using these %% signs, you can divide your code into "cells" which is helpful for selectively testing individual cells -- an added benefit.

Check out a video on how to use this feature at Mathworks.

By proper use of %% and % comments, one can actually produce a nice document (in html, LaTeX or some other options), which is ideal, since now students can submit only a single "M-file", and I can check whether the program works, and the accompanying documentation in one shot.

Thursday, August 19, 2010

Links

1. The "Patel"ization of motels (via RVI): A retelling of how a small economically savvy immigrant community came to dominate the US motel industry.
While some of us were sleeping, a remarkable revolution has taken place. In the past 25 years, members of the Asian American Hotel Owners Association (AAHOA) acquired more than 20,000 hotels with more than one million rooms. This represents more than 50 percent of the economy lodging properties in the U.S. and 40 percent of all hotel properties including many upscale hotels. If you bear in mind that Indian Americans constitute less than one percent of America's population, the achievement appears extraordinary. The market value of these hotels totals about $40 billion.

2. From Unmitigated Disaster to Merely Disaster by John Maudlin (via Joe Koster): A pdf document which seeks to explain in plain English, the confusing mess that Deepwater Horizon has become, although I must admit some unease because of excessive reliance on a single source. A nice read, however.
But here is the good news. It turns out that there are about the equivalent of two Exxon Valdezes a year from natural oil seepage from the floor of the oceans. The Gulf has an ecosystem of bacteria that eat that oil, which are then eaten again by plankton. To those bacteria, dispersed oil is filet mignon. They thrive and grow rapidly, turning that toxic waste into nutrients, which are absorbed by the plankton. The bacteria keep on growing until they lose their source of nutrition (the toxic oil) and then die out over time. Note: once absorbed by the bacteria, the oil is no longer toxic. There are no toxic minerals like mercury introduced into the ecosystem.

Scientists are somewhat baffled. There are tens of millions of gallons of oil that seem to be missing. It seems that the Gulf is providing its own (albeit chemically assisted) defense mechanism. Overton thinks that within less than five years, and maybe only a few years, the ecosystem will largely be back.

Monday, August 16, 2010

On English accents

You may have heard this before, but the great state of Arizona thinks that heavily accented teachers may be a bad influence on school kids, who are still in the process of developing their language skills. 

As an academic, and non-native speaker of English, the issue strikes fairly close to home. But the exact nature of my discomfort is somewhat indirect.

Let me explain.

I came to the United States almost exactly 11 years ago. Like almost everyone else, I was initially amused by differences in American spellings ("color" not "colour","check" not "cheque") , pronunciations ("zee" not "zed", "semi"), and syntax ("meet with me"). However, over a period of time, I internalized this "fork" of standard English, like almost everybody else around me. 

Indeed, many Americanisms felt more natural, and less contrived ("meter" over "metre").

Over the last decade, I have also noticed that my speech indeed sounds different, depending on the environment I find myself in. The amount of "Indian" or "American" accent that gets dialed in, is variable - even at the risk of sounding inauthentic or phony.

Recently, I visited my 7 year old niece, who has lived in England for the past five years. During the first 2-3 days, I was amazed that she had not yet fully picked up a British accent, since most immigrant kids of that age in the US usually do.

Then, one day we visited one of her friends, and boy, did she sound different! She spoke without the slightest trace of an Indian accent. 

Even as a kid, she was calibrating her speech to her audience!

Whether the motivation was efficient communication, or not sounding like an outsider, I still don't know.

Friday, July 30, 2010

"What did Paul J. Flory do?"

This summer, I had a undergraduate student, Joshua Worch from Manchester College, Indiana, work with me on a NSF-REU funded project. After we wrapped up his practice talk this week, he said, "Did you know Paul Flory went to my college?"

This was priceless trivia, especially since Manchester College is a small (~1000 undergrads) liberal arts school.

Paul J. Flory, for the uninitiated, is a towering figure in polymer physics and chemistry, a Nobel Laureate, and the author of some of the most seminal papers in my research area.

Seeing that he had piqued my interest, Joshua added that the inventor of Teflon (Roy Plunkett) also went to school there (incidentally, both Plunkett and Flory got their PhDs from Ohio State, sworn nemesis of my alma mater, Michigan).

He then said many people at his school thought that it was Plunkett who got the Nobel Prize, because of his famous accidental discovery of Teflon.

As I was correcting him, he asked me, "So, what did Paul J. Flory do exactly?"

A part of me did not know where to start, and a part of me had a hard time pinning down his "one crowning achievement" - his record was littered with so many of them.

In fact even his Nobel citation reads, "for his fundamental achievements, both theoretical and experimental, in the physical chemistry of macromolecules."

Not much help there, huh!

Wednesday, July 28, 2010

Handwriting

I came across this not-very-surprising summary of a research report on how legible handwriting earns better grades, in the Editor's choice portion of a recent Science magazine (the original citation Soc. Psychol. Pers. Sci. 1, 230 (2010) is not available at my University).

Essentially, better handwriting earned an approximately 8% premium, for otherwise identical essays.

When evaluators are made aware of this bias, the premium disappears.

It served as a painful reminder of how shoddy my own handwriting has become.

Thursday, July 22, 2010

Two video links

1. I found myself  needing a quick introduction to the principles underlying NMR, and found this series of introductory videos on YouTube.
2. I found out about Khan Academy (a different Salman Khan!) which has videos on thousands of science/math topics via Sol.

Monday, June 21, 2010

Perverse Incentives

From an institutional standpoint, developing a fair incentive structure is extremely important. Many of the excesses on Wall Street are great examples of incentive schemes gone awry.

I read Roger Lowenstein's "The End of Wall Street", a couple of months ago. It presents the circumstances that led to the Enrons and MCI Worldcoms of the last big crisis on Wall Street. Besides telling a great story, it fleshes out a laundry list of perverse incentives that were structured to encourage the very irresponsible behavior, that eventually undermined the system.

Auditors, encouraged by the consulting business that writing lax reports would bring to their parent companies (think Arthur Anderson, but most big accounting firms were complicit in some form) allowed, and even crafted the bogus accounting smoke and mirrors, that was their fiduciary duty to reveal. Board members, received cushy salaries, for doing everything like schmoozing, playing golf together, etc., everything that is, but their job - keeping an eye on the management on behalf of the shareholders. The list goes on and on: stock analysts, politicians, stock-options, CEO compensation plans, etc.

Very few incentives in the system, encouraged the right behavior.

The reason I bring this up, is because academia is beset by many of the same afflictions.

Incentive schemes are just as perverted inside our campuses, as on Wall Street.

Funding has become the primary metric of scientific worth.

I know this is an over-generalization, but sadly it is also extremely close to mantra that guides most research universities in the US.

The university gets to keep 1/3 of the funds as overhead, which keeps the administration happy, especially in these times of declining governmental support. Funding lets the researcher hire more grad students and post-docs, which keeps the departments happy, since they can boast about the great number of degrees awarded.

Since this is the "path to happiness", everybody wants to raise a lot of money.

Thanks to the modern word processor, it is easy to flood the systems at NSF, NIH with proposals, with the hope that one of them hits the jackpot. This directly leads to a broken review system, with low acceptance rates, which unfairly, but understandably, favors well-connected big-shots and academic rock-stars with name recognition and a fan following.

Because of low acceptance rates, the amount of time wasted on writing proposals is a huge time sink, which draws resources away from places where they could be deployed more fruitfully: for example, to advance science, instead of fundraising.

The scientist suffers. Science suffers.

We probably overproduce PhDs, again due to perverse incentives. The reputation of a university is often built on the shoulders of its graduate program. Many of these PhDs now spend a lot of time looking for their first real job.

Economics instructs me to diagnose this evidence as an excess of supply over demand.

The grad student suffers.

There are many other manifestations of this perverse incentive scheme, including sky-rocketing journal subscription fees, the cancer of cheap, for-profit journals which exist only to pad resume's of scientists too busy writing proposals, the near complete break-down of peer review in many hot fields, which publish garbage, and random SEM images with reckless abandon, the toll that all this takes on teaching core classes, diluting the learning experience for students.

Most of these ills exist and flourish, because somewhere the incentive structure was compromised.

That good science still happens is a miracle. It is despite, not because of, the system.

Wednesday, June 16, 2010

Links

1. Steven Stogatz's popular columns on the elements of mathematics in NYT, are now all available at one convenient location.

2. A bunch of game theory lessons (videos) now available as a playlist on YouTube here. I was first introduced to game theory via Richard Dawkins popular books. I found, and continue to find, the link between basic math, logic, psychology, and economics endlessly fascinating.

3. The computing power of the first supercomputers and many mobile phones are now comparable. The funny thing is that I didn't even raise an eyebrow when I read the blog, despite my natural tendency for skepticism.

Sunday, June 6, 2010

John Hussman Commentary

I find John Hussman's weekly commentaries on financial markets very informative, mostly because they are very different from noise that important looking "experts" with (faulty?) crystal balls spew on CNBC. Sometime back, I linked to this page, which clearly demonstrates that forecasters, as a group, merely extrapolate the past into the future.

This is a great disservice, because most of the numbers that these experts divine, pretty useless from a practical standpoint. In addition, the mask of conviction with which these experts conduct themselves instills a false sense of confidence in people who like to listen to such talking heads.

I like John Hussman's balanced commentaries because of the how heavily he uses concepts of probability, and Bayesian inference in his analysis. I wish they taught this stuff more widely. For example, in his most recent commentary linked above, he comments about the Gulf of Mexico oil-spill:
With regard to oil spills, however low one might have believed P(we'll have an oil spill) to be, prior to the recent accident, the "prior" probability estimate should change given that we've now observed one of the worst oil spills in history. Even if the oil industry previously argued that the probability of an oil spill was one in a million, it's hard to hold onto that assessment after the oil spill occurs, unless your faith in the soundness of the technology is entirely unmoved in the face of new information.
(John Maynard Keynes would have paraphrased it as: "When the facts change, I change my mind. What do you do sir?")

Hussman goes on to do a back-of-the-envelope calculation which suggests that since the number of deep sea oil rigs has increased dramatically, the chances of seeing catastrophic oil spills are actually quite significant.

Friday, May 21, 2010

Bike to work week

Generally, "Hallmark events", which seem to have strangely proliferated in recent years, evoke a mildly derisive response in me, for their crass commercialism. That way they can sell more cards, restaurants can populate slow week-nights, and essentially somebody, somewhere, can get the wheels of businesses rolling.

Last week (May 17-21) was national "bike to work" week, and it was a pleasure to see more than the usual number of folks grinding away the streets of Tallahassee. As for myself, I could not avoid driving on Tuesday, but still 4/5 is not too shabby.

Here are a few nice local bicycling related links:

1. Capital City Cyclists: a Tallahassee based cycling club, mostly focused on biking for recreation, and competitions - but useful local information for commuters as well.

2. Tallahassee Mountain Bike Association: maps of trails and pictures, which are useful because you don't have to commute the same route as you drive.

3. SharetheRoad: a Canadian site with plenty of interesting information (so not really local :) )

Monday, May 10, 2010

Vizualizing Orientation Tensors with Matlab/Octave

Recently, I had to vizualize the standard fiber orientation tensor A=<pp> where p is the orientation of a single fiber as shown in the figure below, and the angular brackets denote an average over the distribution function. Although, I explicitly refer to the fiber orientation tensor in this blog, the discussion below is valid for any symmetric tensor, such as a stress tensor, for example.


For some simple cases, the tensor has a direct physical meaning:

For non-simple cases, it can be tricky to mentally visualize the tensor. However, if we calculate the eigenvalues and eigenvectors of the matrix A, visualizing the distribution can be done easily by drawing an ellipsoid. The ellipsoid points in a direction determined by the eigenvectors and the shape and size of the ellipsoid is determined by the eigenvalues.

I modified some code (VizOrient.m) that I found online. It works fine with any relatively recent version of Matlab and Octave 3.0 and higher. Below are five examples:

A=[0.45 0 0; 0 0.45 0; 0 0 0.1];
VizOrient(A);
A=[0.90 0 0; 0 0.05 0; 0 0 0.05];
VizOrient(A);
A=[0.33 0 0; 0 0.33 0; 0 0 0.33];
VizOrient(A);
A=[0.33 0.1 0; 0.1 0.33 0; 0 0 0.33];
VizOrient(A);
A=[0.45 0.2 0; 0.2 0.45 0; 0 0 0.1];
VizOrient(A);

The only problem with Octave is actually a problem with gnuplot. The statement "axis equal" is not strictly implemented, and hence some mental gymnastics could be required. Works great on Matlab, though.
 
References:
1. Chung and Kwon, Korea-Australia Rheology Journal, 14(4), 2002, 175-188

Code:
function VizOrient(A)
%
% take a 3x3 fiber orientation (symmetric) matrix A, and visualize the 
% resulting ellipsoid. using a program from Nima Moshtagh, and erasing the 2D
% lines - also correcting the meaning of a, b, and c axes (1/a)
%
%------------------------------------------------------------------------------
% Copyright (c) 2009, Nima Moshtagh
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without 
% modification, are permitted provided that the following conditions are 
% met:
%
%    * Redistributions of source code must retain the above copyright 
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright 
%      notice, this list of conditions and the following disclaimer in 
%      the documentation and/or other materials provided with the distribution
%      
%THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
%AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
%IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
%ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
%LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
%CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
%SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
%INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
%CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
%ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
%POSSIBILITY OF SUCH DAMAGE.
%------------------------------------------------------------------------------
N       = 20;
[U D V] = svd(A);
 
%----------------------------------
% generate the ellipsoid at (0,0,0)
%----------------------------------
a = D(1,1);
b = D(2,2);
c = D(3,3);
 
[X,Y,Z] = ellipsoid(0,0,0,a,b,c,N);
    
%-------------------------
% rotate and the ellipsoid
%-------------------------
 
XX = zeros(N+1,N+1);
YY = zeros(N+1,N+1);
ZZ = zeros(N+1,N+1);
 
for k = 1:length(X),
  for j = 1:length(X),
    point = [X(k,j) Y(k,j) Z(k,j)]';
    P = V * point;
    XX(k,j) = P(1);
    YY(k,j) = P(2);
    ZZ(k,j) = P(3);
  end
end
 
%-----------------
% Plot the ellipse
%-----------------
surf(XX,YY,ZZ);
xlabel('x');
ylabel('y');
zlabel('z');
axis equal
hidden on
 
end

Saturday, May 1, 2010

Why do you follow the news?

A few years ago, a friend I played ultimate frisbee with in Ann Arbor, asked me that question.

"Why do you follow the news?"

I bumbled a five-minute response, which was sprinkled with phrases like "it is a good habit", "we do not live in isolation", "it allows me to respond to emergencies", and other such platitudes.

Truth be revealed: I thought my answer was pathetic, and figured that if I really thought about the question for sometime, I would be able to come up with something less wimpy.

Part of the obsession to stay on top of the news was certainly an addiction. Reading the news/blogs was a daily fix. But addictions are hard to defend. So I gave up on that.

Part of the motivation was very pedestrian: reading the news helped with small-talk, which, while easy to belittle, lubricates conversations with people, just outside your first circle of friends. For example, following college football closely, allowed me to engage people I shared nothing else with, for long hours. Following a little celebrity gossip, likewise, had some twisted merit.

"Hmm, I may be getting somewhere with this",  I thought. I tried to generalize that sentiment into something grand: "following the news helps us participate in a shared culture", or some such BS.

But even that approach had a problem.

If that "shared culture" was being synthesized by the popular media (which I don't have a very high regard for), then perhaps it really wasn't that desirable!

In the end, I came up with something that went along the lines of, "We live in a democracy. Leaders that we elect, influence our futures. The process of choosing our leaders is best served, if we are aware of the world. Ergo."

Wimpy, I know.

Friday, April 30, 2010

A sed one-liner for LaTeX

Sometime in the near past, I posted my regex cheat sheet. With "sed" you can make regex work. For those not in the know:
sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
But that doesn't really tell you much. Here is an excellent tutorial by Bruce Barnett. Here are explanations to some great one liners.

Today, I had to do something to a LaTeX manuscript, I have been working on for a few months: I finally made up my mind on which journal to send it to. While LaTeX in conjunction with natbib and BiBTeX is great for re-formatting, there was one issue that needed to be weeded out.

I wrote the manuscript using Nature citation style (compressed numerical superscripts) by using \cite commands after punctuation marks like commas and periods. The new place I wanted to send it to required author-year formatting before punctuation marks. Basically transform something like
This is known from previous studies.1-3
to,
This is known from previous studies (Smart and Boss, 1990; Smarter et al., 2005; Smartass 2011).

Normally, this would be a fairly tedious manual exercise. But sed reduces the task into a one liner.


sed 's/\([,.;:]\)\\cite{\([A-Za-z0-9, ]*\)}/ \\citep{\2}\1/g' doc0.tex > doc1.tex

Let me parse the command.

sed 's/xxx/yyy/g' doc0.tex > doc1.tex

substitutes (the s/) all matches (the /g' at the end for global substitution) of "xxx" in the file doc0.tex with "yyy" and writes it into a new file doc1.tex. So far it is a simple find and replace, which could have been done easily in most editors.

The real magic is the "xxx" and "yyy" in the original command. The [,.;:] matches any of the usual punctuation marks that precede a \cite declaration. Parenthesis \ ( and \ ) mark stuff to be remembered and \1, \2 etc puke it out. Thus,
echo abcd123 | sed 's/\([a-z][a-z]*\).*/\1/'
abcd

The \\ is required to protect the \, which has special meaning. The rest is plain old regex matching.

Saturday, April 24, 2010

Should teachers be judged based on student evaluations?

The case certainly can be made for including student surveys as one part of a teacher's overall evaluation. I understand and respect student opinion, as an important component for designing a continuous improvement strategy. Nevertheless, I have a problem, when they are used as the primary source of a teacher's evaluation.

One of my colleagues emailed me this story.
Dominique G. Homberger won't apologize for setting high expectations for her students. The biology professor at Louisiana State University at Baton Rouge gives brief quizzes at the beginning of every class, to assure attendance and to make sure students are doing the reading. On her tests, she doesn't use a curve, as she believes that students must achieve mastery of the subject matter, not just achieve more mastery than the worst students in the course. For multiple choice questions, she gives 10 possible answers, not the expected 4, as she doesn't want students to get very far with guessing.
Students in introductory biology don't need to worry about meeting her standards anymore. LSU removed her from teaching, mid-semester, and raised the grades of students in the class. In so doing, the university's administration has set off a debate about grade inflation, due process and a professor's right to set standards in her own course.

My state of Florida even tried to take the idea too far: directly connect teachers pay increases to students performance. Thankfully, the governor vetoed it.

As I read somewhere, how would law-makers like it if their pay increases were connected to the performance of the laws they passed (how many laws were successfully obeyed, or any such metric)?

Sunday, April 18, 2010

Diligence v/s Intelligence?

As a product of the JEE myself, I have been reading both positive, and negative reactions to changes proposed for admitting students into the IITs, with much interest.

Board Exams = Diligence?
Many years ago, I used to think doing well on board exams had to do with being diligent. Putting in long hours redoing fairly standard problems/questions, committing large amounts of data to memory (processing it was completely optional), learning to present material neatly etc. The exam paper itself, was never a surprise.

JEE = Intelligence?
The JEE on the other hand was quite the opposite (I suspect that coaching classes changed the equation somewhat). Very few problems were standard, and clearly required some degree of processing. No amount of sheer practice could substitute for the "think on your feet" aspect of the exam. Clearly, I use the label "intelligence" quite loosely to describe this quality of the selection criteria.

I don't want to imply that diligence and intelligence are orthogonal in any sense. And a completely different issue (and one that my colleagues and I talk about quite a bit, in the context of what makes for good grad-student/scientists) is what is more desirable?

One fairly important person said something about "99% perspiration", and while I could bicker about the percentages, my thoughts are in alignment.

Thursday, April 8, 2010

Detaching from terminals using GNU screen

GNU screen is a Linux utility, that I did not know much about it, until a couple of years ago. It is a very handy program, and I'll start with my most frequent use of the utility.

If you use Linux, you like terminals. Let's say you start a program like Firefox or emacs from the terminal, by issuing a command like

$ emacs &

The program runs in the background and let you do other work in the terminal. However, when you exit the terminal, by either typing exit or closing the terminal window, your program (emacs in this case) is also killed.

GNU screen allows you to detach the program from the particular terminal from which it was invoked, thereby letting the program persist beyond the life-time of the terminal.

It is very simple to use. Fire your program from a terminal, in background mode.

$ emacs &

Then invoke screen (preinstalled on pretty much all Unix like systems)

$ screen

You may see that the title of your terminal window has changed somewhat, but that is not important.

You now type Ctrl-A d. You should see something like [detached] echoed on your screen.

Now go ahead, and kill your terminal.

Your emacs window persists!

Magic!

There are several other good uses for screen. You could fire programs like Thunderbird, Firefox, emacs etc. from a terminal and leave them running for months. If you've logged into a remote server, screen can function as a multiplexer (multiple tabs).

There are a number of places to learn more about screen. Here are some of them.