Reasons Unbeknownst

December 21, 2007

Oxymoron: Funny Economics Story

While working on HoundWire I would often go to Park Bench Deli (a few blocks up the hill from where that photo was taken) in Altadena with various interesting people. One fellow diner was our intern from Caltech. Caltech is the west coast rival of MIT so they have some very smart professors wandering the halls. One out of every thousand alumni has received the Nobel Prize. The point is that the professors there know a little bit about what they teach.

To the story. Stephen, the undergrad, had a math class that was being taught after an economics class. The econ teacher inconsiderately left his scribbles on the chalk board for the math professor to deal with. According to the story the math professor walked in, looked at the econ equations for a minute, turned to the class and proclaimed “This is complete nonsense”.

A great analogy I heard about economics is that of a book report. Modern economists look at novels, run statistical analysis on the average words per paragraph and paragraphs per chapter. It’s all very scientific, high brow stuff based on calculus. Then they use that information to try to predict what the author’s next novel will be about. Of course that’s completely ridiculous but it explains why economists have predicted 9 of the last 4 recessions.

The Austrian School argues that you can’t predict the author’s next book unless you understand human nature. One of the most important books in the Austrian School is called Human Action by Mises. It just makes sense in my not yet well enough read opinion.

If you have an hour to kill I highly recommend this 70 minute podcast about the Austrian School from the Econ Talk website:
http://www.econtalk.org/archives/2007/12/boettke_on_aust.html
I’ve listened to it about 4 times and it’s sinking in. Good for long, caffeinated drives.

Photo info

March 15, 2007

Investing, Journalism, and Mass Psychology

My finance professor in college had a newspaper clipping stuck to his door. On it was a successful chimp with a dart standing in front of a wall-mounted newspaper stock chart. The impression left was that it’s impossible to beat the street. Markets are supremely rational and trying to out rationalize emergent intelligence is futile.

The housing bubble changed that perception. Even in 2004 it was evident that something was seriously amiss. I was making decent money yet there was no way I could afford a home based on the typical 2-3x income number used to determine affordability. Especially here in San Diego. This agitation led to my research on liar-loans, piggybacks, 80/20s and the general decline of lending standards.

So back on June 23, 2005, after a lot of research and head scratching, I wrote this on my blog.

If I had equity right now I’d sell my house, buy a NASDAQ index fund and rent for the foreseeable future.

There are two reasons I could have been right. It was either luck or some failure in the market system. Why a failure? Because I don’t think I’m smart enough to predict the future. But my ego is just big enough to try an explanation of market failure.

Journalists will track down corruption, cover car accidents, etc. But how enthused would they be about driving the news van to the scene of an accident involving their own family? They might tell the audience “They are all going to make it, everything is going to be ok.” Which would be totally understandable though maybe not totally accurate.

Newspaper circulation was declining sharply due to monopoly crushing web competition precisely as the housing boom was ramping up. Perpetual home price appreciation was the light at the end of the tunnel for a lot of job-insecure, home-owning journalists. Ad revenue from home builders, furniture suppliers, and mortgage lenders was the only thing keeping a lot of these people employed.

Occam’s Razor. No conspiracy theory needed. Wall Street probably knew about the mortgage problems but were content to let the stucco orgy rage on, unchecked by reporters. In the dank, econ aware part of their brain, journalists probably knew too. The average consumer had no reason to doubt the bullish, commission crazed mortgage broker and realtor because the “bubble” was something only talked about by the occasional grumpy renter-relative(that would be me).

When reporters tend to drive drive half million dollar Fords you’re probably going to hear a lot more about Toyota’s problems. It would have been nice if, following these breathless articles about the miracle of real estate, writers would have added the following disclaimer…

The views, opinions and conclusions expressed by Lois Lane are those of the author, who has a zero down, negative amortization, stated income loan on a ridiculously over priced condo. She is about to lose her job due to competiton from blogs.

Next time. The Fed – Nefarious Middle Class Squashers or Overpaid Delayers of Inevitability?
Image is by Satanoid on Flickr.

February 20, 2007

Emergence, Economics, Psychology

I’m not sure if it’s a character flaw, looking for big but simple ideas and hoping emergence will arrange them and spit out present or future reality. Maybe I have a thing for Occam’s Razor

“The principle states that the explanation of any phenomenon should make as few assumptions as possible, eliminating, or “shaving off”, those that make no difference in the observable predictions of the explanatory hypothesis or theory.”

It’s one of those things I’ve noticed working back from my love of technology, people, and economics. Economics lead me to Hayek who said about governing

…it is the individualist who recognizes the limitations of the powers of individual reason and consequently advocates freedom as a means for the fullest development of the powers of the interindividual process.

Or Tolstoy on intuition

“Reasoning led him into doubt and kept him from seeing what he should and should not do. Yet when he did not think, but lived, he constantly felt in his soul the presence of an infallible judge who decided which of two possible actions was better and which was worse; and whenever he did not act as he should, he felt it at once.”

Or Po Brosnon on child rearing:

“When we praise children for their intelligence,” Dweck wrote in her study summary, “we tell them that this is the name of the game: Look smart, don’t risk making mistakes.” And that’s what the fifth-graders had done: They’d chosen to look smart and avoid the risk of being embarrassed.”

Or Edsger Wybe Dijkstra on Software

“The competent programmer is fully aware of the limited size of his own skull. He therefore approaches his task with full humility, and avoids clever tricks like the plague.”

What’s more complicated – the brain, or a few hundred million of them operating in a democracy? Is it a matter of scale? Let’s assume communism fails but psychoanalysis works. So emergence only works on a societal level meaning our brains aren’t the result of emergent order. I have a hard time buying that. Which is probably why I’m not a big believer in therapy unless you’ve run out of people to talk to.

Photo Uploaded on April 16, 2006 by lukecanvin

January 8, 2007

Math Discovery

Filed under: Culture,Philosophy,Random Thoughts — Kirk @

Knock on..
Originally uploaded by Splat Worldwide.

It was the ’90s. I was sitting in class in 8th grade, bored out of my gourd. I started fiddling with my calculator and found something weird. If you take a number, lets say 789654, and subtract the reverse (456987) and divide the result by nine you get an answer 36963 that is the same backwards or forwards. A numerical anagram, like radar. It struck me as weird that this little trick only worked for some numbers. Then the other day I posted my little find to the comments section of Reddit and found that I’d stumbled upon what are known as Lychrel numbers The discussion in response to my comment is below. A coder competition to calculate Lychrel numbers using Erlang breaks out. It’s possibly the geekiest, most interesting thing I’ve ever witnessed.

Along the same lines: take a natural number and add its reverse. After a few iterations, you get a palindromic number. For example:

* 7326 + 6237 = 13563
* 13563 + 36531 = 50094
* 50094 + 49005 = 99099 <--- A Palindrome

89 takes an unusually large 24 iterations (the most of any number under 10,000 that resolves into a palindrome) to reach the palindrome 8813200023188.

Numbers that do not form a palindrome through the process of reversing and adding their digits have been named "Lychrel numbers".

The first known number starting from 0 that does not apparently form a palindrome is a three digit number. And here we have again a mysterious number for which we not now if it is just incidental, or that there is some deeper mathematical reason why it is exactly this number. It is 196.
permalink parent reply
reply cancel


sblinn 1 point 4 hours ago*

I wrote some Python to do bits of lychrel computation recursively — it was a bad idea as eventually I reached:

RuntimeError: maximum recursion depth exceeded in cmp

Probably bad code, anyway:

import sys

def reverse_int(i):
return int(str(i)[::-1])

def is_palindrome(i):
s = str(i)
return s == s[::-1]

def lychrel(min,max,depth):

print_each_fail = 0
print_each_success = 1

num_lychrel = num_not_lychrel = 0

for i in xrange(min,max):
j = do_lychrel(i,depth)
if j == 0:
num_lychrel += 1
if print_each_success:
print "%d is lychrel at depth %d" % (i,depth)
else:
num_not_lychrel += 1
if print_each_fail:
print "%d is not lychrel at depth %d" % (i,j)

print "in the xrange %d to %d at depth %d there are %d lychrel and %d non-lychrel numbers" % (min,max,depth,num_lychrel,num_not_lychrel)

def do_lychrel(i,depth,j=1):

palindrome_i = reverse_int(i)
palindrome_sum = i + palindrome_i
if is_palindrome(palindrome_sum):
return j
elif (j+1) >= depth:
return 0
else:
return do_lychrel(palindrome_sum,depth,(j+1))

if __name__ == "__main__":
lychrel(int(sys.argv[1]),int(sys.argv[2]),int(sys.argv[3]))

It was easy enough to re-write the recursive part as a loop so it would actually run:

def do_lychrel(i,depth):

j = 1
while (j<=depth):
palindrome_i = reverse_int(i)
palindrome_sum = i + palindrome_i
if is_palindrome(palindrome_sum):
return j
i = palindrome_sum
j += 1
return 0

Results are things like:

# python lychrel.py 10 2000 2000
196 is lychrel at depth 2000
295 is lychrel at depth 2000
394 is lychrel at depth 2000
493 is lychrel at depth 2000
592 is lychrel at depth 2000
689 is lychrel at depth 2000
691 is lychrel at depth 2000
788 is lychrel at depth 2000
790 is lychrel at depth 2000
879 is lychrel at depth 2000
887 is lychrel at depth 2000
978 is lychrel at depth 2000
986 is lychrel at depth 2000
1495 is lychrel at depth 2000
1497 is lychrel at depth 2000
1585 is lychrel at depth 2000
1587 is lychrel at depth 2000
1675 is lychrel at depth 2000
1677 is lychrel at depth 2000
1765 is lychrel at depth 2000
1767 is lychrel at depth 2000
1855 is lychrel at depth 2000
1857 is lychrel at depth 2000
1945 is lychrel at depth 2000
1947 is lychrel at depth 2000
1997 is lychrel at depth 2000
in the xrange 10 to 2000 at depth 2000 there are 26 lychrel and 1964 non-lychrel numbers

Whee. It could probably be written much better with some reduce or whatever functional mumbo-jumbo. No matter what I tried, I couldn’t get the recursive version to be “properly” tail recursive without manually writing the loop.
permalink parent reply
reply cancel


BioGeek 1 point 3 hours ago*

sblinn, you seem to have enjoyed yourself with these Lychrel numbers :)

Now, with your code in hand, you should easily be able to solve question 55 at projecteuler.net:

How many Lychrel numbers are there below ten-thousand?
permalink parent reply
reply cancel

sblinn 1 point 3 hours ago*

Heh, it is not answerable without some proviso as to what I’m calling the Lychrel “depth”. I could answer “how many lychrel numbers are there at a depth of 200 below ten-thousand”:

$ python lychrel_loop.py 1 10000 200
in the xrange 1 to 10000 at depth 200 there are 249 lychrel and 9750 non-lychrel numbers

But nobody can say yet whether even 196 is “really” a Lychrel number or not, right?
permalink parent reply
reply cancel

sblinn 1 point 3 hours ago*

Some Erlang code for lychrel calculations (probably very, very bad code!):

$ cat lychrel.erl

-module(lychrel).

-export([is_lychrel/1]).
-export([is_lychrel/2]).

is_lychrel(N) -> is_lychrel(N,infinity).

is_lychrel(N,D) -> is_lychrel(N,D,1).

%% if we've reached iteration such that we've exceeded depth, it is a lychrel number at depth:
is_lychrel(_N,D,I) when I >= D -> true;

%% main guts
is_lychrel(N,D,I) ->
Nrev = reverse_int(N),
Nsum = N + Nrev,
Bpal = is_palindrome(Nsum),
if
Bpal -> false;
true -> is_lychrel(Nsum,D,I+1)
end.

reverse_int(N) ->
list_to_integer(lists:reverse(integer_to_list(N))).

is_palindrome(N) ->
N == reverse_int(N).

$ erlc lychrel.erl

$ erl

Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.5.2 (abort with ^G)
1> c(lychrel).
{ok,lychrel}
2> lychrel:is_lychrel(89,12).
true
3> lychrel:is_lychrel(89,24).
true
4> lychrel:is_lychrel(89,25).
false
5> lychrel:is_lychrel(8).
false
6> lychrel:is_lychrel(86).
false
7> lychrel:is_lychrel(89).
false
8> lychrel:is_lychrel(10911).
false
9> lychrel:is_lychrel(1186060307891929990).
false
10> lychrel:is_lychrel(196).

That last one won’t return — EVER — if the conjecture is true.

edit: little update that saves the resulting palindrome and iteration count:

%% main guts
is_lychrel(N,D,I) ->
Nrev = reverse_int(N),
Nsum = N + Nrev,
Bpal = is_palindrome(Nsum),
if
Bpal -> {false,I,Nsum};
true -> is_lychrel(Nsum,D,I+1)
end.

erl:

2> lychrel:is_lychrel(196,2000).
true
3> lychrel:is_lychrel(10911).
{false,55,4668731596684224866951378664}
4> lychrel:is_lychrel(1186060307891929990).
{false,261,
44562665878976437622437848976653870388884783662598425855963436955852489526638748888307835667984873422673467987856626544}

Any help making this properly tail-recursive would be awesome.
permalink parent reply
reply cancel


degustideathstar 10 points 1 day ago

Dividing by nine (or, actually, dividing by n-1 in a base-n system) has some kind of funny properties. This is probably related to how the digits in multiples of nine add up to multiples of nine.
permalink parent reply
reply cancel

sblinn 6 points 9 hours ago*

Fun. I wrote a little python program to calculate it (called it lychrel9 as I have no idea what the proper term would be):

in the xrange 0 to 100 there are 100 lychrel9 palindromic and 0 lychrel9 non-palindromic numbers

in the xrange 0 to 1000 there are 1000 lychrel9 palindromic and 0 lychrel9 non-palindromic numbers

in the xrange 0 to 10000 there are 6745 lychrel9 palindromic and 3255 lychrel9 non-palindromic numbers

The lowest is 1011. Breaking it down by 1000s yields surprisingly uniform results:

in the xrange 1000 to 2000 there are 633 lychrel9 palindromic and 367 lychrel9 non-palindromic numbers

in the xrange 2000 to 3000 there are 639 lychrel9 palindromic and 361 lychrel9 non-palindromic numbers

in the xrange 3000 to 4000 there are 643 lychrel9 palindromic and 357 lychrel9 non-palindromic numbers

in the xrange 4000 to 5000 there are 645 lychrel9 palindromic and 355 lychrel9 non-palindromic numbers

in the xrange 5000 to 6000 there are 645 lychrel9 palindromic and 355 lychrel9 non-palindromic numbers

in the xrange 6000 to 7000 there are 643 lychrel9 palindromic and 357 lychrel9 non-palindromic numbers

in the xrange 7000 to 8000 there are 639 lychrel9 palindromic and 361 lychrel9 non-palindromic numbers

etc. Going for only slightly larger numbers seems to be about the same distribution:

in the xrange 10000 to 20000 there are 6350 lychrel9 palindromic and 3650 lychrel9 non-palindromic numbers

But once we get to 6-digit numbers, the majority do not fit:

in the xrange 100000 to 200000 there are 42415 lychrel9 palindromic and 57585 lychrel9 non-palindromic numbers

in the xrange 100000 to 1000000 there are 385252 lychrel9 palindromic and 514748 lychrel9 non-palindromic numbers

in the xrange 1000000 to 2000000 there are 424210 lychrel9 palindromic and 575790 lychrel9 non-palindromic numbers

etc.

The interesting bit to me is that all numbers minus their reverse are evenly divisible by 9. Also interesting (perhaps) is that the set of “lychrel9″ and “non-lychrel9″ numbers is expensively computable (and determinable — unlike a lychrel number which cannot be proven to be such a number one way or another) and are perhaps useful in algorithms.
permalink parent reply
reply cancel


sblinn 2 points 6 hours ago*

For the curious, the horrible awfulness that is my python code for it:

import sys

def reverse_int(i):
return int(str(i)[::-1])

def is_palindrome(i):
s = str(i)
return s == s[::-1]

def lychrel9(min,max):
print_each_fail = 0
print_each_success = 0
num_palindromic = num_not_palindromic = 0

for i in xrange(min,max):
j = abs(i - reverse_int(i))
k = j / 9
if is_palindrome(k):
num_palindromic += 1
if print_each_success:
print "%d is lychrel9 palindromic" % i
else:
num_not_palindromic += 1
if print_each_fail:
print "%d is not lychrel9 palindromic" % i

print "in the xrange %d to %d there are %d lychrel9 palindromic and %d lychrel9 non-palindromic numbers" % (min,max,num_palindromic,num_not_palindromic)

if __name__ == "__main__":
lychrel9(int(sys.argv[1]),int(sys.argv[2]))

permalink parent reply
reply cancel


sblinn 2 points 6 hours ago*

Neat, another palindrome curiousity, this time with primes:

http://primes.utm.edu/curios/page.php/229.html

The smallest prime that remains prime when added to its reverse.

Replacing each digit of prime 229 with its square, respectively its cube, results in two new primes: 4481 and 88729, with a palindromic difference of 84248. Coincidentally, 229 + 4481 + 88729 is palindromic as well.

And there’s a cipher paper out there using palindromic differences (PDF):

http://csrc.nist.gov/pki/HashWorkshop/2006/UnacceptedPapers/MACHADO_caligo.pdf

January 7, 2007

Kirkfuscius Say

Filed under: Economics,Philosophy,Predictions — Kirk @



Knock on..
Originally uploaded by Nels1.

I constantly annoy my relatives with economic predictions. In retaliation they started calling me Kirkfuscius. So I was reading some more quotes by the National Association of Realtors’ chief economist and came up with a saying. But first the quote.

“It appears we’ve hit bottom, the price drops are necessary to stir sales. It is working.” (Globe and Mail Dec 29th 06)

David Lereah has been calling the bottom of the housing market on a monthly basis as the statistics deteriorate. So I came up with:

“He who calls the empty glass half full is not an optimist, he just has a drinking problem.”

December 25, 2006

Festivus for the Restivus




this is Roy..
Originally uploaded by Cory.

Random ideas had after drinking too much coffee…

  • Dynamic page width should become adjustable by the user using AJAX. And it probably will as more get wide-screen monitors. Nobody is using AJAX for page layout yet.
  • Open standards should be used for printable views of websites so they can be aggregated into something that would allow you to print new articles from all of your favorites sites in a seamless, newspaperesque format.
  • I started building the econ simulator. I’m learning Erlang to do it so it can someday take advantage of future CPUs and because C++ kills me.
  • I’m noticing fewer websites that make me slap my forehead and say “Why the hell haven’t they fixed this?”. 1 divided by that quote is my measure of web maturity.

Some quotes:

  • “Computer Science is no more about computers than astronomy is about telescopes.”
  • “The competent programmer is fully aware of the limited size of his own skull. He therefore approaches his task with full humility, and avoids clever tricks like the plague.”
  • “Object-oriented programming is an exceptionally bad idea which could only have originated in California.”

Computer Science and Economics are the same damn thing if you step back far enough, hence my use of Erlang(free markets) instead of C++(communism++). How a Libertarian, agnostic, econ-geek programmer could use anything other than Erlang for simulating economics strikes me as bizarre. I’m probably the only person trying so I guess I shouldn’t worry about it.

So I wrote this big fancy website in C# that calculates distances between zip codes and retrieves the nearest results. Microsoft even did a case study on it. Bill Gates was in San Diego and he was supposed to show up at our office. I was terrified he was going to ask to see my code. Well he never made it but now in my old age I realize that my code only worked because I didn’t try to do it by the book. And now Erlang shows up and tells me I’m not crazy.

It just struck me that I could convince a lot of programmers that believe in socialism to convert to the un-dark side by listing brilliant software quotes and them converting them to economic quotes. Most already believe in the logic behind free markets. They haven’t considered it outside of the domain of 1s and 0s yet.

November 16, 2006

Goodbye Freedman (sp)

Filed under: Culture,Economics,Philosophy — Kirk @

Milton Friedman, one of my favorite thinkers, passed away today. Some quotes:

‘One of the great mistakes is to judge policies and programmes by their intentions rather than their results.’

‘A major source of objection to a free economy is precisely that it … gives people what they want instead of what a particular group thinks they ought to want. Underlying most arguments against the free market is a lack of belief in freedom itself.’

‘I want people to take thought about their condition and to recognize that the maintainence of a free society is a very difficult and complicated thing and it requires a self-denying ordinance of the most extreme kind. It requires a willingness to put up with temporary evils on the basis of the subtle and sophisticated understanding that if you step in to do something about them you not only may make them worse, you will spread your tenticles and get bad results elsewhere.’

‘The society that puts equality before freedom will end up with neither. The society that puts freedom before equality will end up with a great measure of both.’

‘The most important single central fact about a free market is that no exchange takes place unless both parties benefit.’

‘It is because it’s prohibited. See, if you look at the drug war from a purely economic point of view, the role of the government is to protect the drug cartel. That’s literally true.’

‘Hell hath no fury like a bureaucrat scorned.’

‘If an exchange between two parties is voluntary, it will not take place unless both believe they will benefit from it. Most economic fallacies derive from the neglect of this simple insight, from the tendency to assume that there is a fixed pie, that one party can only gain at the expense of another.’

‘Inflation is the one form of taxation that can be imposed without legislation.’

‘If you pay people not to work and tax them when they do, don’t be surprised if you get unemployment.’

‘There is no logical basis for the prohibition of marijuana. $7.7 billion is a lot of money, but that is one of the lesser evils. Our failure to successfully enforce these laws is responsible for the deaths of thousands of people in Colombia. I haven’t even included the harm to young people. It’s absolutely disgraceful to think of picking up a 22-year-old for smoking pot. More disgraceful is the denial of marijuana for medical purposes.’

And a video…

October 31, 2006

The Office

Today I worked on a roof. I was sitting there clacking away at my laptop, configuring a router, and looked up. It’s very peaceful up there.

October 29, 2006

Geico Cavemen, Life

Filed under: Culture,Human Nature,Random Thoughts — Kirk @

The Geico Cavemen visited me this Halloween. It made my day.

Favorite songs at the moment:
Arcade Fire: Haiti, Rebellion
Muse: Stockholm Syndrome

October 21, 2006

The Bigger Picture

Psychology, media, technology, economics. It occured to me that everything I write about revolves around those four ideas. And that the world basically lives in two camps. Those that think we’re collectively smart enough to manage ourselves through a democracy, and those who think power needs to be wrestled from the hands of short-sited voters who will destroy the environment and economy if left to their own devices.

You also have the more defined idea of emergence: From Wikipedia:

Emergence is the process of complex pattern formation from more basic constituent parts or behaviors, and manifests itself as an emergent property of the relationships between those elements.

Some examples are free market pricing, evolution, and in the case of Democracies, Law. Evolution requires DNA, pricing requires educated consumers, and democracies require informed voters. When consumers aren’t informed about what they’re buying you get scams and economic crises. Option adjustable rate mortgages are an example of consumers doing themselves harm due to a lack of knowledge about money. When voters don’t know what they’re voting for they get politicians acting recklessly in an attempt to stay in power.

Without DNA, knowledge of economics or knowledge of products you will not get emergent order in the form of life, liberty or the pursuit of happiness(property). I guess I should define knowledge as understanding combined with selflessness. You had a problem with slave owners who knew that what they were doing was wrong but continued because they were comfortable with the status quo.

Joeseph Schumpeter commented on the problem with a lack of knowledge when applied to democracies:

“There will not be a revolution, but merely a trend in parliaments to elect social democratic parties of one stripe or another. He argued that capitalism will collapse from within as democratic majorities will vote themselves the creation of a welfare state and place restrictions upon entrepreneurship that will burden and destroy the capitalist structure.”

As did Bastiat in “The Law”

“According to their degree of enlightenment, these plundered classes may propose one of two entirely different purposes when they attempt to attain political power: Either they may wish to stop lawful plunder, or they may wish to share in it. Woe to the nation when this latter purpose prevails among the mass victims of plunder when they, in turn, seize the power to make laws!”

Bastiat says we’re screwed if we choose Socialism and Schumpeter argues that Socialism is inevitable in a Democracy.

Brain is giving out. Still haven’t covered accelerating change, emergent price and leadership, globalization, tech-deflation + fiat currency, asset bubbles, or why those supposedly in control would let Iraq happen. To be continued…

Newer Posts »

Powered by WordPress