tag:blogger.com,1999:blog-45701573193230209982014-10-04T21:30:04.447-07:00Of Math and Money BagsLearning about economics from the standpoint of science, mathematics, and information theory.Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4570157319323020998.post-49705637410563245892009-08-22T12:25:00.000-07:002011-05-18T14:28:52.992-07:00Electronic mind readerI am reading <a href="http://www.amazon.com/gp/product/B000SBTWNC?ie=UTF8&tag=thesurtea-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B000SBTWNC">Fortune's Formula: The Untold Story of the Scientific Betting System that Beat the Casinos and Wall Street</a><img src="http://www.assoc-amazon.com/e/ir?t=thesurtea-20&l=as2&o=1&a=B000SBTWNC" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> It is a simply amazing book for anyone interested in the intersection of information theory and investing.<br /><br />Claude Shannon plays a major role in this book, and I've been researching him on the side. He wrote an internal Bell Labs paper called "A Mind-Reading (?) Machine" in 1953. It is freely available <a href="http://seed.ucsd.edu/~mindreader/MindReader.pdf">here</a>.<br /><br />The first paragraph reads: <blockquote>This machine is a somewhat simplified model of a machine designed by D.W. Hagelbarger. It plays what is essentially the old game of matching pennies or "odds and evens." This game has been discussed from the game theoretic angle by von Neumann and Morgenstern, and from the psychological point of view by Edgar Allen Poe in the "The Purloined Letter." Oddly enough, the machine is aimed more nearly at Poe's method of play than von Neumann's.</blockquote>Before going further, you may wish to try out an online implementation of Shannon's mind-reading device yourself. You can find it here: <a href="http://www.cs.williams.edu/~bailey/applets/MindReader/">http://www.cs.williams.edu/~bailey/applets/MindReader/</a><br /><br /><a href="http://xroads.virginia.edu/~HYPER/POE/purloine.html ">"The Purloined Letter"</a> is definitely a good story to read in thinking about this subject... The "odds and evens" game is much like Rock, Paper, Scissors, in that I have also heard of people who were able to model their opponent's though processes (based on the patterns played in the game to that point) and then anticipate their next move. This is all that Shannon's machine is doing. Except that it looks at patterns only three moves long.<br /><br />The part of the story Shannon refers is this excerpt: <blockquote>"The measures, then," he continued, "were good in their kind, and well executed; their defect lay in their being inapplicable to the case, and to the man. A certain set of highly ingenious resources are, with the Prefect, a sort of Procrustean bed, to which he forcibly adapts his designs. But he perpetually errs by being too deep or too shallow, for the matter in hand; and many a schoolboy is a better reasoner than he. I knew one about eight years of age, whose success at guessing in the game of 'even and odd' attracted universal admiration. This game is simple, and is played with marbles. One player holds in his hand a number of these toys, and demands of another whether that number is even or odd. If the guess is right, the guesser wins one; if wrong, he loses one. The boy to whom I allude won all the marbles of the school. Of course he had some principle of guessing; and this lay in mere observation and admeasurement of the astuteness of his opponents. For example, an arrant simpleton is his opponent, and, holding up his closed hand, asks, 'are they even or odd?' Our schoolboy replies, 'odd,' and loses; but upon the second trial he wins, for he then says to himself, the simpleton had them even upon the first trial, and his amount of cunning is just sufficient to make him have them odd upon the second; I will therefore guess odd'; --he guesses odd, and wins. Now, with a simpleton a degree above the first, he would have reasoned thus: 'This fellow finds that in the first instance I guessed odd, and, in the second, he will propose to himself upon the first impulse, a simple variation from even to odd, as did the first simpleton; but then a second thought will suggest that this is too simple a variation, and finally he will decide upon putting it even as before. I will therefore guess even' guesses even, and wins. Now this mode of reasoning in the schoolboy, whom his fellows termed "lucky," --what, in its last analysis, is it?"<br /><br />"It is merely," I said, "an identification of the reasoner's intellect with that of his opponent."<br /><br />"It is," said Dupin;" and, upon inquiring of the boy by what means he effected the thorough identification in which his success consisted, I received answer as follows: 'When I wish to find out how wise, or how stupid, or how good, or how wicked is any one, or what are his thoughts at the moment, I fashion the expression of my face, as accurately as possible, in accordance with the expression of his, and then wait to see what thoughts or sentiments arise in my mind or heart, as if to match or correspond with the expression.' This response of the schoolboy lies at the bottom of all the spurious profundity which has been attributed to Rochefoucauld, to La Bougive, to Machiavelli, and to Campanella."<br /><br />"And the identification," I said, "of the reasoner's intellect with that of his opponent, depends, if I understand you aright upon the accuracy with which the opponent's intellect is admeasured."</blockquote>Back to <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jtSRNLN2Vms/SpBHEn0ymII/AAAAAAAAAGk/c0jDJt1FOuI/s1600-h/Shannon%27s+Mind+Reading+Machine+vs.+me.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 213px; height: 210px;" src="http://3.bp.blogspot.com/_jtSRNLN2Vms/SpBHEn0ymII/AAAAAAAAAGk/c0jDJt1FOuI/s400/Shannon%27s+Mind+Reading+Machine+vs.+me.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5372872500188452994" /></a> the <a href="http://www.cs.williams.edu/~bailey/applets/MindReader/ ">online version of Shannon's Mind Reader</a>. Not knowing how it worked, I was still able to beat the machine for a while (until I went off to figure out how it worked). A snapshot from the end of my game is shown. The black bar on the bottom indicates the percentage of games won by the machine.<br /><br />Then, as a control case, I tried a comparable number of clicks, using a sequence of random numbers generated from Octave (admittedly, these are pseudo-random, but they should be good enough). The results was actually a bit worse, implying that this simple Mind Reader can be outsmarted. The corresponding snapshot indicates a score closer to 50%. <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_jtSRNLN2Vms/SpBI6OSBqvI/AAAAAAAAAGs/6oPBd8ooHDQ/s1600-h/Shannon%27s+Mind+Reading+Machine+vs.+rand().jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 223px; height: 223px;" src="http://4.bp.blogspot.com/_jtSRNLN2Vms/SpBI6OSBqvI/AAAAAAAAAGs/6oPBd8ooHDQ/s400/Shannon%27s+Mind+Reading+Machine+vs.+rand().jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5372874520556317426" /></a><br /><br />I did suspect one thing before playing against the Mind Reader: It was based on human predictability, which I tried to avoid. It's like the classic statistics course demonstration where the professor asks the students to generate a random sequence (ones and zeros, heads and tails), and he can tell if it was generated by an actual random process or by a student trying to do an impression of a random process. Humans tend to avoid long strings of ones or zeros, incorrectly assuming that 1010110 is more random than 1111000. Knowing this, I tried to avoid obvious patterns.<blockquote>A mathematical analysis of the strategy used in this machine shows that it can be beaten by the best possible play in the ratio 3:1. To do this it is necessary to keep track of the contents of all the memory cells in the machine. The player should repeat a behavior pattern twice, and then when the machine is prepared to follow this pattern the player should alter it. It is extremely difficult to carry out this program mentally because of the amount of memory and calculation necessary.</blockquote><br /><br />All of the above seems to have a lot of relevance to trying to predict how the average person will invest money. I intend to look into the work of von Neumann and Morgenstern to understand their approach to the problem.Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.com0tag:blogger.com,1999:blog-4570157319323020998.post-9730346504244568562009-08-09T20:50:00.000-07:002009-08-09T22:26:45.550-07:00Is it possible to succeed through day-trading?I am reading <a href="http://www.economics.uci.edu/kassouf/pdfs/beatthemarket.pdf">Beat the Market</a> by Ed Thorp and Sheen Kassouf, which has the subtitle "A Scientific Stock Market System".<br /><br />In the first few pages, he discusses "chartists" which sound very much like what we now call "day traders". <blockquote>Chartists, or technicians, believe that patterns of past price performance predict future performance. They rely solely on price and volume statistics from the ticker tape, claiming that insiders have already acted by the time statistics such as sales, earnings, orders, and dividends are published. Technicians claim that various configurations on their charts, such as heads and shoulders, triangles, wedges, and fans, repeat themselves over and over again, signaling the start and the reversal of price trends. Thus by studying price charts, they believe they can detect trends soon enough to profit from them. <br /><br />Chart reading seems scientific but it isn't. For instance, the most celebrated of all technical theories is the Dow Theory. Richard Durant's <i>What Is the Dow Theory?</i> asserts that $100 invested in the Dow-Jones industrial average in 1897 would have grown to $11,237 by 1956 if these stocks were sold and repurchased whenever the Dow Theory gave the appropriate signal. This is equivalent to 8.3% compounded annually. By comparison, the University of Chicago's Center for Research in Security Prices found that random buying and selling of stock from 1926 to 1960 would have averaged a 9% gain per annum, about what the Dow Theory claims to have earned by design. <br /><br />My doubts about chart reading were strengthened by a test I gave to people who claimed to be able to "read" charts. I selected pages at random from a chart book, covered the name of the corporation and the last half of the chart, and asked what price change the "pattern" indicated. Their "predictions" were no better than those of someone making random guesses! </blockquote> It seems that most day-traders lose money... 80 to 90 percent, if this Slate article <a href="http://www.slate.com/id/1003329">Day Trading is for Suckers</a> is to be believed. And worse:<blockquote>The thing that is most remarkable about day trading, though, is the almost complete absence of a coherent investment theory that could justify the practice. If you read Warren Buffett or Peter Lynch or John Burr Williams, you get a clear sense of the principles that guide their investing. But if you talk to day traders and try to figure out why they believe they can beat the market, you don't get any real ideas. You just get a host of anecdotes about great trades. </blockquote><br />I had mostly dismissed the idea of day-trading as my understanding of investing has come from proponents of index funds and long-term investments, but a friend had recently suggested that long-term investing is hard because you need to know things about companies to be successful (which may be true if you define success as beating the index funds), whereas short-term investing is a game you can potentially win at just by studying price movements. From all of the above and because there is friction in the form of high transaction fees to overcome, I tend to conclude that, assuming it can be done at all, this is a very hard thing to do. <br /><br /><a href="http://epchan.blogspot.com/">Ernie Chan's blog</a> discusses quantitative and algorithmic trading and investment schemes. There seems to be a lot of sound analysis from the standpoint of information theory. Skimming through the posts, I did not immediately find evidence that such strategies can be successful. The closest I have found so far is a post called <a href="http://epchan.blogspot.com/2007/02/in-praise-of-day-trading.html">In praise of day-trading</a> which ends this way:<blockquote>Let me tell you a little secret: in my years working for hedge funds and prop-trading groups in investment banks, I have seen all kinds of trading strategies. In 100% of the cases, traders who have achieved spectacularly high Sharpe ratio (like 6 or higher), with minimal drawdown, are day-traders.</blockquote>The Sharpe ratio is defined to be (the rate of return minus the rate of return of some risk-free investment (like CDs)) divided by the standard deviation of this value. It is essentially the signal-to-noise ratio of the extra return you get from taking risk on a particular investment. There is no indication of what kind of strategies these successful day-traders were using, nor over what period they were able to sustain such high returns, but the implication is that, for some people, day-trading can work.Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.com0tag:blogger.com,1999:blog-4570157319323020998.post-3521018338402805512009-07-18T19:09:00.000-07:002009-08-06T09:07:31.836-07:00On the non-Gaussianness of finanical marketsIn 2002, Malcolm Gladwell published an essay in the New Yorker called <a href="http://www.gladwell.com/2002/2002_04_29_a_blowingup.htm">Blowing Up: How Nassim Taleb turned the inevitability of disaster into an investment strategy</a>.<br /><br />It is sort of a soft profile of 1) Victor Niederhoffer and 2) Nassim Taleb and his hedge fund (Empirica). Taleb's investment strategy begins by noting that people tend to be risk-averse in an asymmetric way (favoring smaller but steady gains and erratic but larger losses (which, I am inferring, shows up in the behavior of the stock market)) [as shown by Kahneman and Tversky]. Also stock market fluctuations do not really follow a normal distribution/Gaussian distribution/bell curve (which describes the statistics of a bunch of identical but independent things...This was one of the assumptions of the Markowitz model.). If you look at the tails (where the largest fluctuations occur), you find that these large fluctuations are much more likely than a Gaussian distribution would predict (as in, they happen perhaps once every few years rather than once very few millennia). This is referred to casually as "fat tails". Eugene Fama first discovered this, and the mathematician Benoit "Fractal Guy" Mandelbrot wrote <a href="http://www.amazon.com/gp/product/0465043577?ie=UTF8&tag=thesurtea-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0465043577">a book</a> analyzing this discrepancy and proposing an alternative model of financial markets.<br /><br />Mandelbrot's calculations show that a Cauchy distribution (a.k.a, Lorentzian distribution) is a better model for such market fluctuations. But is there something better? Probably there are more sophisticated models that require more computation. Fama's collaborator French talks about performing calculations without assuming a distribution. I am looking at academic papers to try to learn more. <br /><br />Today, Fama <a href="http://www.dimensional.com/famafrench/2009/03/qa-confidence-in-the-bell-curve.html">argues</a> though that the average passive investor really needs only to know that the Cauchy fat tails mean that market crashes and surges are more likely than many expect. Unfortunately, many non-passive investors operating in the fat tails without understanding them are believed to be responsible for the collapses of Long Term Capital Management, and more recently, AIG.<br /><br />According to <a href="http://www.bogleheads.org/forum/viewtopic.php?t=6866&start=0">posts on the Bogleheads forum</a>, Taleb's hedge fund had to close because (back in 2004) the excess market volatility that they were betting on was simply not there to earn sufficient profit from.Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.com0tag:blogger.com,1999:blog-4570157319323020998.post-65630200606995216212009-07-11T07:54:00.000-07:002009-07-11T14:13:04.831-07:00The statistics of bombshells and the efficient-market hypothesisJustin Fox has been promoting his book <a href="http://www.amazon.com/gp/product/0060598999?ie=UTF8&tag=thesurtea-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0060598999">The Myth of the Rational Market</a>. In this <a href="http://www.time.com/time/printout/0,8816,1904153,00.html">piece for Time Magazine</a>, he summarizes the historical development of the efficient-market hypothesis. <br /><br />This tantalizing excerpt from the piece, talks about the connection between solving an optimization problem and the mathematics of the market:<br /><blockquote>A key figure in the revival was the University of Chicago's Milton Friedman... [who] convinced himself and other economists (without much evidence) that speculators tended to stabilize markets rather than unbalance them.<br /><br />But Friedman was a scientist too. During World War II, he used his mathematical and statistical skills to help determine the optimal degree of fragmentation of artillery shells. Officers flew back to the U.S. in the middle of the Battle of the Bulge to get his advice on the trade-off between the likelihood of hitting the target (the more fragments, the better) and the likelihood of doing serious damage (the fewer and bigger the fragments, the better).<br /><br />Emboldened by this work, economists began to apply their number-crunching skills to the postwar market. Chicago graduate student Harry Markowitz devised a model for picking stocks that was, in Friedman's estimation, "identical" to his artillery-shell-fragmentation trade-off. And in the late 1950s, scholars at Chicago and the Massachusetts Institute of Technology became enamored of the idea that stock-market movements were, like many physical phenomena, random.<br /><br />The two strands of statistics and pro-market ideology came together in the mid-1960s. It was the great MIT economist Paul Samuelson who made the case mathematically that a rational market would be a random one.</blockquote>From browsing the <a href="http://en.wikipedia.org/wiki/Harry_Markowitz">Wikipedia entry on Markowitz</a>, it sounds like his work was the first to incorporate risk (or second moments) in his estimates of the value of a portfolio. Markowitz is also responsible for the concept of the "Efficient Frontier" (the set of all investment portfolios which maximize expected return for a given level of risk) which eventually led to the efficient-market hypothesis. I would still like to know the exact mathematical details of Friedman's modelling...Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.com0tag:blogger.com,1999:blog-4570157319323020998.post-63344375093233288822009-07-08T06:41:00.000-07:002009-07-08T08:22:35.647-07:00My interest in investingMy current interest in investing started in 2007 when I read an article from San Francisco Magazine called, "<a href="http://www.sanfranmag.com/print/node/3368">The Best Investment Advice You'll Never Get</a>". It starts with a story: <blockquote>As Google’s historic August 2004 IPO approached, the company’s senior vice president, Jonathan Rosenberg, realized he was about to spawn hundreds of impetuous young multimillionaires. They would, he feared, become the prey of Wall Street brokers, financial advisers, and wealth managers, all offering their own get-even-richer investment schemes. ... [T]o protect Google’s staff, he proposed a series of in-house investment teach-ins... One by one, some of the most revered names in investment theory were brought in to school a class of brilliant engineers, programmers, and cybergeeks on the fine art of personal investing, something few of them had thought much about.</blockquote>John Bogle and Burton Malkiel gave talks on the statistical superiority of indexed mutual funds and their low fees. Like income taxes, the friction provided by the transaction costs of frequent stock trades or the commission fees of actively managed mutual funds can easily reduce the total value of your investment portfolio by half. You may wind up with more money than you started out with (as investing is not a zero-sum game) but far less than you could have had with a balanced portfolio of index funds.<br /><br />The simplicity and nonconformity of such thinking appeals to me.<br /><br />But given that investors using such strategies lost a lot of money in 2008 (knocking out gains from the past five to ten years in some cases), is this still a valid approach? And if so, is it the best approach?<br /><br />John Bogle was recently quoted as saying:<blockquote>I read all the time that investors need to move beyond a buy-and-hold strategy, but this strikes me as being a dumb idea. What is the advantage of swapping stock with other people? The stock market system is based on the idea of pitting the interests of one investor against another, knowing that only one will win. People say it's a stock-picker's market but, if your stock picker is good, then mine is bad. It's all a gimmick.</blockquote>There are other approaches beyond picking stocks and investing in index funds with fixed allocation percentages. At this stage, I still have more questions than answers. In this blog, I will document my attempts to understand economics and learn how to invest.Surly Teabaghttp://www.blogger.com/profile/07251453183815233705noreply@blogger.com0