Monday, April 21, 2008

Sudden abstractions

verbatim from "Young Archimedes" by Aldous Huxley, 1928

(an English family spends a year in Italy and their young child befriends an older peasant boy)

"Though fully two and a half years older than little Robin - and at that age thirty months are crammed with half a lifetime's experience - Guido took no undue advantage of his superior intelligence and strength. I have never seen a child more patient, tolerant and non-tyrannical. He never laughed at Robin for his clumsy efforts to imitate his own prodigious feats; he did not tease or bully, but helped his small companion when he was in difficulties and explained when he could not understand. In return, Robin adored him, regarded him as a model and perfect Big Boy, and slavishly imitated him in every way he could.

"These attempts of Robin's to imitate his companion were often exceedingly ludicrous. For by an obscure psychological law, words and actions in themselves quite serious become comic as soon as they are copied; and the more accurately, if the imitation is a deliberate parody, the funnier - for an overloaded imitation of someone we know does not make us laugh so much as one that is almost indistinguishably like the original. The bad imitation is only ludicrous when it is a piece of sincere and earnest flattery that does not quite come off. Robin's imitations were mostly of this kind. His heroic and unsuccessful attempts to perform the feats of strength and skill, which Guido could do with ease, were exquisitely comic. And his careful, long-drawn imitations of Guido's habits and mannerisms were no less amusing. Most ludicrous of all, because most earnestly undertaken and most incongruous in the imitator, were Robin's impersonations of Guido in a pensive mood. Guido was a thoughtful child given to brooding and sudden abstractions. One would find him sitting in a corner by himself, chin in hand, elbow on knee, plunged, to all appearances in the profoundest meditation."

...

(Guido is discovered to have a gift for mathematics.)

"This child, I thought, has had the fortune to be born at a time when he will be able to make good use of his capacities. He will find the most elaborate analytical methods lying readily to his hand; he will have a prodigious experience behind him. Suppose he had been born while Stonehenge was building; he might have spent a lifetime discovering the rudiments, guessing darkly where he might have had a chance of proving. Born at the time of the Norman Conquest, he would have had to wrestle with all the preliminary difficulties created by an inadequate symbolism; it would have taken him long years, for example, to learn the art of dividing MMMCCCCLXXXVIII by MCMXIX. In five years, nowadays, he will learn what it took generations of Men to discover."

(Alas the story ends sadly for the fictitious young Guido, while happily for all of us in real life, the analogy breaks down. Clearly Guido should have contrived to be born not just in the modern age but also in Holland...)

Now let me think a minute, son


Ah, yes, that can be easily done...

Sunday, March 30, 2008

More Python and Climate

Apparently my rants got linked by GravityLoss, who understands that I am saying something about Python and about modern methodologies, but apparently isn't sure exactly what.

Here's my reply:

Hi and thanks for the links.

Make no mistake, I am a Python fanboy. I really doubt it's possible to do much better than Python at our present level of understanding of how to control computers.

As Paul Graham explains, any assertion that a more advanced technology Y is better than technology X tends to fall on deaf ears on users of technology X, because what they think is doable is defined by technology X. It is perfectly possible to get no advantage from Y because it is always possible to do X-like things with it.

I am proposing to do somewhat different things with Y. I am not the greatest expert on Y, but I do see things to do relevant things with Y that are not entirely X-like.

I would like to have software managers more experienced than myself involved. Google are the folk with the disposable wealth and the farsighted motivation as well as some of the relevant skills. I sort of wish they'd do what I want to do rather than leaving me scrambling to do it. I retain enough hubris to suggest that if they tried they'd do well to get me on the team. Realistically I probably will not have their help nor the help of an experienced software manager, though any pitching in from JM or JM would be most welcome.

There's nothing magic about Google or Python that aren't summed up in Clarke's Law: any sufficiently advanced technology is indistinguishable from magic. The sad thing is that much of the academy, including climate science, is far enough behind the cutting edge of what is possible that comparable productivity would look magical.

Friday, March 21, 2008

The elegance of Fortran

You know, the point of OOP is to SAVE work. 

Yes, the following is the most trivial and trite and pointless possible example of OOP.  I am not showing you code that is interesting. I am just comparing it with bolted-on OOP. Have a look at the Fortran equivalent. It's completely equivalent, note.

The "polymorphism" section form the Fortran is expressed in Python as an arbitrarily small amount of whitespace. And you thought whitespace was a drawback of Python!

def vectorsum(vec1,vec2):
...return map(sum,zip(vec1,vec2))

class Circle(object):
...def __init__(self,center,radius):
......self.center = center
......self.radius = radius

...def __str__(self):
......return "circle of radius %s at %s" % (self.radius, self.center)

...def move(self,translation):
......assert len(translation) == len(self.center)
......self.center = vectorsum(self.center, translation)

class Square(Circle):
...""" note: can inherit constructor for circle; treat radius as length"""
...def __str__(self):
......s = self.radius
......shifts = ((0,0),(0,s),(s,0),(s,s))
......corners = tuple([vectorsum(self.center,shift) for shift in shifts])
......return "square at points %s %s %s %s" % corners

Saturday, March 15, 2008

PyCon snippets

Stuff to look into:

iPy1: a spawned interpreter on every CPU

MPI4py: the winner for fine-grained parallelism

distributed NumPy array: Brian Granger

"it's like a beginner trying to make a souffle; you WILL get an egg dish"

stats.bayes.mvs

new buffer type in Py 3, Travis O in charge, imports NumPy arrays; PEP 3118

struct module

Amazon's elastic cloud; Pete Skomorock's ElastiWulf

Trestle

noonhat.com ; saturdayhouse.prg

pyxpcomext.com

freebase

argparse

orbited

math instruction in APL

if you want to start a conversation, ask a question

Friday, February 15, 2008

Insufficient, Inaccurate and Inconsistent

The data I mean...

The job of the geophysicist, I was told yesterday at a seminar given by Mrinal Sen, is essentially impossible. It is, given data that is insufficient, inaccurate and inconsistent to come up with a useful model.

Interestingly, it is unlikely that the skeptics' squad will make much of this admission, since the utility of the models Sen is specifically interested in is whether they correctly inform placement of oil well drilling efforts.

Nevertheless wells do get drilled. In the past it was a matter of some combination of analysis and intuition. Nowadays, statistics works in there as well.

Does climatology partake of these fundamental problems? Not as much as seismology, really; our observations are relatively accurate and consistent compared to seismic data. They are far from sufficient for long time scale processes, and the formalism of use of paleodata still leaves much to be desired.

Nevertheless, the future will happen, and we will do something about it. The question at hand for climate modelers and their customers is to what extent the models ought to affect what we do.

Computational geosciences and computational biological sciences are very different from computational engineering in flavor. In engineering (aside from civil and architectural, which partakes slightly of our problems) the system is entirely controlled and hence the tradeoffs between model expense and model accuracy are well understood. By contrast, our problem is to establish the right model based on observational data and theory.

This is called "inverse modeling" in some circles. I dislike the name and regret the loss of the appropriate term "cybernetics" to Hollywood and to some rather ill-defined corners of computer science. I propose, therefore, to call what some computational sciences do "meta-modeling", wherein the model itself (and the nature of its relationship to observation and theory) is construed as a legitimate object of study.

It is interesting how well-established this modality of thought is in mineral exploration (where there is, after all, a bottom line to take care of) and how controversial it remains in climate science. I have some thoughts as to why this might be. Some of the problems are directly a consequence of the unfairness of the unfair criticisms to which we have been subjected; this makes a fair assessment of fair crticisms fraught with peril. Others emerge from the history of the field and the social structures in which the work is performed.

It seems obvious to me that if the computational resources applied to climate go up several orders of magnitude, the correct approach to this is not, or at the very least not solely, to build a small number of immensely complex modeling platforms which use all the available computational power. Rather, it is to apply the (expensive but powerful) inverse modeling methodology to explore the model space of simpler models; to improve the expressiveness of model description languages; and to use these tools to build a much larger and more formal ensemble of climate modeling tools.

I also have a question whether the most policy-relevant models and the most science-relevant models are necessarily the same. I suspect otherwise. Climate modelers are so defended against the accusation of heuristics that they fail to apply the heuristics that might apply in an applied science effort.

Sen presented an interesting taxonomy of inverse methods at his talk. Much more to follow on this subject, hopefully.

Tuesday, February 12, 2008

Computational Silence

Still not sure whether to take Mr. Hughes seriously, even though he echoes some of my points. His latest looks pretty confused at first reading but it's far from my expertise. Maybe Eli will have a look.

That all said, I am not one who says all is right with computational climatology.

My friend JL sends along an article by (not captain) James Quirk that does a good job outlining the quandary and some of the efforts toward a solution. Climate science is particularly backward in adopting these measures. There's a misperception that all GCMs solve the same problem that is understandable in the public but hard to account for within the field.

The article is called "Computational Science: Same Old Silence, Same Old Mistakes". It appears in a volume on AMR. It is behind a Springer firewall, so if you can't get the PDF note that Google will display a scan of it.

(Remember, rationally, the less we trust the models the more severe our policy constraints on modifying the system should be.)