Pages

.

Paul Krugman and the polemical style of blogging


Just got back from the AEA Meeting, where I happened to run into a lot of cool bloggers, including Mark Thoma, Ryan Avent, Alex Tabarrok, Justin Wolfers, and Steve Landsburg. Unfortunately, I didn't get a chance to meet Paul Krugman.

Anyway, back to blogging! On the subject of Krugman, I've been wanting to write something about this Tyler Cowen post ever since I read it last week, but with job interviews coming up, I didn't have the time. So this post is a little late.

In his post, Cowen let loose with a broad criticism of Krugman's polemical blogging style:
Krugman a) regularly demonizes his opponents, including those who hold Krugman’s old positions, and b) doesn’t work very hard to produce the strongest possible case against his arguments... 
Can you imagine the current Krugman writing something sufficiently multi-faceted that you might come away thinking — because of the piece itself — that the opposing point of view was the better one?... 
Krugman has shown a remarkable and impressive capacity to reinvent himself, more than once.  He could reinvent himself again [to be less one-sided] and become the most important American public intellectual — and perhaps intellectual — of his time.  Or he could keep his current status as a sharp and brilliant someone who has an enormous number of followers but relatively little influence over actual events[.]
I don't know if I agree with this. Yes, Krugman writes in a polemical style. He mocks ideas that he thinks are nonsense, he accuses people of misunderstanding basic economics, and he occasionally accuses certain writers of dishonesty. Is this a bad thing?

I say: it depends on what the world needs right now.

I think you can approach an econ blog in one of two basic ways. Way #1 is to put your complete thought process on a page - to lay out both sides of an argument, and explain why you arrived at a conclusion. This is what Cowen calls the "Humean" method, after David Hume. As I see it, the Humean method is what you use if you want to get the most out of a discussion with a well-informed but fundamentally disinterested interlocutor. If your conclusion is right, then the Humean method is likely to convince such an interlocutor to reach the same conclusion. If your conclusion is wrong, it maximizes the chance that the well-informed but disinterested interlocutor will see where you went wrong and help you to correct your mistake.

But not all interlocutors are disinterested. Some have political agendas. Some have strong personal biases. And not all interlocutors are well-informed. So if one uses the Humean method of argumentation, it is quite possible that your carefully considered ideas will be opposed by a totally biased person who doesn't bother to be nearly as even-handed as you, because he just doesn't care. And this biased opponent may, through his vehemence and the artificial simplicity of his arguments, succeed in convincing many poorly-informed third party observers of his point of view, even if yours has the weight of logic and evidence behind it. And society may suffer as a result.

In this situation, it may provide the most social benefit to adopt a more Hegelian method of argumentation. Hegel's idea of how good conclusions are reached has been described as a process of "thesis, antithesis, synthesis" - two people argue their cases as strongly as possible, and observers can pick and choose the best points of each. This is how our court system works, for example. In the context of econ blogs, using a Hegelian approach means saying "My opponents are going to do everything they can to push their point of view, so I had better do the same in order to balance them out."

This seems to be what Krugman is doing. He writes:
I realized that I also wanted to say something in response to the concern trolling, the “if you were more moderate you’d have more influence” stuff. Again, this amounts to wishing that we lived in a different world. First, there is no such thing in modern America as a pundit respected by both sides. Second, there are people writing about economic issues who are a lot less confrontational than I am; how often do you hear about them? This is not a game, and it is also not a dinner party; you have to be clear and forceful to get heard at all.
In other words, he's adopting a polemic style as a Hegelian tactic, to balance out bad guys who pull no punches.

That's a pretty extreme tactic for an academic type to use. But I can understand why Krugman might use it. After all, he lived through the Bush years - he witnessed the power of loudly repeated lies to overcome even-handed reasonable argumentation, in the run-up to the Iraq War. It's hard to go through something like that, and, as a famous pundit, to think that just maybe you might have been able to stop the madness if you had been just a little more forceful and a little less "fair and balanced." It's less of a worry for me, but only because my audience is fairly limited.

Has Krugman's polemical style been self-defeating? Cowen claims that Krugman has "relatively little influence over actual events," but as evidence he cites only a link to an earlier post of his that asserts the same thing. I can see the case, of course. Krugman warned that Obama was too conservative during the 2008 primaries, but Obama won anyway. Krugman advocated bank nationalization, bigger fiscal stimulus, and a tougher policy toward China's exchange rate peg - all to no avail.

But does that mean Krugman has little influence? The idea of "Keynesian economics" has re-entered the mainstream non-economist public dialogue, largely thanks to Krugman. Fiscal stimulus, which was once advocated only in the middle of economic free-fall by technocrats like Larry Summers, has become a rallying cry for a large number of people who think policy should take a more active role. And, most of all, Krugman's assault on the macroeconomics profession itself has caused much of the public to turn on the practitioners of macro, spurring them to scramble for new ideas, new approaches, and new data.

You may think those results are good things, or not. But I think it's very hard to argue that Krugman has not been enormously influential. As to the question of whether he is the most important American public intellectual of our time...well, I'm having a hard time thinking of who else would fit that description.
reade more... Résuméabuiyad

Conservatism: Always at war with some part of America


More catch-up blogging...I'm overdue for a broadside against the conservative movement, so here goes.

Many people think of the conservative movement as basically nationalist. Think of a guy with an American flag decal on his truck. But I guess I've always seen the American conservative movement in a very different light - as a factionalist movement, concerned more with the balance of power within America than the strength of the country overall. (Naturally, this paints the movement with too broad a brush, but we'll get to that.)

As examples, take George Will and Rick Santorum. Here's George Will, in a recent New York Post column:
Imagine what a horror 2011 was for progressives as Americans began to comprehend their stunning abundance of fossil fuels...environmentalism as the thin end of an enormous wedge of regulation and redistribution is a spent force...Meanwhile,...sales of the electric-powered Chevrolet Volt were falling short of General Motors’ goals even before reports about fire hazards in crash tests. A Wall Street Journal headline proclaimed: “Americans Embrace SUVs Again.”
Why is George Will saying that General Motors' loss is a good thing for America? You'd think that a patriotic conservative - not to mention one who stands behind the business community - would want to see an American company's investments pay off. But George Will is cheering the failure of the Chevrolet Volt.

The reason is that the failure of the Volt represents not just a loss for GM, but a loss of face for a subset of Americans whom Will despises: environmentalists, whom Will thinks are merely crypto-socialists. The success of a product whose benefit is energy efficiency would lend credence to the claim that energy constraints are real; hence, in Will's mind, it is a good thing for us to spend more on energy just to prove that we have energy to waste. For this type of conservative, the Good Americans are those associated with the energy industry, and the Bad Americans are environmentalist crypto-socialists.

Or take Rick Santorum's statement on blacks and welfare:
At a campaign stop in Sioux City, Iowa on Sunday, Republican presidential hopeful Rick Santorum singled out blacks as being recipients of assistance through federal benefit programs, telling a mostly-white audience he doesn’t want to “make black people’s lives better by giving them somebody else’s money.”
The idea that all government spending is racial redistribution is so common on the right, and so widely accepted, as to be almost not worth saying out loud. I can't tell you how many times I've encountered this idea in conversations with conservatives. And pretty much every conservative rant against government spending, in the popular press or in stump speeches, is a dog-whistle for this very idea. For this type of conservative, the Good Americans are hard-working whites and the Bad Americans are lazy blacks living off the government teat.

Of course, as an aside, both of these worldviews rely on claims for which there is little factual support. George Will cites the fact that America is now a net exporter of petroleum products, but that figure is for refined petroleum products only - if you include crude petroleum products, we still have a monster deficit. Closing our eyes and wishing really hard that we were Saudi Arabia is not, and will never be, a viable strategy for national prosperity. As for Santorum, he ignores the fact that a disproportionate number of the people on food stamps are white (84%, compared to about 80% of the populace).

Naturally, the facts are irrelevant to these factionalists. Factionalists imagine themselves to be part of a tribe, and tribal knowledge beats actual knowledge nearly every time.

I believe that this factionalism is hurting our nation, by paralyzing the political process and by reducing government investment to a below-optimal level. This is the main reason I am so strongly opposed to the American conservative movement. Naturally, liberals have been factionalist at times as well, but the strength of the conservative tribal consciousness - especially with regards to race and the "racial redistribution" worldview - is just much greater right now than anything on the left.

But there is hope. I've been reading articles by conservatives like Reihan Salam, Ramesh Ponnuru, and Peter Thiel that have a much more nationalist flavor, including greater support for government investment (and I've seen hints that Bill O'Reilly has started to think along these lines as well). Our current tendency toward factionalism grew out of the long period of peace and plenty between World War 2 and the Bush years, when the only real question was how to divide the American pie. With the lost decade(s) and the waning of American power, it's becoming more painfully clear to people on both the right and the left that factionalism is nothing more than a crippling distraction. But old habits die hard, and the poisonous notion of Good Americans vs. Bad Americans is still the right's dominant paradigm. 
reade more... Résuméabuiyad

Some Thoughts on Writer's Block

Having made a living as a writer for more years than I'd like to admit, I've devoted quite a bit of time and thought to writer's block over the years, and it strikes me that a quick brain-dump on the subject might help others of my kind out there who occasionally struggle with the process of committing words to paper (or electrons to æther, as the case may be), especially since (as I look at what others have written about writer's block) it seems I come at the question of writer's block from a bit of a different direction than others do. Which may or may not be helpful.

Some people go so far as to say writer's block is not real. Which is total nonsense, of course. Writer's block is as real as tooth decay. What makes it fascinating is that "writer's block" has no parallel at the level of other seemingly ordinary daily activities. Eaters don't experience Eater's Block. Walkers don't experience Walker's Block. Why, then, is "writer's block" such a problem?

It seems to me there are two broad categories of reasons why anyone runs into "writer's block" (let's not dignify it by capitalizing it). There are external reasons (e.g., I'm worried about XYZ, which is distracting me from writing), and internal reasons (e.g., I can't think of an opening sentence for this section of my paper). In the discussion that follows, I'm not going to deal with external blockers. That's something for you and your psychiatrist. It's the internal blockers that interest me, because those are the hardest, and the most intrinsic to the process.

The vast majority of instances of writer's block can be traced to just two problems. One is the fear of committing verbal crimes against nature (aka perfectionism). The second has to do with the inherent difficulty of the writing process (which is worth elaborating on). Maybe there's a third Main Problem, which is: Your understanding of whatever it is you intend to write about is so fluid, such a moving target, that you just can't see how you can possibly start capturing it in words. In other words, you're still in the process of making sense of whatever it is you're writing about. You feel nowhere near ready to reduce it to (static, frozen, immutable) text. That's a legitimate concern, but it has to do with the second issue, the inherent difficulty of the writing process.

When you begin to realize how difficult the writing process actually is, you will (or should) come to the realization that it's silly to beat yourself up. You absolutely should not beat yourself up when you're blocked. Instead, have great sympathy for yourself. Why? Because what you're attempting to do is, indeed, in a sense, heroic.

Here's the thing you have to realize about writing. The world of thought, of analysis, of understanding, of comprehension, is multidimensional. More than that, it is inherently reentrant, recursive, and iterative, which (therefore) also means it is nonlinear and ultimately chaotic (in the profoundest mathematical sense envisioned by Gleick in his classic book, Chaos). In your procrastination time, I strongly recommend that you read Gleick's Chaos book, because it will give you an unforgettable introduction to the nature of nonlinear systems. That's important, because nothing is more prototypically nonlinear than the thinking process.

When you're trying to understand something, you come at the subject from multiple angles. Invariably, there are many entry points to understanding. As you gain understanding, you add new ideas, then rethink/reprocess everything. The ripple effects are often far-reaching. But the salient point is: Your path to understanding is not a straight line. It's often a random walk in a multidimensional wonderland.

Now consider what the written form is. It's words arranged one after another in a linear chain. You're trying to reduce a multidimensional process to a linear form. This is why writing is difficult (heroic, even). It's a Quixotic quest to reduce the multidimensional to the unidimensional. Really, what could be more absurd?

Unlike the thinking process, a piece of writing has a definite starting point and a definite endpoint. Which is completely unreasonable. It is a sublimely unreasonable demand to say: "Take this complex multidimensional subject and reduce it to a string of words arranged linearly, one after the other." It's unlikely that whatever it is you're writing about has a definite beginning, middle, or end, or a naturally hierarchical top-down structure. Most things worth writing about are not neatly structured.

This, then, is the paradox of writing. The process of writing is a process of projecting multidimensional phenomena (concepts, thoughts, lines of reasoning) onto a one-dimensional wordspace, where words follow one upon the other in a linear string.

Totally unreasonable.

But there is hope, because once you understand the built-in disjunction between wordspace and thoughtspace, you can approach the writing process differently than you might otherwise have.

First of all, you can give yourself permission to enter the verbal space from any of a multitude of different directions. Your journalism teacher (or your seventh-grade writing teacher) may have told you that you have to begin at the beginning, and structure a discussion hierarchically, from the top down. But really, that's not true at all. That's not the way thinking works. Why should it be the way writing works?

Give yourself permission to enter a subject sideways, with an anecdote or a seemingly incidental aside. Don't think of your subject area (whatever it is) as a linear body of knowledge, because it isn't. Think of it as a giant collage. Your understanding of it is collage-like. Your job, as a writer, is to render the collage on paper (in wordspace), in a way that will ultimately be comprehensible to the reader. Chances are, the reader will not assail you for not taking a linear approach. Quite the contrary. He or she will thank you, most likely, for rendering a complex subject as a pastiche of digestible pieces: pieces of knowledge that, in the aggregate, make sense (because you have drawn the appropriate connections between the pieces). It's not important that you put "first things first" unless the subject demands it (in which case your job is easy, actually). It's more important that you lay down the major pieces of the collage intact, in a way that will make sense once the overall job is done.

So first of all: Give yourself permission to take unusual entry points into the discussion. Give yourself permission to start in the middle, or at the end. Sometimes, you can get good traction by simply listing your concluding points. What are the essential takeaways that you want to be able to deliver? Write them down quickly. Entry points will suggest themselves.

Another good heuristic is: Find the parts of your discussion that mean the most to you emotionally. Begin working on those first, if need be. That will give you good momentum. If you can write with conviction, if you can find aspects of the subject that resonate with you on an emotional level, by all means harness that.

The most important advice of all when you're blocked? Always, always, give yourself permission to write crap. You always need to give yourself license to write pure shit. When you're blocked, writing utter crap is better than sitting there staring at the blank page. So write some junk. You can come back to it later (or not) and pretty it up, make it acceptable. Right now, you just need to get moving.

From time to time, you may hear inner voices saying cruel things. "You're useless." "What you're writing is hopelessly bad." "You'll never make a dent in this, it's futile." What you should do is ask yourself: Is this your authentic adult self talking, or is it your child-self? If it's your inner child (which it almost always is), deal with it as you would deal with a petulent child. Firmly and politely say "That's enough now. I heard you. That's enough." If need be, give the child a time-out. ("Go sit in the corner for five minutes.") Don't let your inner child boss you around. It's not right.

And when you do start to make progress (as you inevitably will), take frequent opportunities to congratulate yourself. You're doing the impossible, after all, the heroic: You're committing thoughts to paper (or words to wordspace). You're reducing the multidimensional to the linear. That's something to celebrate. So celebrate it. And keep moving toward the shitstorm.
reade more... Résuméabuiyad

What are asset bubbles and why do they happen?


Tomorrow I'm going to go the American Economic Association's annual meeting, to interview for economics jobs. (For the uninitiated, most jobs that are specifically for new econ PhDs conduct interviews at this meeting, which is what most economists mean when they talk about "the job market.") One of the key elements of getting a job as an economist is to have a "job market paper," which is generally the first chapter of your dissertation, and which is what shows potential employers that you can do quality research. My job market paper is here in case you want to read it. I'm not going to spend a heck of a lot of time discussing the paper (that can wait until it's ready to send off to journals), but it gives me an opportunity to write a post I've been wanting to write for a while anyway, about the research that motivated my paper in the first place.

That research is the Vernon Smith "bubble experiments." "Bubbles, Crashes, and Endogenous Expectations in Experimental Spot Asset Markets" (Smith, Suchanek and Williams, Econometrica 1988) is definitely a Paper You Should Know.

What is a "bubble"? Well, it's something that looks like this:


Prices go way up, then they crash back down. Look at any long-term plot of any asset price index (stocks, housing, etc.) and you're likely to see some big peaks like this. That's what I call a "bubble." It's also the definition used by Charles Kindleberger in his book Manias, Panics, and Crashes.

But the real question is why we care about bubbles. Some people believe that bubbles are merely responses to changes in expected fundamental value of an asset (the "fundamental value" is the expected present value of  the income you get from owning an asset). According to this view, the NASDAQ bubble happened because people thought that internet companies were going to make lots and lots of profit, and when those expectations didn't materialize, prices went down again. This view is held by many eminent financial economists, including Eugene Fama, the most cited financial economist in the world.

If bubbles represent the best available estimate of fundamental values, then they aren't something we should try to stop. But many other people think that bubbles are something more sinister - large-scale departures of prices from the best available estimate of fundamentals. If bubbles really represent market inefficiencies on a vast scale, then there's a chance we could prevent or halt them, either through better design of financial markets, or by direct government intervention. For a discussion on theoretical reasons to believe or disbelieve that bubbles = departures from market efficiency, see this email exchange between Eugene Fama and Ivo Welch. Very good stuff.

But in the end, empirical reality has to have the last word. And here's the problem we run into when we try to answer the question by looking at the data: It's nearly impossible to know what fundamentals really are. So in 1988, Vernon Smith (now a Nobel laureate) had the idea of using lab experiments to study bubbles. In a lab experiment, the experimenter knows what the fundamental value is, so whether the price exceeds the fundamental can be known with a high degree of confidence.

So Vernon Smith and his co-authors put groups of subjects in a lab, gave them some cash, and let them buy and sell a computer-generated financial asset. The asset payed dividends to whoever held it, so its fundamental value was equal to the expected value of the dividends it paid (or less, since people might be risk-averse). So not only did the experimenters know the fundamental value of the asset, but the subjects themselves were told everything they needed to know to calculate the fundamental!

And guess what happened? Prices rose way above the fundamental value, and then crashed at the end of the market. Check out this graph of the prices from one of their experimental markets:


The black stair-step line is the fundamental value (it goes down, since the market has a fixed finite lifetime). The dots are prices at which subjects exchanged the asset. As you can see, prices went way above the expected value of the asset in periods 3 and 4, then crashed back down somewhere around periods 9 and 10.

You are looking at a bubble that is also a market inefficiency. It is real. It exists.

Now if we knew that the market in this lab experiment was the same as real-world financial markets, this graph would spell death for the Efficient Markets Hypothesis. Done. Kablooie.

But of course, we do not know that this market is the same as a real-world market. This market is 8 inexperienced college kids in a lab, trading about $200 worth of an asset that is very different from real-world assets, over a period of maybe an hour. Real-world markets are made up of thousands or millions of experienced traders trading trillions of dollars worth of assets, with plenty of time to make their decisions. In other words, the Smith, Suchanek, and Williams experiment does not instantly explode all of efficient-market financial economics, because it may lack external validity.

But if it does have external validity, it's the most important empirical result in all of financial economic history.

A lot of work has gone into figuring out whether the Smith-Suchanek-Williams result has external validity. On one hand, it's reliably true that when the same group of traders - or even part of the group - repeats the market 3 times in a row, there's no bubble. On the other hand, if you take those "experienced" traders and run the experiment with a different fundamental value process, the bubbles come back.

The Smith-Suchanek-Williams type experiment has been run with professional traders. It has been run with large numbers of traders. It has been run under various different market institutions - allowing short selling, using different kinds of markets, under various rules, etc. Always, the bubbles come back. As the list of "things that don't prevent lab bubbles" grows, so does the nagging feeling that this type of inefficient bubble may be a universal phenomenon.

But there is one critique of the Smith experiment that has never really been put to rest. What if subjects just fail to understand the fundamentals? Maybe subjects simply learn by doing. Maybe you can tell them the fundamentals, but they don't really understand and believe in the fundamentals until they've had some experience with seeing the dividends roll in. In fact, there is research to support this critique. For example, when you let the subjects watch the dividend process  before they trade, or when you explain the fundamental value in a different way, the bubbles disappear.

Nobody is really interested in a bubble that only happens because subjects are confused. It's easy to confuse a bunch of college kids. So this critique has limited the degree to which the "bubble experiment" literature has turned the financial econ world upside down.

That's where my job market paper comes in, actually. My experiment was about determining demand for assets in experimental markets - i.e., figuring out why people buy assets, not just whether markets lead to bubbles. Instead of the normal market setup, where all the traders trade with each other, I had traders who simply watched the prices that were produced by such a market, and then let them trade at those prices without affecting the price (think of this as one guy sitting at home buying and selling on E*trade; he's too small to move the market, but we can learn a lot from watching how he makes his decisions).

And one of the things I did was to ask my subjects how much dividend income they thought they would get from holding a share of the asset (i.e., the fundamental value). So I was able to tell who understood the fundamental value and who didn't. So I could tell if people who understood the fundamentals would knowingly overpay for the asset.

And guess what? They did. Even people who understood exactly how much the asset was worth were overwhelmingly likely to pay, say, 60 yen for a share of the asset (the experiment was run in Japan), even when the most dividend income they could possibly get for it was only 40 yen. They gave up certain gains. (Why on Earth did they do this? Well, that's what the rest of the paper is about, and is a subject for at least two other long blog posts.) So this result really answers one critique of the Smith bubble experiments: understanding what's going on is not sufficient to make subjects act like the "rational arbitrageurs" in financial economics models.

Now, that's only one critique of bubble experiments. It's impossible to answer them all. But science is a process of excluding causes one by one. The more uninteresting causes of bubbles we exclude, the closer we get to finding whatever interesting causes may exist.

To sum up: If we believed that Vernon Smith type bubble experiments could reliably show us how real financial markets work, the finance industry would be falling over itself to do a billion lab experiments, and both business and government would have to seriously rethink policies that depend on markets being efficient (e.g., stock options for executives). But the jury is still out. Still, the bubble result of Smith, Suchanek, and Williams (1988) is one of the most important experimental findings in the history of economics, and a research effort to which I am happy to (attempt to) contribute.
reade more... Résuméabuiyad

Turbulence in HTML5 Canvas

This is a screenshot of the shader UI showing what basic turbulence looks like.
As an update to my earlier post on procedural texturing in HTML5 canvas, I wanted to post an improved (faster) version of the earlier code that also incorporates a turbulence function, which is probably more properly called fractal noise.

First, hat's off to Ryan Sturgell for pointing out that by moving the big array initialization outside of the this.noise = function() call, it's possible to speed up the Perlin noise() function several-fold. Which should have been obvious, but I missed it on the first go-round. #doh

In any case, the noise() function in the improved code (below) now can process ~400K pixels per second, which is a significant improvement indeed.

Turbulence
The turbulence function adds Perlin noise of various frequencies together, like so:

function turbulence( x,y,z, octaves ) {

var t = 0;
var f = 1;
var n = 0;

for (var i = 0; i < octaves; i++, f *= 2) {
n += PerlinNoise.noise(x * f, y * f, z)/f;
t += 1/f;
}
return n / t; // rescale back to 0..1
}

This has the net result of giving noise that is much more realistic for things like cloud textures or smoke. For example:


x /= w; y /= h; size = 5;
y = 1 - bias(y,.4);
n = turbulence(size*x,1.8*size*y,1-y,3);
y = Math.sqrt(y);
r = bias(y,.68) * n * 255;
g = r/1.22;

This code uses turbulence to generate the cloud pattern and bias() to stretch the sky a bit at the top (and stretch the red value vertically as well).

Without further ado, here's the complete code for the shader page. Copy and paste all of the following code into a text file and give it a name that ends with .html. Then open it in Chrome, Firefox, or any HTML5-capable browser.

<html>
<head>
<script>

// A canvas demo by Kas Thomas.
// http://asserttrue.blogspot.com
// Use as you will, at your own risk.

context = null;
canvas = null;

window.onload = function(){

canvas = document.getElementById("myCanvas");
canvas.addEventListener('mousemove', handleMousemove, false);
context = canvas.getContext("2d");
loadHiddenText();
}

function loadHiddenText( ) {

var options = document.getElementsByTagName( "option" );
var spans = document.getElementsByTagName( "span" );

for (var i = 0; i < options.length; i++)
options[i].value = spans[i].innerHTML;
}

// should probably be called resetCanvas()
function clearImage( ) {

canvas.width = canvas.width;
}

function drawViaCallback( ) {

var w = canvas.width;
var h = canvas.height;

var canvasData = context.getImageData(0,0,w,h);

for (var idx, x = 0; x < w; x++) {
for (var y = 0; y < h; y++) {
// Index of the pixel in the array
idx = (x + y * w) * 4;


// The RGB values
var r = canvasData.data[idx + 0];
var g = canvasData.data[idx + 1];
var b = canvasData.data[idx + 2];

var pixel = callback( [r,g,b], x,y,w,h);

canvasData.data[idx + 0] = pixel[0];
canvasData.data[idx + 1] = pixel[1];
canvasData.data[idx + 2] = pixel[2];
}
}
context.putImageData( canvasData, 0,0 );
}

function fillCanvas( color ) {

context.fillStyle = color;
context.fillRect(0,0,canvas.width,canvas.height);
}

function doPixelLoop() {

var code = document.getElementById("code").value;
var f = "callback = function( pixel,x,y,w,h )" +
" { var r=pixel[0];var g=pixel[1]; var b=pixel[2];" +
code + " return [r,g,b]; }";

try {
eval(f);
fillCanvas( "#FFFFFF" );
drawViaCallback( );
}
catch(e) { alert("Error: " + e.toString()); }
}



function handleMousemove (ev) {

var x, y;

// Get the mouse position relative to the canvas element.
if (ev.layerX || ev.layerX == 0) { // Firefox
x = ev.layerX;
y = ev.layerY;
} else if (ev.offsetX || ev.offsetX == 0) { // Opera
x = ev.offsetX;
y = ev.offsetY;
}

document.getElementById("myCanvas").title = x + ", " + y;
}

// This is a port of Ken Perlin's Java code.
PerlinNoise = new function() {

var p = new Array(512)
var permutation = [ 151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
];
for (var i=0; i < 256 ; i++)
p[256+i] = p[i] = permutation[i];

this.noise = function(x, y, z) {



var X = Math.floor(x) & 255, // FIND UNIT CUBE THAT
Y = Math.floor(y) & 255, // CONTAINS POINT.
Z = Math.floor(z) & 255;
x -= Math.floor(x); // FIND RELATIVE X,Y,Z
y -= Math.floor(y); // OF POINT IN CUBE.
z -= Math.floor(z);
var u = fade(x), // COMPUTE FADE CURVES
v = fade(y), // FOR EACH OF X,Y,Z.
w = fade(z);
var A = p[X ]+Y, AA = p[A]+Z, AB = p[A+1]+Z, // HASH COORDINATES OF
B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z; // THE 8 CUBE CORNERS,

return scale(lerp(w, lerp(v, lerp(u, grad(p[AA ], x , y , z ), // AND ADD
grad(p[BA ], x-1, y , z )), // BLENDED
lerp(u, grad(p[AB ], x , y-1, z ), // RESULTS
grad(p[BB ], x-1, y-1, z ))),// FROM 8
lerp(v, lerp(u, grad(p[AA+1], x , y , z-1 ), // CORNERS
grad(p[BA+1], x-1, y , z-1 )), // OF CUBE
lerp(u, grad(p[AB+1], x , y-1, z-1 ),
grad(p[BB+1], x-1, y-1, z-1 )))));
}
function fade(t) { return t * t * t * (t * (t * 6 - 15) + 10); }
function lerp( t, a, b) { return a + t * (b - a); }
function grad(hash, x, y, z) {
var h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE
var u = h<8 ? x : y, // INTO 12 GRADIENT DIRECTIONS.
v = h<4 ? y : h==12||h==14 ? x : z;
return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
}
function scale(n) { return (1 + n)/2; }
}

function turbulence( x,y,z, octaves ) {

var t = 0;
var f = 1;
var n = 0;

for (var i = 0; i < octaves; i++, f *= 2) {
n += PerlinNoise.noise(x * f, y * f, z)/f;
t += 1/f;
}
return n / t; // rescale back to 0..1
}

// Perlin's bias function
function bias( a, b) {
return Math.pow(a, Math.log(b) / Math.log(0.5));
}

</script>
</head>

<body>
<canvas id="myCanvas" width="300" height="300">
</canvas><br/>

<input type="button" value=" Erase "
onclick="clearImage(); "/>

<select onchange=
"document.getElementById('code').innerHTML = this.value;">
<option>Choose something, then click Execute</option>
<option>Basic Perlin Noise</option>
<option>Basic Turbulence</option>
<option>Waterfall</option>
<option>Spherical Nebula</option>
<option>Green Fibre Bundle</option>
<option>Orange-Blue Marble</option>
<option>Blood Maze</option>
<option>Yellow Lightning</option>
<option>Downward Rainbow Wipe</option>
<option>Noisy Rainbow</option>
<option>Burning Cross</option>
<option>Fair Skies</option>
</select>

<br/>
<textarea id="code" type="textarea" cols="37" rows="7">/* Enter code here. Globals: r,g,b,x,y,w,h,PerlinNoise.noise(a,b,c) */</textarea>
<br/>

<input type="button" value=" Execute "
onclick="doPixelLoop();" />
<input type="button" value="Open as PNG"
onclick="window.open(canvas.toDataURL('image/png'))"/>


<!-- BEGIN HIDDEN TEXT -->
<div hidden="true">
<span>
// you can enter your own code here!
</span>

<span>
x /= w; y /= h;
size = 10;
n = PerlinNoise.noise(size*x,size*y,.8);
r = g = b = 255 * n;
</span>

<span>
x /= w; y /= h;
size = 10;
n = turbulence(size*x,size*y,.8,4);
r = g = b = 255 * n;
</span>

<span>
x/= 30; y/=3 * (y+x)/w;
n = PerlinNoise.noise(x,y,.18);
b = Math.round(255*n);
g = b - 255; r = 0;
</span>

<span>
centerx = w/2; centery = h/2;
dx = x - centerx; dy = y - centery;
dist = (dx*dx + dy*dy)/6000;
n = PerlinNoise.noise(x/5,y/5,.18);
r = 255 - dist*Math.round(255*n);
g = r - 255; b = 0;
</span>

<span>
x/=w;y/=h;sizex=3;sizey=66;
n=PerlinNoise.noise(sizex*x,sizey*y,.1);
x=(1+Math.sin(3.14*x))/2;
y=(1+Math.sin(n*8*y))/2;
b=n*y*x*255; r = y*b;
g=y*255;
</span>

<span>
centerx = w/2; centery = h/2;
dx = x - centerx; dy = y - centery;
dist = 1.2*Math.sqrt(dx*dx + dy*dy);
n = PerlinNoise.noise(x/30,y/110,.28);
dterm = (dist/88)*Math.round(255*n);
r = dist < 150 ? dterm : 255;
b = dist < 150 ? 255-r : 255;
g = dist < 151 ? dterm/1.5 : 255;
</span>

<span>
n = PerlinNoise.noise(x/45,y/120, .74);
n = Math.cos( n * 85);
r = Math.round(n * 255);
b = 255 - r;
g = r - 255 ;
</span>

<span>
x /= w; y /= h; sizex = 1.5; sizey=10;
n=PerlinNoise.noise(sizex*x,sizey*y,.4);
x = (1+Math.cos(n+2*Math.PI*x-.5));
x = Math.sqrt(x); y *= y;
r= 255-x*255; g=255-n*x*255; b=y*255;
</span>

<span>
// This uses no Perlin noise.
x/=w; y/=h;
b = 255 - y*255*(1 + Math.sin(6.3*x))/2;
g = 255 - y*255*(1 + Math.cos(6.3*x))/2;
r = 255 - y*255*(1 - Math.sin(6.3*x))/2;
</span>

<span>
x/=w;y/=h;
size = 20;
n = PerlinNoise.noise(size*x,size*y,.9);
b = 255 - 255*(1+Math.sin(n+6.3*x))/2;
g = 255 - 255*(1+Math.cos(n+6.3*x))/2;
r = 255 - 255*(1-Math.sin(n+6.3*x))/2;
</span>

<span>
x /= w; y /= h; size = 19;
n = PerlinNoise.noise(size*x,size*y,.9);
x = (1+Math.cos(n+2*Math.PI*x-.5));
y = (1+Math.cos(2*Math.PI*y));
//x = Math.sqrt(x); y = Math.sqrt(y);
r= 255-y*x*n*255; g = r;b=255-r;
</span>

<span>
x /= w; y /= h; size = 5;
y = 1 - bias(y,.4);
n = turbulence(size*x,1.8*size*y,1-y,3);
y = Math.sqrt(y);
r = bias(y,.68) * n * 255;
g = r/1.22;
b = 255 - r/2;
</span>
</div>
<!-- END HIDDEN TEXT -->

</body>

</html>


Incidentally, I did find a halfway-decent discussion of noise() and turbulence() online, written by Ken Perlin himself, at http://http.developer.nvidia.com/GPUGems/gpugems_ch05.html. Read it and reap!
reade more... Résuméabuiyad

Is debt a burden on future generations? It depends.


Does government debt impose a burden on future generations? Paul Krugman says no. Nick Rowe says yes. But they're talking about different things.

Paul Krugman asks: If we wake up in 2012 and find ourselves with $9 trillion in government debt, are we any worse off than if we wake up and find ourselves with zero government debt? Assuming that all of our government debt is held domestically (so that we don't have to slave away for foreigners), and assuming that we don't default on our debt (which causes economic disruption), the answer is "no." Some people (creditors) are better off and some are worse off, but overall it's a wash.

Nick Rowe asks: If, starting now in 2012, we rack up some more debt over the next decade, will that make our descendants in 2042 worse off than they would be if we didn't rack up any more debt? Rowe's answer is "yes." To show how this works, Rowe makes an "overlapping generations" model where all goods are perishable and debt temporarily grows faster than GDP. In the model, the government uses debt to give extra consumption to the older generation, then taxes the younger generation to pay back the debt. Voila! A burden is imposed on the young.

But see, here's the interesting thing about Rowe's model: the government doesn't need to use debt to impose this burden on the young. It can achieve exactly the same result with zero debt, just by taxing the young directly and spending on the old (i.e. a Social Security system with unsustainably large contributions). In Rowe's model, debt is just an accounting system that keeps track of how much consumption has been transferred from the young to the old. But the debt itself doesn't really matter; only the consumption transfer matters.

So I think this tells us something important about debt in the real world. What matters is not debt, it's intertemporal choice. The important question is not how much debt we rack up, but whether we want to move consumption from the future into the present or from the present into the future.

In the real world, the way we move consumption around through time is through investment. In Nick Rowe's toy model there is no investment (because all consumption goods are perishable), but in the real world, the way we move consumption into the future is by investing in productive assets, like buildings or machines or education or ideas. The way we move consumption from the future to the present is by reducing investment and consuming more today.

So when the government takes out more debt, does it move consumption from the future to the present, or from the present to the future? The answer: It depends on what the government spends the money on!!!

("Aha!", you say at this point. "But investment = savings, and debt is negative saving, so more debt always means less investment!" And here is where I invoke Krugman: For the government to borrow money, someone has to save money by buying the government bonds. Objection overruled!)

It depends on what the government spends the money on. If the government borrows money and then invests it in productive assets - building or repairing infrastructure, researching new ideas, improving schools - and if those productive assets have real rates of return that exceed the rate at which the government borrowed, then the debt (or rather, the debt-financed spending) transferred consumption from us to our descendants, not the other way around. And note that this is true whether the government borrows domestically or from foreigners. But if the government spends the money on consumption - for example, buying everyone in the country a birthday cake - then the debt-financed spending has transferred consumption from our descendants to us...it has imposed a burden on future generations.

Now, it's also true that the private sector can act to neutralize some or all of this intergenerational consumption transfer. If increased public debt is spent on consumption goods (birthday cake), then the private sector can choose to invest more of its own money in productive assets (e.g. office buildings or trucks), thus negating the burden imposed on the future generations. To what degree that actually happens is an open question.

But the basic point is this: When asking whether running up our debt will impose a burden on future generations, the key question is what the government will do with the money it borrows. I personally believe that the U.S. is currently underinvesting in the kind of productive assets that only the government can cheaply create - roads, bridges, electrical grids, broadband infrastructure, and basic research. That means that if our government borrows to invest in those things, it will be doing our grandkids a favor, not imposing a burden.
reade more... Résuméabuiyad

Actually, I don't think David Romer is batty at all...

Scott Sumner thinks I am too quick to bash other people's blog posts without first doing my due diligence:
Noah Smith is a very smart guy, but he has a bad habit of jumping into disputes without first discovering what the other side is actually saying.  Indeed he recently admitted this after DeLong pointed out that his criticism of Robert Lucas was inaccurate.
Guilty as charged (though readers should note that said mistake was more of an attempt to defend Lucas than criticize him). The blogosphere is a place where we discuss very high-level ideas in very glib sentences, and whenever high-level ideas are discussed in very glib sentences, there will be a tendency to misinterpret people's claims. So a lot of these arguments are really just people talking past each other, which is kind of a waste of time. Like most econ bloggers, I engage in that sort of thing more than I should.

Sumner, who is an even smarter guy than I am, believes I have made another such error in this post of mine. He writes:
In his long post he spends a lot of time setting up foolish arguments that he imagines I might make, and then shoots them down.  Unfortunately for him, I don’t actually make those foolish arguments.
Well, perhaps I did. Let's see what I said in my earlier post. I was responding to this quote of Sumner's:
Keynesian economists have never been able to accept my assertion that the fiscal multiplier is roughly zero because the Fed steers the (nominal) economy.
Now, I do admit that this sentence could mean several things! Let's consider three claims that could be represented by this statement:

Possible Claim 1: Because monetary policy can act in opposition to fiscal policy, the effect of fiscal stimulus depends crucially on how the Fed reacts to a stimulus.

Possible Claim 2: The data show that, in practice, the Fed does act to negate the effects of fiscal stimulus.

Possible Claim 3: Because the Fed can, in theory, counteract any fiscal stimulus, the effect of any fiscal policy on output should be considered to be zero.

So, let's look at these possible claims. Possible Claim 1 is a theoretical claim. It basically just says that monetary policy is always capable of counteracting fiscal policy. That claim is not logically inconsistent ("batty") at all. Arguable, maybe - since it depends on how effective you think monetary policy can be - but certainly not batty.

Possible Claim 2 is an empirical claim. Therefore, it can't be logically inconsistent or "batty"; only the data will tell us if it's true or not. Andy Harless and David Beckworth argued in the comment thread of my earlier post that this claim is true, and I'm certainly willing to entertain the possibility that it is true (though I must say I am skeptical).

Possible Claim 3 has two parts - a definitional part, and a theoretical part. First, it says that (3a) when we talk about the "multiplier" associated with fiscal stimulus, we should include the Fed's reaction function in the model that we use to estimate the multiplier. This is the argument made by David Romer in some remarks cited by Sumner:
As Robert Solow stresses in his remarks in this session, we should not be trying to find “the” multiplier: the effects of fiscal policy are highly regime dependent.  One critical issue is the monetary regime...if [central banks are] successful [at offsetting the effects of fiscal policy], one would expect the estimated effects of fiscal policy to be close to zero.
This is just saying that there are several ways to define "the multiplier" - you can talk about the multiplier while holding monetary policy constant, or you can talk about the multiplier in the context of a model that includes the Fed's reaction function. If we look in the data and see that a fiscal stimulus was followed by an increase in nominal output, we could say that "The stimulus increased output," or we could say that "The Fed increased output by choosing not to counteract the stimulus." To borrow an old NRA slogan, it's a question of whether guns kill people or people kill people.

BUT, aha! Possible Claim 3 also involves a theoretical claim. This is the claim that (3b) the Fed's reaction function is invariant to fiscal policy! To see why, consider a world in which the Fed targets a 3% growth rate for NGDP if there is no stimulus, but raises the growth rate target in the event of a stimulus. In this case, it would make perfect sense to say "fiscal stimulus increased NGDP growth," in the sense that we normally think of causality. It would make no sense to attribute the growth increase to the Fed. That would be like saying "You think you put butter on that piece of toast, but actually it was I who put butter on that piece of toast, since I could have clobbered you on the head and stopped you from putting butter on the toast, and I chose not to. Thus, you are incapable of buttering toast; only I can butter your toast." That would be a truly batty claim!

And it was this claim, Possible Claim 3, that I believed Sumner to be making. Which is why I said it was "batty."

Now, maybe I was wrong. Maybe I misunderstood what Sumner was trying to say when he said "the fiscal multiplier is roughly zero because the Fed steers the (nominal) economy." When I go back and read that sentence again, it still sounds like Claim 3b, but that could be my minsinterpretation. Perhaps Sumner was only making a combination of Possible Claims 1, 2, and 3a. Perhaps he was saying that in the past, the Fed has counteracted fiscal policy, and can therefore be expected to do so again in the future, and that we should include that behavior in our definition of the "mutiplier." And if this was the totality of what he was saying, then I was indeed mistaken in bringing out Bat Boy.

But what kind of research would have allowed me to know that Sumner was not going on to assert Possible Claim 3b? I know Sumner has made Claim 2 in the past, but does that mean that that was all he was saying this time? When I read the phrase "the fiscal multiplier IS zero because the Fed STEERS the nominal economy," it sounds to me like a claim that the fiscal multiplier theoretically MUST be zero. Which would just not be true, since the Fed's reaction function might not be policy invariant.

So perhaps I was too quick to say that Sumner's claim was batty. It was simply the case that the claim I thought Sumner was making would, in fact, be batty (i.e. not logical). Perhaps I should have first asked Sumner "What exactly did that statement mean?" before assuming it meant what it sounded to me like it meant. Perhaps I was too quick to jump to conclusions, and ended up knocking down a straw man. And if so, I hereby revoke the Bat Boy from Scott Sumner and award it instead to anyone out there who does believe that the potential effectiveness of monetary policy means that fiscal policy is ineffective by definition...
reade more... Résuméabuiyad