Friday, January 25, 2008

Generating samples from a normal distribution

Stumbled upon an elegant result today:
If F is the cumulative distribution function of X, then F(X) is the Uniform Distribution on [0,1].

How to use this in practice? Well, NORMSINV(RAND()) can be used in Excel to pick a random value from a standard normal (Gaussian) distribution. Though accurate, this is very slow as it involves the inverse of an integral.

Wednesday, December 12, 2007

Career politicians

I am suspicious about the intentions of anyone who says he is a "career" politician. Such people typically are scoundrels.

Anyone with integrity seeks to provide value in the world. Administration, governance and bureaucracy is parasitic on others' production, at best it is neutral and at worst detrimental to usage of scarce resources.

The concentration of power in centralized administration has only "produced" genocide of more than 50 million people (WW1, WW2, Korea, Stalinist Russia, Mao China, Vietnam, Sudan ...) in the 20th century.

Monday, November 19, 2007

Your dream fulfilled - in Redwood City, CA.

Amazing real estate in the incomparable Bay Area:
Americans have always dreamed about being cowboys - a distinctly American profession. Well, if you own this house, you can practice corralling small children or pets! Maybe you could have a rodeo and lasso your cat! Try riding your dog! Or other American Dream fun fill activities.

Friday, November 16, 2007

On jobs, retirement and slavery

Something I found in my archives, dated Nov 28, 2002.
About the notion of "job".

The ancient Babylonians had a type of slavery in which the slaves worked for their masters and were paid a bit for that. If they so wished, they could sell crafts for themselves to make extra money in their spare time. They also had an option of buying their freedom.

(Slavery conjures images of flogging and hard physical labour, but the above form almost sounds like the life of an employee - you spend 8 hours a day working for your employer.. are free to do what you want in your spare time, even make money for yourself and can retire if you think you have enough money...)


The modern notion of a job was created by the industrial revolution.

In Victorian England, it was scandalous to do a "job". Any self-respecting individual "worked for himself". Obviously the very idea of a job seemed akin to slavery to the people then.

The subsequent boom in "Manufacturing and Services" made the concept of earning a living by working for another socially acceptable.


That brings us to retirement. This is an interesting creation of 20th century America !

In the 20's and 30's, America went into a deep depression. There just weren't enough jobs for people then.

In those days it was customary for people to work as long as they wanted to. It became imperative for the stability of the economy that older workers be replaced by younger ones.

But people just would not stop working voluntarily due to the difficult economic times. Also the elderly who did quit had no hope of gettign a job again because of all the young people in the job market.

So Social Security Act was passed (Roosevelt's New Deal) which made retirement a glorious event - work until age X (59, 60, 55 whatever) and you life after that will be automatically taken care of!

Cessation of work no longer meant abject poverty and penury, instead now there was a pot of gold at the end of the rainbow.

Thursday, November 01, 2007

Democratizing anxiety rather than opportunity

Excerpts from a review for The Chosen that is worth reading in its entirety.
Proof of extracurricular activities, leadership qualities, letters of recommendation -- we take all these as natural, necessary and even enlightened elements of the college application process, though they cause us endless anxiety. Actually, they don't resemble in the least the way people in Europe or Japan get into college. They're a result of a particular American challenge at the turn of the 20th century, which President A. Lawrence Lowell of Harvard then characterized as follows: how to "prevent a dangerous increase in the proportion of Jews."

By the end of the 19th century, Harvard, Yale and Princeton were committed not primarily to refining the intellect but to welcoming the well-bred, athletic, public-spirited and sociable scions of the privileged -- young men who may not have performed well academically but were destined to be the leaders of the next generation. The result of such measures, at Harvard and elsewhere, was a horrific surprise: too many Jews! Though most of these students were more than academically competent, they didn't fit the usual definition of "gentlemen." The key code word here was 'character', a quality thought to be frequently lacking among Jews but present almost congenitally among high-status Protestants.

Newly established admissions departments gathered increasingly large amounts of "background" data on each applicant. Race? Color? Religious preference? Birthplace of father? Previous surnames used by the family? Mother's maiden name? The need for letters of recommendation was born; so was the interest in extracurricular involvement. Photographs were required, and personal interviews were encouraged, particularly with local alumni who would be most eager to perpetuate the muscular and sociable undergraduate image dear to them. The mechanism was similar to that of self-perpetuating private social and country clubs where new candidates were admitted only if members vouched for them.

Since the number of admission slots was being limited while more and more applicants were meeting the Big Three's academic criteria, the various nonacademic criteria and "intangible qualities" became decisive. One logical alternative -- raising academic standards even higher to get a more brilliant, intellectual class -- was hardly a consideration. By contrast, it was the well-bred students of average intelligence who university elders insisted were more likely to end up as leaders in business and politics -- and to become loyal, generous alumni. Most university leaders made no bones about limiting the "super-bright" to only 10 percent of each class.

Astonishingly, this subjective college admissions system -- designed in the 1920s to discreetly exclude as many "social undesirables" as possible -- is the system we continue to use today. And the central irony of The Chosen is that the very flexibility that was designed to exclude nontraditional students and placate the alumni up to the middle of the 20th century was subsequently available to administrators to accomplish essentially opposite goals.

As the century unfolds, ... [these] three schools had to process these demands [for diversity in admissions] in terms of its own internal constituencies: faculty pressuring for "more brains," students and the press demanding diversity, and alumni in open revolt against any such changes.

Having decided to change the make-up of their student body in this new direction, each school was successful in doing so because from the 1920s on, admissions officers had at their disposal a variety of nonacademic criteria by which to evaluate applicants. And as Karabel notes, moves to include previously excluded groups were not terribly radical since the Big Three, in fact, "had never been pure academic meritocracies."

Dramatic as these developments appear, they hardly constitute a sea change in how universities make such decisions. University administrations still view a move to completely meritocratic selection as neither in their self-interest nor realistic. Instead, Karabel convincingly shows this new institutional behavior to be the result of constant administrative shifts in order to maintain an uneasy balance among competing demands.

Much has changed in who now constitutes "the chosen" -- the elite prep schools, for example, can no longer count on a high proportion of their graduates getting into the Big Three. "As a consequence, deep apprehension about college admissions now extends to the highest reaches of the upper class," Karabel writes. But much remains the same. "At the same time, the children of the working class and the poor are about as unlikely to attend the Big Three today as they were in 1954. It is no exaggeration to say that the current regime in elite college admissions has been far more successful in democratizing anxiety than opportunity."

Saturday, October 27, 2007

Market Sentiment

Comedy video explains how the market converts the tens of thousands lent to an unemployed black man in a string vest in Alabama to the more respectable Bear Sterns high grade structured credit enhanced leverage fund.

Wednesday, October 17, 2007

Principle of Least Surprise

Andrew Koenig has a post on surprises in designs:
[In APL,] a surprising result comes from three applications of the principle of least surprise:

1) It should be possible to have an array with no dimensions, and a zero-dimensional array should be the same thing as a scalar.

2) The size of an array should be a vector with one element for each dimension of the array.

3) When you do arithmetic on a scalar and a vector, the result has the same size as the vector.

Choosing the least surprising behavior in these three contexts causes the surprising behavior that the average of a scalar sum(v)/size(v) is an empty vector.

Monday, October 08, 2007

Life changing tech items -- wishlist

Google RSS, with feeds to technorati, gizmodo, techmeme and a few other early adopter sites. Thumbing through these in your free time will show you all of the upcoming tech trends and why they will change your life.
  • GPS
  • pandora.com ---> internet radio
  • slingbox http://electronics.howstuffworks.com/slingbox.htm/printable
  • at&t edge card for nationwide high speed internet access
  • A good DSLR camera.
  • Satellite radio
  • zappos.com ---> shoe store
  • cellphone bluetooth headset
  • Anti-TP-Delamination spray (two ply)
  • http://www.harmankardon.com/drive-1/
  • Amco citrus squeezers
  • NetVibes as your RSS reader
  • ohdontforget.com to send those text msgs instead of using a phone
  • https://secure.logmein.com/home.asp?lang=en
  • Sonos Music System makes MP3s available in any room with speakers
  • Roomba
  • Speakman shower head, screw off the back and knock out the flow regulator
  • upconverting DVD player from 480p (standard) to 720p/1080i (high def)
  • flickr.com, to quickly organize and store digital photos

Get TVersity (free software) and and one of PS3 / XBox 360 / any uPnP media player. Rip all your DVDs to hard drive (AutoGK) and you can now flix though them like a video jukebox on your TV. You can also watch internet video feeds, for example Youtube, on your TV.

Sunday, September 23, 2007

There can only be one ... ketchup!

Excerpt from an interesting article by Malcolm Gladwell of Tipping Point fame:
There are five known fundamental tastes in the human palate: salty, sweet, sour, bitter, and umami. Umami is the proteiny, full-bodied taste of ... cooked tomato. "Umami adds body," Gary Beauchamp, who heads the Monell Chemical Senses Center, in Philadelphia, says. "If you add it to a soup, it makes the soup seem like it's thicker—it gives it sensory heft. It turns a soup from salt water into a food." When Heinz moved to ripe tomatoes and increased the percentage of tomato solids, he made ketchup, first and foremost, a potent source of umami. Then he dramatically increased the concentration of vinegar, so that his ketchup had twice the acidity of most other ketchups; now ketchup was sour, another of the fundamental tastes. The post-benzoate ketchups also doubled the concentration of sugar—so now ketchup was also sweet—and all along ketchup had been salty and bitter. These are not trivial issues. ... Salt and sugar and umami are primal signals about the food we are eating—about how dense it is in calories, for example, or, in the case of umami, about the presence of proteins and amino acids. What Heinz had done was come up with a condiment that pushed all five of these primal buttons. The taste of Heinz's ketchup began at the tip of the tongue, where our receptors for sweet and salty first appear, moved along the sides, where sour notes seem the strongest, then hit the back of the tongue, for umami and bitter, in one long crescendo. How many things in the supermarket run the sensory spectrum like this?

Sunday, September 16, 2007

Installing a new external hard drive

First change the jumper to Master. It is usually set to Cable Select for internal hard drives.

Then for Windows 2000/XP, do the following:
  • Right click on My Computer
  • Choose Manage (This will open the Computer Management window).
  • Go to the Storage category and select Disk Management
  • Right click the new drive (usually listed as Hard Disk 1) and "initialize"
  • You now have the option to partition and format the drive.
  • The default settings of Primary Partition and NTFS- Quick Format are recommended for most users.

Saturday, September 15, 2007

Change a traffic light at will

Kipkay has a video on metacafe that shows how to change a traffic light at will:
Press the cross button 3 times quickly,
2 long presses,
1 short,
2 long,
3 short.

Monday, August 27, 2007

Interchangeable Parts

Excerpt from "Holding a Program in One's Head":
One of the defining qualities of organizations since there have been such a thing is to treat individuals as interchangeable parts. This works well for more parallelizable tasks, like fighting wars. For most of history a well-drilled army of professional soldiers could be counted on to beat an army of individual warriors, no matter how valorous. But having ideas is not very parallelizable. And that's what programs are: ideas.

Friday, August 24, 2007

Scalene triangles puzzle

Yesterday, God Plays Dice posed a scalene triangle puzzle:

Given a right triangle with integer sides, show that there is another integer-sided scalene triangle with a 60 degree angle and 1.5 times the perimeter of the given triangle.

Isabel posted the solution, but it involved getting several examples and making conjectures from them about the scalene-60 triple. Since I dislike the production of conjectures from data, and strongly prefer derivations from first principles, here is my detailed solution:

Consider scalene-60 triangles, there is one angle bigger than 60 degrees and one smaller. (Total is 180)
Say the side opposite 60 is z.
Let the smaller one be x=z-a, and the bigger one be y=z+b where both a and b are positive.
From triangle inequalities, you get

Then using cosine rule: x2 + y2 - xy = z2

Plug stuff in and simplify like crazy,
z(a-b) = (a2 + b2 + ab)

If a=b, then this becomes a=b=0, the equilateral triangle.
As the RHS is strictly non-zero, a>b.

Simplifying, z = (a-b) + 3ab/(a-b)

(z-a, z, z+b) generates all such tuples! The only condition on a,b is that (a-b) must divide 3ab.

Now (a-b) divides a if and only if (a-b) divides b.
(Proof: x divides a and x divides a-b, therefore x must divide b, now set x = a-b)

So we can scale a and b by (a-b) and get another triple.

In other words, it is enough to consider the two cases: a-b = 1, and a-b = 3.

Actually, we have parametrized all possible scalene-60 triples:
With a-b=3, we get one sequence and another with a-b=1

As an aside, this is an interesting picture:
If you draw a 60 degree angle and mark off 8 on one arm, use that endpoint to draw an arc of radius 7, it will intersect the other arm at 2 places -- at 3 and at 5. The angles correspond to arccos(1/7) and 180-arccos(1/7)

Coming back to the puzzle, all right triangles can be parametrized as (m2 - n2 , 2mn, m2 + n2 ) or a scalar multiple thereof, where m and n are co-prime and have opposite parity.
The perimeter is 2m(m+n).

1.5 times perimeter is 3m(m+n)

Can we map this to the scalene-60s?

Let us see. Try the first sequence: a-b=3
gives us z = b2 + 3b + 3 for triangle (z-a, z, z-b)
with perimeter 3z-3 = 3(z-1) = 3(b+2)(b+1)

Looks similar to what we want!

Now it is just a matter of fiddling with the definitions of (m,n) and (z,a,b) to get the common parametric form:
Right triple is (m2 - n2, 2mn, m2 + n2)
Scalene-60 is (m2 - n2, m2 + mn + n2, m2 + 2mn)
[Substitute b=(m-n)/n; and scale the triple (z,a,b) by n]

We are home and have a sequence of scalene-60 triangles left over!

Wednesday, August 22, 2007

The US employment based immigrant visa system

  • It is advisable to not change jobs except after all but one stages are approved, and the last one (Form I-485) has been pending for 6+ months.
  • For Indian and Chinese-born persons, it is imperative to apply in EB1 classification, the so-called "PhD category", from an established R&D department of a bigger company.
  • All other categories have queues pending several (2-5) years.
  • Mexico is impossibly backlogged (10+ years) except for persons with advanced degrees.
  • Philippines has some issues as well.
  • For nationals born in any other country, it is merely a procedural matter.
  • Family based immigrant visas are hopelessly backlogged for all nationals.
There now you can hold your own in any immigration related conversation.

Tuesday, August 21, 2007

Using sunrocket gizmo as an almost free telephone

Sunrocket, which was the 2nd largest VoIP provider in the US recently declared itself dead. So I was left with a phone adapter that was now effectively an expensive paperweight.

After some internet searches, I found a way to convert it to an almost free landline. Details follow.
-----------

I had the Innomedia Gizmo, which I first unlocked as follows:

Innomedia devices from sunrocket come with SNMP enabled. The community strings is private. The admin password OID is SNMPv2-SMI::enterprises.3354.1.3.1.1.3.2.0
So we browse this and change it. Download GETIF
1 - After you start the tool enter the IP address of you device in Host Name field, say 192.168.1.99
2 - Change the Read community to private (default is public)
3 - Click on start
4 - click on MBrowser tab
5 - St the bottom of the window you will see 3 fields that you can enter values in.
The first field is the OID enter .1.3.6.1.4.1.3354.1.3.1.1.3.2.0
The second field is the type. Change it to string
The 3rd field is the value. Enter any value you want (That's the new password).
6 - Click on the set button

Make sure:
1. Firewall is NOT blocking port 161. Be sure to enable that port.
2. Be sure WAN is connected to internet connection, LAN directly to the machine you are trying to SNMP from.
3. Browse to http://192.168.1.99/Voice_adminPage.htm and use admin and the password you just set!
---------------

Next use the unlocked gizmo with Gizo Project and Grand Central as a VoIP phone.
  1. Sign up for a Gizmo Project (note the SIP number) and
  2. Sign up for a Grand Central account (this is the new telephone number).
  3. Setup the unlocked Sunrocket Gizmo device to work with Gizmo Project
    1. Disable Provisioning. Go to IP Network-> Provisioning Setting. Uncheck the Enable Provisioning box.
    2. Setup your SIP Proxy. Go to VOIP->SIP Proxy. Use the settings in this image. proxy01.sipphone.com got cut off on this.
    3. Change your User Account. Go to VOIP->User Account. Your user ID is your Gizmo Project SIP number with the one before it. Your password is your gizmo project password. Image.
    4. Test Setup Setup your gizmo so that it is directly connected to the internet. The order should be modem - gizmo - router. If you want to put your gizmo after your router, you will need to forward UDP ports 5004, 5005, and 64064 to your voip gizmo, and enable QoS in the router. If you use a static IP for the gizmo, you will also have to set the DNS servers in the Gizmo.
  4. Finally, Setup Grand central to forward calls to your gizmo project account.
If you have your Gizmo project program running on the PC, you may have trouble receiving calls.
------------

When I accept a call, it tells me to press 1/2/3/4, when I do that, it does nothing. Keypad does not seem to work, but it works with my cell phone. Here is the fix for this issue:
1) Telnet into your gizmo and enter the login and password of the gizmo (obviously case sensitive)
2) Press C2 and make sure RFC2833 (SDP and 2833 packets) is ALWAYS OFF, Otherwise press 0 (zero) to turn it off.
3) Press Cs
4) Look for Use SIP INFO for DTMF = Yes
5) If it says no, then press c to change settings.
5.1) Look for 18. SIP INFO for DTMF
5.2) Press 18 to set it to yes
5.3) Press y at the prompt -- Use SIP INFO for transmitting DTMF digits?[y/n]
5.4) Press w to write setting to Flash
6) Power cycle the gizmo

You should now be able to accept GC calls and negotiate menus anywhere else, e.g., VM using th etouch tone keypad. Remember to set your phone to use tone dialing (not pulse).

Activating the second line on the gizmo:
1) Telnet into your gizmo and enter the login and password of the gizmo (obviously case sensitive)
2) Press Mp
3) Follow the on-screen prompts to activate both lines
4) Power cycle the gizmo
----------

Voila! Free incoming calls forwarded via Grand Central and outgoing calls at 1.9c/min via Gizmo Project.
----------
Connecting to the gizmo when it is behind a router -- use a static IP, say 192.168.1.99, for the gizmo. In this case, also set correct DNS servers on the Gizmo, especially when changing ISP, otherwise it won't work! Alternatively:
Say "ipconfig" on a network machine to find the address, say 192.168.1.1, of the default gateway/router.
Get the DHCP table from the router and lookup the Gizmo's IP address. The gizmo registers itself as "000XXX0XX4XX". Say this is 192.168.1.99 for instance.
Use that IP address to get the management page for the Gizmo.

Tuesday, August 07, 2007

Large vs. small companies.

Most large organizations are similar -- it just takes forever to get anything done and you have to negotiate with (beg of?) several people. Things are inefficient. Things move slowly. People don't care one way or the other most of the time.

This is not a defect in the system. Rather it is intentional. Reason (well, my hypothesis) -- large corps are merely trying to stay in business, not necessarily trying to innovate constantly. Their existence is not threatened every day. Accordingly they are optimized for continuity / stability than for efficiency / churn.

Startup life is arguably better -- you get to discuss strategy more than you get to do so as a corporate employee, (but orders of magnitude less than the founders and executive management). Eg: Today the CEO and two of us were talking about the business model of another startup, over lunch. That is typical.

As romantic as a startup sounds, for the founders it is actually a lot of infrastructure activity and for research-y types, often boring -- sales, marketing, fund raising, coding, tech work, hiring. Marc Andreessen has has a wonderful blog series on Silicon Valley startup culture.

However, for the employees, the work itself is far more focused than a corporate job, so you won't get diversity in what you do. The agenda is set in stone by the business plan and the CTO and there is no scope to budge an inch outside of that.

Instead, stay in a corporate job, and use the corporate setup to your best advantage -- get your immigration sorted out, read, travel, get some continuing education or personality development courses, pick up new skills or hobbies. That'll keep you excited and reduce your boredom.. :)

Here is an interesting thought -- On the Dilbert blog, recently Scott Adams recommended trying to get in the top quartile of the population in 2+ different things and then co-relate them, thus making a niche for oneself. He was in the top quartile of three things -- comedy and cartoon/drawing and knowledge of business culture. In any of the individual areas 25% of the people are better than him but in the intersection (Dilbert cartoon strip) he is easily in the top 1%.

Sunday, July 15, 2007

Mark to model vs. Mark to market

An excerpt from a study of valuations -- market pricing vs. fair pricing:
What is the common theme among Franklin, the Granite Funds and LTCM? All three depended on exploiting deviations in market value from fair value. And all three depended on "patient capital" -- shareholders and lenders who believed that what mattered was fair value and not market value. That is, these fund managers convinced their stakeholders that because the fair values were hedged, it didn't matter what happened to market values in the short run — they would converge to fair value over time. That was the reason for the "Long Term" part of LTCM's name.

The problem with this logic is that capital is only as patient as its least patient provider. The fact is that lenders generally lose their patience precisely when the funds need them to keep it — in times of market crisis. As all three cases demonstrate, the lenders are the first to get nervous when an external shock hits. At that point, they begin to ask the fund manager for market valuations, not models-based fair valuations. This starts the fund along the downward spiral: illiquid securities are marked-to-market; margin calls are made; the illiquid securities must be sold; more margin calls are made, and so on. In general, shareholders may provide patient capital; but debt-holders do not.

Saturday, July 07, 2007

Why people do things

Insightful excerpt on utility:
Vast amounts of human behaviour can be explained not by causal utility but by symbolic utlity, to use Nozick's distinction. We do many things not because they improve our (or others) objective well-being, but to signal who we are.
For instance:
  • Running in a race for cancer, world hunger, or child education

Monday, July 02, 2007

Improving democracy

Excerpts from a book review in the New Yorker on how to improve democracy in order to get better government and improve policy making:
... voters cherish irrational views on many issues ... relevant to economic policy. The average person, he says, has four biases about economics—four main areas in which he or she differs from the economic expert. The typical noneconomist does not understand or appreciate the way markets work (and thus favors regulation and is suspicious of the profit motive), dislikes foreigners (and thus tends to be protectionist), equates prosperity with employment rather than with production (and thus overvalues the preservation of existing jobs), and usually thinks that economic conditions are getting worse (and thus favors government intervention in the economy). Economists know that these positions are irrational, because the average person actually benefits from market competition, which provides the best product at the lowest price; from free trade with other countries, which (for American consumers) usually lowers the cost of labor and thus the price of goods; and from technological change, which redistributes labor from less productive to more productive enterprises.

People do not ... vote their self-interest: ... “Precisely because people put personal interests aside when they enter the political arena,” Caplan says, “intellectual errors readily blossom into foolish policies.” People really believe that the country would be better off if profits were regulated, if foreign goods were taxed, and if companies were prevented from downsizing. Politicians who pander to these beliefs are more likely to be elected, and the special interests that lobby for protectionism and anticompetitive legislation are the beneficiaries—not the public. The result, over time, is a decline in the standard of living.

... [M]ost economists peg the optimal level of government involvement in the economy too high, because they overestimate the virtues of democracy. ... some suggestions for fixing the evils of universal democratic participation: require voters to pass a test for economic competence; give extra votes to people with greater economic literacy; reduce or eliminate efforts to increase voter turnout; require more economics courses in school, even if this means eliminating courses in other subjects, such as classics; teach people introductory economics without making the usual qualifications about the limits of market solutions.

Sunday, July 01, 2007

Magazines get it late.

The annals of obvious research presents this bit: Are cover stories effective contrarian indicators?

Apparently by the time magazine covers feature a company outperforming its competition, most of the trend is over. Well, isn't that blindingly obvious? A magazine article is supposed to analyze past events and make for interesting reading, and almost any event is best explained in hindsight when all the facts are available, not in real time while it unfolds and some or most of the key facts are hidden from public view.