Archive for August, 2009

On Homosexuality

Monday, August 31st, 2009

The BBC is reporting that thousands of Britons are now calling upon their government to posthumously pardon and knight Alan Turing. If you don’t know his story, you should.

Alan Turing is one of the founders of the field of Computer Science, which is the study of the mathematical laws underlying computation.   He proved, among other things, that there are some problems that cannot be solved by a computational device. Not only was Turing’s work theoretically impressive and groundbreaking, it was also of incredible importance to the allied effort during the second world war.  The British intelligence ran an outfit called Bletchley Park, whose sole purpose was to intercept German and Japaneses messages, break open the encryption schemes, and use the gleaned secrets to help the Allies.  The Germans had a complicated encryption computer called ‘Enigma,’ which they believed to be unbreakable.  There was a herculean effort on the part of the allies  to break open this encryption system, and it succeeded.  Alan Turing devised a machine called ‘the Bombe’ which could reverse engineer the settings on the enigma machine, to help decode its messages. It is entirely possible that without the efforts at Bletchley Park,  the war might have lasted a long longer or ended on an entirely different note.

Alan Turing was not only a genius who worked tirelessly to save the free world, he was a homosexual living in an age when homosexuality was illegal. In 1952 he was charged with having a homosexual relationship, and he accepted a sentence of chemical castration via estrogen injection.  His security clearance was stripped, he was forbidden form working at Bletchley Park, and a year later, he killed himself. Now, I suppose an apology on behalf of the British government would be nice, but it wouldn’t accomplish much.  After reading the story of Alan Turing, I realized that there is an entire class of people who live as second class citizens. If we would like to honor the memory of Alan Turing, the best response is to end the “Don’t Ask, Don’t Tell” policy and to stop treating a group of our fellow citizens as if there were something wrong with them. I am not homosexual and I do not really understand what causes some people to be so, but to me the reason is irrelevant -  there’s simply no excuse for discriminating against someone because of whom they happen to be attracted to.

Visual Studio Macro: Set ‘CopyLocal’ To False For All C# Project References

Monday, August 24th, 2009

I wrote this macro for work and thought other people might be able to use it.

Public Sub MakeAllRefsCopyLocal()
    For Each aproj As Project In DTE.Solution.Projects
        If (aproj.Kind = PrjKind.prjKindCSharpProject) Then
            Dim vsProj As VSProject = CType(aproj.Object, VSProject)
            For Each ref As Reference In vsProj.References
                Try
                    ref.CopyLocal = False
                Catch ex As Exception
                End Try
            Next
        End If
    Next
    MsgBox("All References Made To Copy Local")
End Sub

On the Failure of One Mathematical Strategy for Happiness

Thursday, August 20th, 2009

In my last post, I discussed a simple mathematical model of happiness. I made quite a few assumptions in building the model, and I thought I’d revisit one of them. In my model, people traveled through a world with one spatial dimension, and were either happy or sad depending upon their location and the time. It was quite a simple model, but it still yielded what I believe to be reasonable advice – listen to other people’s experiences and try to use that information to form a more complete picture of the world, in order to make yourself happier.

The strategy I proposed in the last post was to simply maximize the sum of the happiness you experience at each individual moment.  Let’s call this the SumOfHappinesses strategy. Is that a reasonable strategy? Despite my last post, I argue that it actually is not a good strategy to pursue.   My reasoning follows.

Suppose you live in a universe where you have 100 coins, and you have a device which flips them all at the same time. You’ll be very happy if they all come up ‘heads’. As happy as you possibly could be.  That happiness will last you for the rest of your life, too. In this universe, What do you do?  The SumOfHappinesses strategy says to keep on flipping as often as you can, in order to maximize your happiness.

Think about this for a second, though.  You spend your life doing nothing but flipping coins? I don’t care how happy it makes you, waiting your whole life for one extremely unlikely event to occur can’t be worth it.  Every time the event doesn’t occur, you’ll get upset, and most likely you’ll never reach the event.  The odds of all coins coming up heads are 1 in 2100, which is about one in 1.26 x 1030 . If you flipped the coins ten times a second, nonstop, for the age of the entire universe you’d still be very very unlikely to ever reach that ultimate happiness event.

You might argue that I’ve created an absurd universe – who would really be that happy if they flipped 100 heads in a row? It turns out that there are plenty of things that happen in the real world that are similar to my coin-flipping example.  The lottery is one thing that comes to mind – even if you could get one free lottery ticket each day, it wouldn’t be worth it to go out and pick the thing up, because your probability of winning is so small.

What are some other examples?  Becoming famous works perfectly here.  Let’s suppose your goal is to become the next rock superstar. You’d have to practice really hard, meet the right people, and be extraordinarily lucky.  If you put all your life’s effort and energy into becoming a rock star, the overwhelming probability is that you’ll end your life no more famous than you began.   The same is true in any other field that has ’super stars’  which is pretty much every field I can think of.

Does this mean you shouldn’t “shoot for the top?” Absolutely not – it just means you shouldn’t make “getting to the top”  your only source of happiness. If you like playing guitar, then by all means shoot for stardom, but make sure you don’t forget to derive happiness from your daily practicing.  If you focus only on the goal and not the process of getting there, you’re going to be unhappy. No matter how happy extremely unlikely events could make you, the fact that they’re extremely unlikely means that they’re really not worth pursuing unless you enjoy the act of pursuing them.

A Mathematical Model of Happiness

Thursday, August 13th, 2009

What if we could use mathematics to figure out how to make ourselves happier? I submit for your consideration that it is, in fact, possible.  In this post, I construct a simple mathematical model of experiencing the world, and then derive some principles from the model which I believe are applicable to real life. Let’s begin! Consider the following graph of my happiness over the course of a day:

[Happiness on a Typical Day]

The day starts off well, and reaches a peak when I eat my breakfast of eggs and turkey bacon. Yum. I get into my car, and there’s a wreck on 15-501, so I’m late getting to work. My mood goes down, but it’s still positive. Upon arriving at work, I realize that I’ve fallen seriously behind in a big important project, so my mood falls. As I work harder and harder, I keep realizing how much more work I have to do. My mood plummets, until lunch time. A dozen buffalo wings provide a brief respite and put me in a better mood, but I’m still frustrated about work. I have time to think at lunch, though, and I realize  I can save myself some time if I take a new approach that I hadn’t though of.  My mood improves, and by the end of the work day I’m happy again.   After I get home from work, I relax by playing a game of Left 4 Dead with some friends, and my mood improves back to where it was.

The above graph was generated using a type of randomized noise function called Perlin noise. In other words, I modeled happiness as simply the summation of random waves. What better models can we use to describe and predict how people can become more happy? If happiness is a function of time, the simplest model says that we just choose to be happy all of the time. I would argue that the ‘choose to be happy’ model is too simple to be very useful.  Happiness isn’t a simple binary choice: It’s hard to choose to be happy when it’s cold and dark outside, and you feel tired, lonely, and hopeless about the future. Conversely, It’s easy to choose to be happy when it’s sunny outside, you’ve just enjoyed a nice meal with friends, and now you’re playing a sweet designer German board game, like Dominion.  These  examples are taken from points in my life. Your mileage may vary. The examples demonstrate that, very often, external factors in your life play a huge role in how happy you are. I believe it is possible to influence those external factors, but influencing them Isn’t as simple as just saying “I choose the happy path.”

A more predictive model of happiness must therefore take into account external factors as well as personal choices.   After giving this idea a lot of  thought, I came up with a model, based upon the concept of ‘Experience-Space.’  Experience-Space is the set of all possible experiences that an individual could have. Points in Experience-Space are points in both time-space and sensation-space.  In other words, a single point in experience space describes the exact feelings you feel at a given time.   To make things as easy to understand as possible, we will say that the only sensation one can experience is happiness, and that, at any given instant in life, one can make one of three choices. Why three? When there is only one sensation, Experience-Space becomes two dimensional: time is one dimension, and the experience you have is the other dimension. We can represent life with an image. Your experience of life is a path traced by a pixel through that that image from left to right.  At each step in time, the pixel can either go straight forward, diagonally up, or diagonally down.  We will label these choices straight, up, and down.

Look at this example:

Choice of a Single Dot

In this example, the person is currently happy. They have a choice to make: in the next time tick, they will be happy if they choose straight or down, unhappy if they choose up.  This is a very simple model, but it proves surprisingly powerful in generating useful predictions about how we can make ourselves happier.

Suppose you know everything about the universe, and your goal is to be as happy as you possibly can.  You start out at some initial point in experience-space, and your goal is to maximize the sum of the happiness of the experiences you have over the course of your entire life.  (Is that a reasonable goal? A question for another blog post!). Suppose that experience space looks like this:

Gradient Model Of Happiness

If this is your universe, wherever you start out, your most logical move is to always choose to go down (when possible) and then go straight along the bottom edge of the graph, when (if) you ever reach it.  That’s easy enough. Let’s consider a more complicated model of the world:

Happiness as Perfect Moments

In this model, most experiences are either slightly positive or slightly neutral. There are quite a few “great” experiences, and a small number of “terrible” experiences. These big experiences are so big that they affect you for some time after you experience them.   How would you navigate this graph, in order to maximize your happiness? The problem begins to look like an artificial intelligence.  I’m not going to go into artificial intelligence algorithms such as A* search (as much as I’d like to.) Instead, I’m going to draw to draw some conclusions from this model.

In the real world, we don’t know the entire universe ahead of time: we only know the choices that we have made, and their ramifications. In other words, our graphs look like this:

A Single Path

That’s not a lot to go on. It would be hard to take that information and build a model of the world and use it to predict where to go next.  While walking like this, you’d probably notice that some areas were nicer than others, and that the really nice areas and really bad areas tended to clump together, but you’d still have a hard time determining which areas to go towards. Suppose there are 50 people in the universe, and you all share information about the choices you have made and the results those choices have brought you. Then, your picture of the universe looks like this:

More Paths Means More Knowledge

This picture is much more complete than the picture you were able to generate by yourself.  By using information you glean from asking others about the choices they make, you can make yourself happier.

Conclusion: Talk to as many people as you can, and learn about their experiences.  Doing this talking will allow you to gain a much more accurate model of the world as a whole, in order to determine what will make you happy. Ask people about their history, and specifically about choices they have made that made them happy or unhappy.

I hope to write more on this subject in the future. Stay tuned!

Mathematically Modeling Health Care

Monday, August 3rd, 2009

With the Obama administration pushing a massive reform of our Health Care system, I figured I would share my opinion on the subject, for all of those interested.  I firmly believe that if you want to solve a problem, the best approach is to come up with mathematical models for your problem, analyze them, and do what the models suggest.  In this post, I will gradually build a mathematical model that describes health care, asking questions about the model and proposing policies reflecting the outcomes of the model.  Let’s begin!

Model Version 1: There is a universe of N individuals with two states: healthy and sick.  Let the variable t represent time, with t =  0 being some arbitrary date, say January 1, 2009. In this model, t is discrete – that is, it takes on the values -3,-2,-1,0,1,2… &c.  In other words, there are no fractional times.  At each time t , there is a certain probability p_sick that an individual will become sick. It costs c_cure dollars for a sick become healthy.

How much does Health Care cost in version 1 of the model? If we have N people, then at teach time tick, p_sick * N become sick, then the total cost of keeping everyone health is

c_total  = N *p_sick *c_cure.

In this simple model, we have only one question to ask: who pays the cost of health care? Should the individual who becomes sick pay for his own cure, or should the government foot the bill?  I contend that this this question is entirely a value judgment.   Everyone has a different opinion on what’s fair or just. We could argue about constitutionality, but that wouldn’t get us anywhere either – everyone interprets the constitution differently and different people will just claim that the constitution backs their case.  Thus, the first conclusion:

Conclusion 1: The question of “who should pay for health care” is entirely a personal value judgement.

Model Version 2:  In version 2 of the model, we add in different diseases, and choices.  Let D = {d_0, d_1, d_2….} be different diseases that people could acquire.   Note that we could consider things like  broken legs and concussions to be ‘diseases’ because people do suffer from them, and they do cost money to cure. For each d_i, there is a cost c_i to cure that disease. Note that for some i, c_i is infinite. In other words, for some ailments, there are no known cures.  Additionally, let A = {a_o, a_1, …} be a set of actions that an individual could perform.   The actions a person takes affect the probability that they catch certain diseases. For example, if you choose to drive a car to work, you increase the probability of getting any number of bodily ailments. If you eat a bag of Cheetos for lunch, you increase your probability of getting a heart attack.  Let risk be a function that takes an action a_i and a disease d_j as input, and returns p_j. In other words, risk(a_i,d_j) is the probability that you will suffer from disease d_j if you perform action a_i.
How much does health care cost in this model? It’s almost impossible to answer. You’d have to know risk(a_i,d_j) for each possible combination of i and j.   As the models get more and more complex, we see that we can’t really predict from logical principles how much health care is going to cost unless we can predict what kind of actions people are likely to take.  What we can observe, though, is that the question of ‘who pays’ becomes more interesting. If the government pays for all health care, then people have no incentive to minimize the risks they take.   If individuals pay for their healthcare, however, they have every incentive to minmize the risks that they take, reducing the total cost of healthcare.  Model 2 suggests that the best solution is to have individuals pay for their own health care, so that they minimize the amount of risk that they take.

Suppose one of the actions is ‘going to the doctor for a routine checkup.’ Clearly, this action reduces the risk of many diseases.  If individuals are forced to pay for their own health care, and rational individuals wish to minimize the cost they spend on health care, then rational individuals would go to doctors for routine checkups.  In reality, this often doesn’t happen – so something is wrong with the model. Let’s expand it.

Model 3: Same as Model 2, except the concepts of “cost” and “cure” change. Now, instead of cost being associated only with disease, each action a_i has an associated cost given by cost(a_i) Sometimes the cost of an action is positive (going to the doctor, going to see a movie, buying gas) and sometimes the cost of an action is negative (i.e. selling a house, going to work.) For each disease d_i,  there is an action that cures the disease. Let this action be called cure_i. Additionally,  the function risk now takes a third argument as input: the state of the individual at time t. In other words, if you’ve currently got a cold, then your risk of sinus infection might go up.

How does Model 3 differ from Model 2? We have removed cures as some abstract thing that happens to people, and transformed them into actions that people take. As a result, the incentive structure of the system changes.  When some diseases increase the risk of other diseases, rational people are more willing to pay to treat the first disease, in order to prevent themselves from getting the second.   We can also explain why a lot of people people don’t go to the doctor under our current health care system -  the cost of going to the doctor is positive, but the benefits are small, becuase insurance is more likely to cover catastrophic illnesses than it is to cover minor ones.

I could go on and continue to expand the model, but I won’t (although I’d find it very interesting to do so.)  The conclusion I’ve drawn from the modelling process is that healthcare is really complex, invovling many value judgments. Answering questions such as ‘who should pay for what’ and ‘how much will it cost’ is not easy to do.  In light of that conclusion, the question you should ask yourself is: “What is the best way of answering complex questions involving the value judgements of many individuals?” Economists have been studying this question for centuries, and, empirically, the answer is pretty clear – governments are notoriously bad at answering these questions satisfactorily. Markets, while far from perfect, are the best solution anyone has ever devised.

The primary problem with a Market-oriented solution to health care is that it excludes those who are unable to afford health care. I believe that the best way to handle those who are unable to afford health care is to supply them with vouchers that they can use to purchase health insurance of their own choice.  This would create competition and reduce costs. The Obama administration seems to belive  not only that the government is entitled to answer all of these questions for us, but the government is actually capable of doing so, in a fair and just manner. Believing that requires a hurculanean leap of faith in government.  If you think the government is capable of solving the healthcare problem better than markets, you must certainly believe that the government can solve the question of ‘who should produce what, and who should consume what’ even better.   Communism died for a reason: governments are not as efficient or responsive as markets. Listen to the empircal evidence of history, and make up your mind accordingly. I welcome your comments.