Monday, February 15, 2010

Conflicting World Models in Conflict Simulation

Many board games have been created to simulate past military conflicts. They are often created to explore "what ifs", alternative choices the opposing commanders hypothetically could have made at the time. A basic problem, of course, is that we have hindsight knowledge (though sometimes still incomplete) of what actually happened.

To simulate "fog of war" games sometimes hide the positions or strengths of opposing troops. More rarely the strengths of untested "green" troops are even hidden from their own commanders. Elaborate scenario start conditions also try to recreate the historical limitations faced by commanders at the time: troops hopelessly out of position or delayed due to political restrictions, surprise, disrupted communications, etc.

What these games rarely represent, however, is that commanders sometimes start with fundamentally different understandings of "basic game mechanics", such as the effects of mapboard terrain on movement, supply, and combat. Many historical battles have hinged on one side believing certain terrain was impassible by many unit types. The classic gaming example is the Ardennes forest at the beginning of both WW I and II. A "historically correct" gameboard for the French would show it impassible to mechanized units, while the German gameboard would show it passable. Since the "after the fact" map has the terrain passable, the French player will of course want to defend it accordingly. Thus the elaborate setup-rules necessary to prevent this and ensure at least the possibility of achieving the historical outcome. But here the most important element of surprise, that of one commander suddenly discovering his world-model is incorrect, is lost.

This limitation becomes more acute the further players try to maneuver beyond the historical outcome. Since these alternative paths were (figuratively and literally) never explored, we have little idea where their differing world models would have broken down in conflict with reality.

The Future of Amplification

Recently there have been several positive reviews of the NAD M2 Direct Digital Amplifier (white paper). It is the first of its kind, and I expect many more amplifiers like this will follow.

Today most audio sources are digital: CD/SACD, DVD/Blu-Ray, HDTV, PC/MP3 server, etc. These signals are passed through a digital-to-analog converter, have volume control applied, and are passed as analog signals to the amplification stage. Even current class D amplifiers accept an analog signal, convert it to a PWM (pulse width modulation) digital signal, and use that to generate the final amplified analog signal sent to the speakers.

The NAD M2 is unique in keeping the input digital signals in the digital domain as long as possible. It accepts PCM (pulse code modulation) digital inputs, applies volume control digitally, and converts the PCM to PWM for output by the class D amplifier. Keeping the signal digital as long as possible eliminates all the possible noise sources in the redundant digital-to-analog-to-digital conversions, and the lossy analog connections between source, pre-amplifier and power amplifier.

(Yes, I deleted my previous audio post as I realized I was spreading disinformation. I am currently fascinated by the topic, and will keep trying.)

Sunday, January 24, 2010

Cycles of Explanation in Economics

In areas of science such as physics and biology our successive theories developed over time are better and better explanations of the observed facts. Think heliocentrism versus geocentrism, or natural selection versus Lamarckism. But in economics I suspect this is not always the case. Traumatic events like the Great Depression, or (hopefully) the current crisis can force a brief period of clarity. But over time economic forces will result in the mainstream replacement of the theory which most closely matches the observed facts of the previous crisis with a theory which maximizes short term profits for powerful actors. The time-frame over which this shift occurs is probably a generation, in which those with first-hand memories of the previous crisis leave power.

Here are two exhibits for my point. The first is a quote I have been re-sending for years:

"When business in the United States underwent a mild contraction in 1927, the Federal Reserve created more paper reserves in the hope of forestalling any possible bank reserve shortage. More disastrous, however, was the Federal Reserve's attempt to assist Great Britain who had been losing gold to us because the Bank of England refused to allow interest rates to rise when market forces dictated (it was politically unpalatable). The reasoning of the authorities involved was as follows: if the Federal Reserve pumped excessive paper reserves into American banks, interest rates in the United States would fall to a level comparable with those in Great Britain; this would act to stop Britain's gold loss and avoid the political embarrassment of having to raise interest rates.

The "Fed" succeeded; it stopped the gold loss, but it nearly destroyed the economies of the world in the process. The excess credit which the Fed pumped into the economy spilled over into the stock market -- triggering a fantastic speculative boom. Belatedly, Federal Reserve officials attempted to sop up the excess reserves and finally succeeded in braking the boom. But it was too late: by 1929 the speculative imbalances had become so overwhelming that the attempt precipitated a sharp retrenching and a consequent demoralizing of business confidence. As a result, the American economy collapsed. Great Britain fared even worse, and rather than absorb the full consequences of her previous folly, she abandoned the gold standard completely in 1931, tearing asunder what remained of the fabric of confidence and inducing a world-wide series of bank failures. The world economies plunged into the Great Depression of the 1930's."


Gold and Economic Freedom, Alan Greenspan, 1967.

Here the Greenspan of 1967 believed holding Fed rates too low caused a bubble that could not be cleaned up afterwards. But the Greenspan of the late 1990s and again early 2000s no longer believed low rates caused bubbles, or that a bubble could be too large for the Fed to clean up afterwards. Why the shift? I think the earlier theory fits the facts of the 1920-30s (and our current situation now) better. But note his successor Ben Bernanke still denies low rates cause bubbles.

A second exhibit is the presentation I wrote in 2006 and posted as Black Swans in the Market in 2008. I showed that any Statistics 101 student could easily demonstrate that daily stock prices changes are not normally distributed. This makes people like the CFO of Goldman Sachs, who claimed in 2007 "We were seeing things that were 25-standard-deviation events, several days in a row" look extra-silly. Why were they using such bad models? Is finance in general so ignorant of basic statistics[*]? No, they are simply choosing models which maximize their short-term profits -- and bonuses.

[*] OTOH, a Google Books search on "which shows a histogram of the daily returns on Microsoft stock" shows that as of 2005 Brealey et. al. were still peddling this nonsense to unsuspecting MBA students in their Principles of Corporate Finance and related texts. A 2005 edition apparently shifted the MSFT date range from 1986-97 to 1990-2001 (omitting the crash of 1987!). Later editions don't hit on the search terms; no idea if they have cleaned up their act.

Sunday, January 3, 2010

Multi-Core Ant Colony Optimization for TSP in Go

Go is a new statically typed, garbage collected, concurrent programming language. It is native compiled and offers near-C performance. Like Erlang it uses a CSP model of lightweight processes ("goroutines") communicating via message passing. Messages can be synchronous (unbuffered) or asynchronous. Go supports multi-core processors.

On my usual ACO TSP test case Go is the best performing language so far. On a single core it was 2.8x slower than C, beating the previous best Shedskin Python. Go's speedup from 1 to 2 cores was 1.9, matching previous best Erlang. With 4 cores Go exceeds C's single core performance -- the first tested language to achieve this goal.



Go's lightweight processes are scheduled onto OS threads by the Go runtime system. This allows the system to support many more processes. I was able to run ACO TSP with 100,000 ant processes. The runtime system scheduler appears to treat these processes somewhat like futures, lazily scheduling them when another process is blocking on receipt of a message from a shared channel. This is inefficient for the type of parallel processing used in ACO (many seconds of parallel computation ending with a single message send), as only a single process (and thus a single core) is active at a time. This is a known issue, and the simple solution suggested on the golang-nuts mailing list is to add runtime.Gosched() calls to yield the processor. For my case this was insufficient, and adding additional heartbeat messages to each process helped force maximal multi-core usage.

See here for code and more details.

Sunday, December 20, 2009

Science Fiction Physics, and Biology

The January 2010 Scientific American article "Looking for Life in the Multiverse" analyzes how much the laws of physics might differ while some form of life is still possible. It specifically shows that carbon-based life is still possible when the weak nuclear force is eliminated. The authors are less supportive of non-carbon-based life popular in science fiction, and still find support for the anthropic principle ("conditions that are observed in the universe must allow the observer to exist") in the precise value required for the cosmological constant.

Also, in an earlier post I claimed that all life on earth is dependent on the sun for energy. This is incorrect. The black smoker sea vents on the ocean floor support complete ecosystems including archaea, clams, and tubeworms. Here the energy comes from the interior of the earth instead of the sun.

Monday, December 14, 2009

Science Fiction Morality

In an earlier post I questioned the existence of atheist essentialist philosophers. I had been looking in the area of Philosophy of Science. Turns out a better place to look is Moral Philosophy. Moral Philosophy presents a moral spectrum, from Moral Nihilism (nothing is moral or immoral), to Moral Relativism (morals are relative to individual, social, cultural, or historic circumstances), to Moral Universalism (applies to "all similarly situated individuals") to Moral Realism (moral statements can be objectively true, and subject to rules of logic). In Moral Realism moral rules are similar to Platonic Forms or Ideals. Moral Realism is often grounded in religion, but is also supported by some atheist philosophers (example: Quentin Smith).

The boundaries between the positions are often fuzzy, with various proponents subtly repositioning other prominent philosophers. A historical stumbling block has been determining how a Universal Morality can be possible without recourse to a deity (and this is the basis of the "argument from morality", a proof of God's existence). More recently, based on research in Evolutionary Psychology, Steven Pinker wrote a great essay on how a human moral sense or instinct may have evolved. He presents many rules which are specific to the evolved nature of humans, and some which may be more universal. He says:

"Two features of reality point any rational, self-preserving social agent in a moral direction. And they could provide a benchmark for determining when the judgments of our moral sense are aligned with morality itself... One is the prevalence of nonzero-sum games. In many arenas of life, two parties are objectively better off if they both act in a nonselfish way than if each of them acts selfishly... The other external support for morality is a feature of rationality itself: that it cannot depend on the egocentric vantage point of the reasoner..."

It is interesting to consider how many rules the Moral Realist propose are universal, versus specific to the evolved nature of humans. I wonder how much science fiction Moral Realists read. A common theme in science fiction is the presentation of different alien races, and the different moral imperatives which naturally arise from their different evolutionary heritage. Examples are the K'kree (herbivores) and Hivers (one sex) from Traveller. And aside from other planets, we can similarly consider how morals would differ if radically different earth species (sharks? praying mantis? naked mole rats?) had evolved sentience. The Moral Realists imply that all creatures, regardless of evolutionary heritage, will always converge on the same universal morality (or that creatures which are unable to meet the standard can't achieve sentience). This may be a realistic assumption for a few of the meta-universals proposed by Pinker, but I don't think it applies to the much larger set of rules proposed by the Moral Realists. And without this universality the attempt to use rules of logic falls apart.

Sunday, December 6, 2009

The Fish Balance of Hobbiton

Like everyone else I've been trying to make sense of the arguments between the Keynesians, Austrians, etc. over the financial crisis. Lately I've been trying to puzzle out the National Financial Balance Accounting Identity:

Household FB + Business FB + Government FB + Foreign FB = 0

Described here. The importance of this equation is its use in justifying government deficits:

"We’ve said it before and we’ll say it again. As a matter of national accounting, the domestic private sector cannot increase savings unless and until foreign or government sectors increase deficits. Call this the tyranny of double entry bookkeeping: the government’s deficit equals by identity the non-government’s surplus." Marshall Auerback

From the first linked article, some definitions:

Financial Balance FB = income - expenditures, or saving - investment
income = profits + wages = P + W
spending = investment + consumption = I + C
normally (when FB=0) total income = total spending, so P +W = I + C

In discussing households we simplify by assuming no profits, so P=0

savings = W - C
FB = (W - C) - I

The author of the first linked article criticized an earlier author who claimed it was possible for all sectors Financial Balance to be simultaneously positive, so the Accounting Identity would not have to sum to zero. He claimed this would only be true in a primitive barter-based "Hobbit Shire".

Let's build one. Assume our world economy only consists of Hobbit households. No businesses, no government, no foreigners, no money, no outside investment. One primary resource: deep sea fish. Household "Wages" are the daily catch of fish. "Consumption" is eating fish. "Savings" is storing fish in the snow (Eskimo Hobbits :-) for later. So in good times (summer?) the net FB "Fish Balance" of all the Hobbit households is positive, while in bad times (winter?) the FB can be negative. This doesn't match the original Accounting Identity, but we can make it sum to zero by adding a new often-negative "Natural Resources" term to the equation.

Hobbit Household FB + Natural Resource FB = 0

This forms an interesting analogy to arguments against evolution based on the Second Law of Thermodynamics. Life on earth is not a closed system. It depends on a constant supply of energy from an outside source -- the sun. Life on earth is also dependent on heavier elements produced in prior supernovas. Similarly human economics is dependent on many raw material inputs which are not initially generated by (or often even owned by) humans. For the above Hobbit example I chose deep sea fish as a renewable resource owned by no-one. Other renewable resources include timber, food crops, textile crops, livestock, etc. Non-renewable resources include oil and minerals. Think AH Civilization or Settlers of Catan. And note these raw materials also ultimately come from the sun or supernovas.

This introduces the question of why the real Accounting Identity doesn't include a Natural Resources term. Obviously the real one is about money, not about resources. But if gathering natural resources creates value within the system, shouldn't it be represented? It is also not clear how many other aspects of value creation (such as a household purchasing an income-generating asset, rather than investing in the business sector) are represented.

This also brings up how new money is injected into the system. If the currency were gold-backed, money would be a resource. But a fiat currency is created by central banks. I assume the government deficit spending advocated in the quote above is fiscal spending, and the Government FB is budgetary spending. Alternately could they be advocating monetary stimulus, and the Government FB is that of the Federal Reserve? Does inflation matter in the equation, or is it irrelevant?

I think some of these questions are at the heart of the debates between the Keynesians and the Austrians. The Austrians focus on productive versus wasteful uses of resources, like my Hobbiton Fish Balance (to the extent they recognize the Financial Balance version they see it as an argument for returning to the resource-based gold standard). The Austrians claim recessons are caused by misallocation of resources. Keynesians are more focused on the flow (especially velocity) of money inside the Financial Balance Accounting Identity. Some claim our current problems are due to government not carrying out its proper role: running deficits.