Locklin on science

On beating roulette: part 3

Posted in econo-blasphemy, Gambling systems by Scott Locklin on March 14, 2016

This is third in a four part series. Part 1 here, part 2 here.

Picture 12

To my mind, the most mathematically interesting thing about roulette is the betting system you should use to maximize your wins. Bet sizing systems are important in all probabilistic games, and the types of lessons learned from a winning game of roulette are the same types of lessons you need to learn in betting on other things, like success in trading, or having an edge on the wiener dog races. The nice thing about a game of roulette is it is relatively easy to characterize your edge. Most people’s edge over the roulette wheel is negative, so you should not bet. If you built one of the computer gizmos I went over in part 2, you have a positive edge over the roulette wheel.

We know from results in information theory, that sequential bets in the presence of an edge should be sized according to the Kelly Criterion to maximize bankroll growth rate.

betsize = \frac{bankroll * edge}{house odds}

or, in more probabilistic terms;

betsize = \frac{p * odds + p -1}{odds}


where p is probability of success.

It’s probably not immediately obvious why this is so, but consider a biased coin toss at even odds ($1 payoff for $1 bet). If your coin’s edge is 100%, you gain money fastest by betting your whole bankroll. If you have 0% edge, you shouldn’t bet anything. If you have a 1% edge, you should bet 1% of your bankroll.

Daniel Bernoulli came up with the same fraction a long time before by maximizing the geometric mean.

Kelly’s original paper figured this out by modeling how a better would place bets assuming he had insider information transmitted over a noisy wire transmitting a binary code; a beautiful way of thinking about predictions in the presence of noise. Kelly is a guy I wish had lived longer. He dropped dead at the young age of 41; in his short life he was a Naval aviator in WW-2, invented computer speech synthesis, made huge contributions to information theory, mentored important mathematicians (Elwyn Berlekamp, who went on to found Axcom/Rentech, based in part on Kelly’s insights) and had the kind of life that would be considered hyperbole if he was in a science fiction novel.  They make big men in Texas. Kelly was a giant.


I’m pretty sure his testicles smoked unfiltered camels

I’ve been known to take sadistic glee in making fun of economists. One of the most mockable economists in American history is (Nobelist -the Swedes have dry humor) Paul Samuelson.  One could write entire books on the ways in which Samuelson was a scoundrel and a numskull who set back human knowledge by decades. One fact will suffice for this essay: Samuelson didn’t believe in Kelly betting. Explaining why he thought this, and why he’s wrong would be pointless; debugging an economist’s faulty thought processes is as pointless as explaining why a crazy lady is breaking dishes in the kitchen. If you’re interested, Ed Thorp is your man here also.


Ed Thorp is the man, period

Following Ed Thorp’s original essay in the Gambling Times, as good little experimental physicists, we need to build up an error budget to figure out our edge.  Thorp breaks down the errors in his and Shannon’s Roulette system into several kinds.

  1. E1 Rotor speed measurement error
  2. E2 Ball speed measurement error
  3. E3 Ball rotor path randomness
  4. E4 Ball stator path randomness
  5. E5 Fret scatter
  6. E6 Rotor tilt (discovered by Shannon and Thorp)

Uncorrelated errors add up as the sum of squares, so the total error budget is

Error = \sqrt{\sum_{n=1}^{n=6}{E_n^2} }

The Thorp/Shannon roulette system had a 44% edge on the most favored number; single number payouts in Vegas are 35:1, making the correct bet on one number 0.44/ 35 = 0.01256. Since nobody in 1960s Vegas suspected the mathematical machinators of having a physics edge on the wheel, they were able to place larger bets on parts of the quadrant. While Thorp describes it as “diversification” in his exposition. Another way of thinking about it: he’s just playing more games at once. A friend and former customer explained his trend following method as working in much the same way. The more bets you place, the more likely you’ll hit a winning trend.

Kelly betting isn’t a perfect solution in all cases; fixed fraction betting has certain disadvantages when you can’t exactly characterize your edge, or the payout odds, or you have a limited number of bets before you have to cash in your chips. However, in the case of a machine to beat Roulette, it’s difficult to think of a better technique.

Of course, Kelly betting and things like it figure in other sorts of betting; people do use it in Markets where it is appropriate. Supposedly it was part of Axcom/Rentech’s early secret sauce, and certainly folks who have thought about trading need a bet sizing and risk management strategy that makes sense. Kelly is often a good place to start, depending on your situation. But that’s a topic for another blog post. One more coming on modern techniques to beat Roulette, including the one I came up with in 2010 (which, in case you were holding your breath, didn’t really work, which is why I have to work, and am willing to talk about such things in blogs).

Kelly criterion resources

Kelly’s original paper:


Thorp’s explanation:


Thorp’s website:




Bad models and the end of the world

Posted in econo-blasphemy, stats jackass of the month by Scott Locklin on March 23, 2014

I loathe journalism as a profession: a claque of careerist whores, half-educated back-slappers and propagandists for the oligarchical lizard people who are ruining civilization. I loathe “science journalism” particularly, as they’re generally talking about something I know about, and so their numerous impostures are more obvious.

Journalists: they're mostly like this

Journalists: they’re mostly like this

Today’s exhibit, the “NASA study predicting the end of Western Civilization.” The actual study can be found in PDF format here. If you read the “journalism” about this in the guardian, cnet, or wherever else, it’s all about our impending doom. Not only do scientists tell us we are doomed, fookin’ NASA scientists tell us we are doomed.

The authors of the study are not NASA scientists. The NASA subcontractor  associated with this paper would like you to know this; probably because NASA was annoyed their name was associated with this paper. The only contribution NASA made was in partially supporting an institution which partially supported one of the three authors for one semester. The author in question,  Safa Motesharrei is a grad student in “public policy” and “mathematics” at U Maryland. The other two authors are also not NASA scientists. One is allegedly a professor of … political science in Minnesota -and more recently some cranky looking outfit called “Institute of Global Environment and Society.” The other one is a professor of the U Maryland department of Oceanic and Atmospheric sciences. Unless you consider the partial ramen noodle stipend one grad student received for one semester to be “funding,” or you consider NASA’s subcontractor to be liars, NASA did not fund or endorse this study in any meaningful way. Journalism 101, failed before even getting to the content of the article.

The three authors of this study

The three authors of this study

For what it is worth, had I published anything my sophomore year of grad school instead of trying to build a crazy vacuum chamber and catch a venereal disease, I’d have had some words in my paper thanking NASA for their support as well. This is despite the fact that most of my money came from the NSF and the University I was attending. I wasn’t in any way a NASA scientist. My institution wasn’t NASA affiliated. But we did get a NASA grant that paid for at least a month’s salary for me over the course of a year. When you get those grants, you say “thank you.”

Nafeez Ahmed, the imbecile at the Guardian who broke the story, continues to insist that NASA funded this study, despite the fact that they didn’t. I guess when someone Discovers you are a shoddy journalist, the accepted thing to do these days is doltishly double down on your error. Ahmed, of course, works for some preposterous save-the-world outfit, which apparently means he can pretend he is a journalist and doesn’t have to tell the truth about anything.

Journalistic failure is to be expected these days, and NASA scientists say stupid things all the goddamned time. Still, reading the paper itself was informative. Had anybody bothered to do so, the story would have been murdered in infancy. It’s one of the godawful silliest things I have ever read.

There is a fairly standard model from ecology called the “predator prey” model. Predator/prey models were  mostly developed to model exactly what it sounds like: things like wolf and moose populations in a National Park. The model makes assumptions (that predators are always hungry,  the prey will never die of old age, and  there are no other predators or prey available, for just a few examples of the limitations of the model), but if you set these equations up right, and the parameters and conditions are non-degenerate, it can model reality reasonably well. It’s really no good for predicting things, but it’s OK for modeling things and understanding how nature works.  The equations look like this, where x(t) is the predator population, y(t) is the prey population and a is predator birth rate, b is the predator death rate, c is the prey’s birth rate, and k is the predation rate; all rates are constant.

\frac{dy}{dt} = ay(t)x(t) -bx(t)

\frac{dx}{dt} = cy(t) -kx(t)y(t)

The predator/prey model is elegant, concise, and in some limited circumstances, occasionally maps onto reality. It is, of course, a model; there is no real reason to model things using this set of differential equations, and a lot of reasons not to. But sometimes it is useful. Like most good models, it is simple and doesn’t have too many parameters. Everything can be measured, and interesting dynamics result; dynamics that we can observe in nature.

The authors of this doom-mongering paper  have  transformed that relatively simple set of equations; a set of equations which, mind you, produces some fairly complicated nonlinear dynamics, into this rather un-handy mess, known as HANDY (for “Human And Nature DYnamics”):

\frac{dx_c}{dt} = \beta_c x_c(t) - \alpha_c x_c(t)

\frac{dx_e}{dt} = \beta_e x_e(t) - \alpha_e x_e(t)

\frac{dy}{dt} = \gamma (\lambda -y(t)) y(t) - \delta x_c(t) y(t)

\frac{d \omega}{dt} = \delta y(t) x_c(t) - C_c(t) - C_e(t)

In this set of equations, x_c(t) is the productive peasant population, x_e(t) are the population of parasitic elites, y(t) is “natural resources” and w(t) is “wealth.” \lambda is a “saturation of regrowth of nature rate.” \gamma is an “exponential growth of nature rate.” \delta is a “depletion of nature” rate term. C_c(t), C_e(t) are wealth consumption rates.

to make it even more complex: \alpha_c(t), \alpha_e(t), C_c(t), C_e(t) are all functions of \omega(t), x_c(t), x_e(t)

C_c(t) = min(1,\frac{\omega(t)}{poor(t)}) s x_c(t)

C_e(t) = min(1,\frac{\omega(t)}{poor(t)}) \kappa x_e(t)

poor(t) = \rho x_c(t) + \kappa \rho x_e(t)

poor(t) is some threshhold wealth function, below which you starve, and allegedly \rho is supposed to be a minimum consumption per capita, but it really makes no sense based on the equations. s is some kind of subsistence level of wealth and \kappa is the multiple of subsistence that elites take.

Instead of contenting themselves with constant predation or death rates, this train-wreck insists on making them the following:

\alpha_c(t) = \alpha_m + max(0,1-\frac{C_c(t)}{s x_c(t)}) (\alpha_M - \alpha_m)

\alpha_e(t) = \alpha_m + max(0,1-\frac{C_e(t)}{s x_e(t)}) (\alpha_M - \alpha_m)

Where \alpha_m, \alpha_M are constants for a normal death rate and a death rate where you have a high death rate, where, and I quote the paper directly: “when the accumulated wealth has been used up and the population starves.”

It’s worth a look at what they’re implicitly modeling here by adding all this obfuscatory complexity. All of the following assumptions are made by this model. Very few of them are true in reality. Most of these assumptions are designed to get the answer they did.

  1. The natural resources of the earth is well modeled by the prey equation
  2. The natural resources of the earth regenerate themselves via a logistic function
  3. There are two classes of humans
  4. There is a thing called “wealth” that is consumed by the two classes of humans at different rates
  5. The elite class of humans preys on the peasants and produces nothing
  6. The peasant class is all equally productive
  7. Wealth comes from peasants exploiting nature
  8. Elites all have \kappa times a subsistence income, rather than a smooth distribution of incomes
  9. Peasants all have s , a subsistence income, rather than a smooth distribution of incomes
  10. An extra variable called “wealth” is needed to make sense of these dynamics, and this variable maps onto the thing known in common parlance as “wealth.”
  11. The wealth factor could sustain a human society for centuries after ecological collapse (page 18)
  12. Death rates increase as natural resources are consumed at a faster rate (everything about modern civilization indicates the exact opposite is true)
  13. The peasants get nothing from the elites except population control
  14. Technological change is irrelevant (yes, they argue this; page 7)
  15. This ridiculous spaghetti of differential equations actually models something corresponding to Human Civilization

There are more assumptions than this, but you get the idea: this model is ridiculous, over parameterized, and designed to get the answers that they did. If you assume parasitic non-productive elites, you get the situation where social stratification can help “cause” collapse. Of course, if you assume parasitic non-productive elites, you’re assuming all kinds of ideological nonsense that doesn’t map well onto reality.

If you assume natural resources also act like prey, you can get situations where the natural resources collapse, then the society collapses. This is no big surprise, and you don’t need these obfuscatory complications to say this: it’s in the predator-prey equations already. Why didn’t they just model humanity and nature as simple “predator/prey” above? I am guessing, because nobody would buy it if you say things that simply, and it wouldn’t be an original paper. It also doesn’t allow them to pontificate on egalitarian societies.

As for the additional “wealth” factor these clowns use to distinguish themselves from an earlier bad model; as far as I can tell, the only purpose served by this degree of freedom is making it easier to mine way more natural resources than we actually need to support a population (something that wouldn’t happen in a standard predator-prey model). It also doesn’t make any sense, modeled in this way, unless you believe grain silos contain centuries worth of corn, or that people can eat skyscrapers. That’s how their wealth equations work; they actually assume you can eat wealth.


Dr. Nafeez Ahmed: Guardian columnist who broke this story

I actually feel a bit sorry for these guys, even though they are unashamed quacks. They didn’t ask to become this famous. Somehow the zeitgeist and some imbecile activist newspaper reporter decided to make them famous as people who are really bad at modeling anything. God help these people if they attempt to model something real, like chemical reaction dynamics, or, say, the earth’s atmosphere.

Returning to the mendacious loon, Ahmed, who brought this paper to world fame and attention. He asserts that the paper actually compares historical civilizations using this model. It does nothing of the sort. The paper mentions historical civilizations, but they don’t even make legalistic arguments that, say, the ancient Egyptians, whose civilization lasted for thousands of years, somehow follow these equations.  All they say is, ancient cultures were cyclical; they rise and fall; something everyone has known from the time of Heraclitus. Cyclical behavior does not imply this complex pastiche of differential equations; there are cyclical behaviors in nature which can’t be modeled by any differential equations. Finally, Ahmed asserts that the model predicts things. It doesn’t; nor does it claim to. It claims to model things. Modeling things and predicting things are very different.

The model itself was bad enough. What the activist-reporter said about it is inexcusable. The fact that everyone credulously picked up on this nonsense without questioning how Nafeez Ahmed made his living is even worse. Science by activist press release. Yeah, thanks a lot, “science journalists.” Nobody even noticed the clown who broke this story is a goddamned 911 truther.

A more reliable narrator than the Ahmed bozo who broke this story

A more reliable narrator than the Ahmed bozo who broke this story

I find all this intensely sad. I’m sad for the boobs who wasted their lives cranking out a model this useless. I’m sad for our civilization that it is possible to make a living publishing rubbish, and that talented people can’t make a living doing interesting and correct research which will benefit humanity. I’m also sad that journalists aren’t fired over their credulity regarding this fraud. I’m sad that ideological hogwash is published in all the papers as some kind of scientific truth, while nobody notices simple things, like the fact that the world fisheries are presently undergoing collapse, or the fact that there are no more rhinos because Chinese people haven’t discovered viagra yet.

I’m also sad that people are so obsessed with the end of the world. Maybe some day we’ll experience some kind of ecological apocalypse, or the imbeciles in the White House will nuke the slightly less stupid cavemen in the Kremlin. Chances are pretty good though, that before these things happen, we will all be dead. Wiser men than me have pointed out that anxiety about the end of the world is a sort of transference for anxiety about their own impending demise. As Spengler put it, “perhaps it is not the end of the world, but just the end of you.”

In which I have a laugh at economists: whistling at the abyss

Posted in econo-blasphemy, history, philosophy by Scott Locklin on July 31, 2011

I never studied economics. Don’t pretend to understand it. Don’t want to understand it any more than I want to understand Voodoo theology or radical feminism: it seems to me a pernicious form of anti-knowledge. Some of it makes a little bit of sense (maybe voodoo theology does too: dunno), but looking at it like a visitor from another planet (MFM Osborne or Joe McCauley are reasonable approximations, being from planet Physics), it doesn’t look much different from schools of medieval medicine, punctuated by occasional linear regression models. There aren’t generally falsifiable models, and when there are, people seem awfully reluctant to test them. Economic schools seem to grow up around charismatic prophet types, and the arguments for their validity seemed to be along the lines of “Rabbi X said Y, and lo, he was correct.” I think everyone on the internet has seen the Hayek vs Keynes rap, which is about as good an introduction as one could hope for to this sort of thing. I think the intellectual content of a posing rap battle is about as much as one can hope for in this sort of argument as well; ultimately, it’s just a dong wagging contest.

Hayek’s views on economics are, I think (and someone please correct me if this is a misapprehension) closer to the conventional thinking in the 1920s. Keynes views seem to be something approaching the conventional wisdom in the 21st century. Austrian views are “conservative” and Keynes is “liberal” (in the American sense anyhow). This is a broad generalization; most modern Keynesians have some Austrian ideas, and vice-versa, but ultimately, the debate between these guys boils down conflict between these two ideas:

  1. Expansion of debt is inevitably followed by economic recession (Austrian Business Cycle Theory).
  2. Economic recession is ameliorated by deficit spending (Keynesian idea).

The historical battleground they fight their idea on is the Great Depression and WW-2; the events which formed the modern world. The modern Keynesian view is that “Austrian” ideas made the great depression worse. The government, according to them, should have engaged in lots of deficit spending, and that would have magically made things all better. After all, things only got better after WW-2, when we engaged in lots of deficit spending, right? I’m certain the Keynesians have all manner of regression models with which to “prove” this idea, but ultimately, they’re only using one set of data points, and only a couple of variables. This school of thought seems to have won the modern day; we’re at WW-2 levels of deficit spending now. Of course, we’re not spending the money on the same things at all. It’s not clear to me how the Austrians account for the financial success of the United States (and Japan and Germany and the Soviet Union) in the post WW-2 era, but it seems likely to be an equally specious shaggy dog story.

I don’t know if any school of thought argues that the war itself had something to do with things, but I’m going to argue exactly that; call it the Heraclitus school of economics. Seems like an obvious thing to me. I can’t “prove” it using regression models, or by being a college professor or whatever nebulous vril economists use to “prove” their points, but it seems as ultimately convincing as anything else. My toy model does something few economic ideas since Pareto has done: it takes into account the fact that we’re talking about large groups of actual human beings, rather than utility optimizing economic robots.

To reiterate: in Krugmanistan, the prevailing idea seems to be that printing a lot more money will magically make things all better, because dropping lots of bombs on Germany and Japan seemed to be good for the American economy in WW-2. To a Keynesian economist, it was the magic of the printing press. Not the fact that the US developed new technologies, invested in vast new industrial infrastructure, mobilized its entire population, brainwashed its civilians into working double shifts for small amounts of money (and buying lots of government debt), brainwashed its military aged men into fighting a war in distant countries, displaced vast segments of the population to work in factories; hell, we even put women to work in factories. All those other countries did the same thing. Car makers and other manufacturers built giant ships, aircraft which couldn’t have been built before, new kinds of vehicles, tanks, atomic bombs, jets; radio makers made huge strides in electronics, computers and other electronic techologies: and all these companies retained the ability to produce these new technologies after the war was over. Entirely new forms of economic output were possible after the war which weren’t possible before. To name five obvious ones: Airlines, Computers, Atomic power, Highway travel, Rocketry. These new technologies and manufacturing capabilities became new industries which provided people with jobs and further economic output creating things which were figments of people’s imaginations a decade previous. The United States (and all those other countries) made a hail Mary investment in their infrastructure, and transformed their people into fanatical worker bees. The amateur businessman could look at this as an investment in the country; an investment in the employees and the infrastructure. By accident, it was a reasonably intelligent investment for future growth. And after that, the economy did a lot better. Economists want you to believe it had something to do with printing money or business cycles.

I don’t buy the arguments of economists. I think the reason things changed for the better after WW-2 is people were transformed into something they weren’t before, and the national infrastructure was transformed into something a lot more capable than it was before. I do think availability of money is important (duh), and deflation is generally worse than inflation, but if you asked me why WW-2 was followed by a period of prosperity in the US, the above is my reason: nothing to do the magical printing of money or lack therof. Single factor regression models rarely work on systems more complicated than a couple of diodes: why should I be impressed by spurious regression on ancient data?

Another thing economists don’t seem to notice much: the nature of the population. Taking only one variable: mean age seems important to me. Old people don’t work or innovate as much as young people. Old people also have more money than young people, and they do things like invest this money in hopes of making rent on it. Basically, finance is the loaning of old people money to young people, so young people can do useful things with the money, like start businesses. Populations in all industrialized countries are getting older. This means there is a surplus of old people money seeking young people to invest in. This is why interest rates are low, despite all the printing of money going on everywhere. If there were more young people, we’d be in a completely different pickle. This single fact pretty much makes rubbish of any statistical model based on historical data: we’ve reached a fundamental change point which is unprecedented in economic history. There are no historical regimes in which there were lots of old people money chasing young people to invest in. The idea of fitting an economic model to something in the 1930s and expect it to be relevant today …. I might as well trade a model based on 1930s IBM stock prices.

Me? I’m not an economist, or a prophet. I work for a living. I don’t have any answers, and I don’t have any bright ideas as to how to fix the mess we’re in. I’m pretty sure nobody else does either; certainly no politicians alive today are saying anything remotely sensible -it’s all magical thinking, and genuflections before long dead sacred idols. Since I’m of a scientific bent, I wouldn’t mind running some experiments. It seems to me the country is large enough this sort of thing is possible. Hopefully we don’t have one forced on us.