Tuesday, October 30, 2007

Opportunity cost and grad school

I apologize in advance to everyone who knows this stuff, but I keep writing posts and then realize I need to make sure my audience is familiar with some concepts before posting it.

The opportunity cost is the cost of not doing something
. It is something that is widely ignored and it shouldn't be.

Last June I received my undergraduate degree in Software Engineering. I considered going to grad school but finally decided against it (but I might reconsider that in a few years, we'll see). As I was looking into different universities, I was taken aback at the high cost of the private US colleges as opposed to the Canadian ones. Grad school in Quebec cost about 5,000$ a year for every University. At the MIT, for example, the cost is around 32,000$ a year.

When you quickly look at those numbers, you might think that it would cost me about six times as much to go to the MIT compared to McGill. Well, first of all we need to add in the cost of living, which we can estimate at 10,000$ a year in Montreal and 15,000 a year in Cambridge. We're now at 15,000$ vs 47,000$, still a 3x difference.

Now, let's add the opportunity cost. To go to grad school, I would've had to give up my ability to work a full time job. Let's say I was offered a job at 50000$ a year (after-tax), the cost of going to grad school would now be:
McGill: 65,000$ / year
MIT: 97,000$ / year

The difference is now merely 1.5x. Of course, in absolute term, the money I have to pony up is the same. If you really want to go to a pricey, then don't let money be in the way. The tuition cost will only be a small part of what you'll really pay anyway.


And something else to consider with these numbers. How much do you think a masters or a doctoral degree is worth? In this case, a masters degree at McGill will have to be worth at least 130,000$ to you before you decide to do it.

For some people it is, for others it's not.

P.S. No, I'm not a shill for the MIT, I've never been anywhere near Boston.

TCS: How to transform time into money



Let's make an assumption: If you wanted to, you could work 168 hours a week. This isn't exactly true on several levels, but let's take it as a fact for now. Let me convince you. You might say: "But I have a 40 hours a week job, I can't do overtime". To that I would say that you could find another job, I'm sure the nearest fast food are in need of people, or you could start your home business. I don't know, you could assemble Ikea furniture for elderly people? Buy and sell stuff on ebay? Here's one anyone could do: farm gold on World of Warcraft. Thus, every time you want to do something that doesn't involve making money, you have to factor in the opportunity cost of not working.


If you think you could be making 10$/h and you decide to go see a movie instead, it's really costing you the 10$ entry price plus your time, 10$/h x 2h = 20$, so 30$ overall.

We've now established how every hour in your life could be transformed into money, proving the good old adage time is money. We'll get into how every hour aren't born equal pretty soon.


(Photo by lortica)

Saturday, October 27, 2007

When should you ask for help

Typical thread in a forum:

A. "I can't make Product XYZ work"
B. "Have you looked at the FAQ and the Manual? Can you give us more info."
A. "What's your problem? I ask for help and you tell me too look in the manual?"

We have a wonderful example of someone who values his time much more than the time of other people.

There is a mailing list at work that is used for miscellaneous stuff and has a lots of subscriber. People often send emails that make no sense when you consider the huge amount of readers. Let's use TCS to try to figure out when to ask for help.

There are about 3400 people subscribed to this mailing list. Let's assume that half of those people read it. That makes say 1700 people reading messages sent to it.
Let's say employees costs my company an average of 40$/h. That comes down to approximately 0.01$/s.


Whenever you send a message, it costs the company approximately 17$ for every second that message takes to read.
TCS = 1700person * 0.01$/person*s = 17$/s
If you send a message that takes an average of 10 seconds to read, then that message just cost the company 170$ in lost productivity.
TCS = 17$/s * 10s = 170$

Lets' say I send an email saying "Can someone give me a ride to xyz". If you expect that message to take 5 seconds to read, then it's only a good idea if the taxi ride to xyz cost more than
TCS = 17$/s*5s = 85$
Especially if you reply afterward saying "Thanks everyone, I've got someone", which might takes another 5s to process and raise the total cost to 170$.


Of course this implies that people would be working instead of reading your email, which isn't true in most cases. Most people tend to look at those messages in their downtime, which destroy my case, but it's still interesting to look objectively at it.

Wednesday, October 24, 2007

Quantum Programming

Quantum Programming happens when your program only works when you run it step by step in a debugger.

Credit to Mike for bringing that up.

Tuesday, October 23, 2007

Someone call the nut house

because we have a crazy mathematician on the loose!

Some people have told me that my ideas are way too complicated for most people, and I tend to agree. To some rare individuals, it seems that they are a gross oversimplification. My good friend L.C.S., who has a promising blog named Les aventures du mathématicien fou, had so much to say about my last post Why is the bus so often late in the comments that it would be a crime not to re-post it here.

So there it is, his two posts:

First Post

That looks interesting. However, I do think your model neglects some important things. First, waiting w for the runner causes not only the people in the bus to lose time, but also all other eventual passengers on the bus ride. Indeed, after waiting for the runner, the bus will be w seconds late.

Suppose we number the bus stops along the ride by 1, 2, ..., N. We set X_i to be the number of passengers in the bus between stop i-1 and stop i. Let Y_i be the number of people waiting for the bus at stop i. Then, if the runner is at stop k we have the following TCS if we wait for the runner:

TCS = w * (sum{Y_i, i > k} + X_k)

Then, for it to be valuable to wait, we need:

t > w * (sum{Y_i, i > k} + X_k)

Second, it would be very unfair to wait for the runner at stop k but not for other runners. Thus, if we want to be fair, we need either to wait for all runners along the ride or for none of them.

Let w_i be the time to wait for the runner at stop i. This time can be zero if no runner is present at stop i. Then, if we do not wait for them, the TCS is:

TCS = (N - 1) * t

If we do wait, we get:

TCS = sum{w_k * (sum{Y_i, i > k} + X_k), k = 1, 2, ..., N - 1}

Now, it is unreasonable to suppose we already know all X_i and Y_i. We should treat them as random variables with a given distribution (which can be found by sampling the commuters). Then we can make the calculation with the expectation of the TCS for waiting.

Second Post

Ok, I just realized I made an important mistake. If we do not wait for the runners, then the TCS is not necessarily (N - 1) * t. It is so if there is a runner at each bus stop. A more realistic TCS is given by
TCS = M * t
where M is the number of runners.

And the point you made is very important indeed, Simon. We need to define what "time" means in this context. If we consider an absolute time, then a "runner" at stop i+1 that arrives w_{i+1} seconds late will not cause any problem if the bus has already more than that much time late. However, considering this is much more complicated.

In my comment, I used a "relative" time, meaning that the w_k were times measured relative to the arrival of the bus at stop k. Similarly, I made the not so realistic assumption that the time between buses is alwats t. So even if a bus is already late the runner that did not pick the bus will wait t, not t minus the amount of time the preceding bus was late...

I think it is possible to formulate this problem in a more convenient way. Something like
minimize TCS
s.t. some constraints
To do this, we need to find an expression for the TCS that includes both cases (waiting and not waiting). Then we could set the w_k as variables an try to find what values give an optimal solution to that problem. I still need to figure how to do that. As soon as I found something, I will post it here.

Sunday, October 21, 2007

Why is the bus so often late?

How long should a bus driver wait for someone who's running to the stop? Well, we've got this nice little tool called Total Cost to Society(TCS) that we can use.

Let's lay down the variables:
t: amount of time(in seconds) before the next bus
p: number of people in the bus
w: amount of time(in seconds) to wait for the running passenger

Considering that the driver has no information about the passengers, we can assume that everyone's time is worth the same.

Let's first see the two decisions and what their respective TCS are:
1. The bus driver wait
Consequence: Everyone in the bus has to wait for w seconds.
TCS = w * p

2. The bus driver doesn't wait
Consequence: The running passenger has to wait until the next bus
TCS = t

So for it to be valuable to wait, we need:
t > w * p
With a slight transformation we now have the magic formula of

w < t / p


Let's look at an example. There is a bus every 10 minutes (600 seconds) and that bus now contains 30 passengers.
w < t / p
w < 600 / 30
w < 20

We learn that in this case, the TCS of waiting will be lower as long as the wait is less than 20 seconds.

(Photo by dennis)

Saturday, October 20, 2007

Total Cost to Society

Life is full of choices. Every day you're confronted with different paths that you must choose from. These go from "should I do the dishes now or do it later" to "should I quit my job". When you're about to make a decision it's important to be able to quantify each different outcomes.

Now, there a tons of ways to quantify the effect of a decision but the ones I use most often are money and time, which some would argue is one and the same, simply because they're the easiest to work with. Happiness would be a great quantity to measure but it's very difficult to do so, yet it can often be a used as a multiplier.

It's often relatively easy to quantify how a simple decision will affect you, but it's harder to see how it affects other. I guess it's part of being human, we always want to put out interests first. So I've developed a system that I've been using for a long time in my head without ever formalizing it. Well, now is the time to give it a name and purpose.

I've decided to call it Total Cost to Society(TCS), which is a bit of misnomer because it's very individual-centered. I reserve the right to change the name once I find something better. TCS aims give a certain measure of the effect of your actions on yourself and everyone else around you.

I expect it'll take a few posts before I can fully explain the concept but I'll ignore a lot and give a simple example.


Let's assume everyone's time is worth exactly the same in every circumstances and there are no monetary costs to different options.

I don't have a car, never have (though I'm thinking of buying one, I'll do the analysis soon, should be fun). I'm going to a friend's place that is slightly far away. By mass transit this'll take 30 minutes of subway and 60 minutes of bus, for a TCS of 90 minutes. My other option is to ask my friend to come and pick me up (he, on the other hand, has a car). It's a 35 minutes ride in a car, so my friend will take 30 minutes to come to my place, and then both he and I will take 35 minutes to go back to his, for a TCS of 105 minutes.

In this case, it's clearly a better choice to take mass transit. But we should look at other options. After taking the subway, I'm now only 15 minutes away if I get a ride. In this case the TCS becomes 75 minutes. Great! Of course I'm omitting tons of stuff such as the cost of public transport and gas, the relative value of everyone's time and much more.

I hope to go over that example in more details as I go over several different concepts.

Cheers.

Thursday, October 18, 2007

Reduce the amount of coins you keep

I keep hearing people complain about having so much change in their pocket, especially people from my homeland of Canada where there are 1$ and 2$ coins and the smallest bill is a 5$. I've never really had that problem, but I guess I'm not an average individual so I'll share how I do it, it's pretty simple.

1: Know how much you're carrying.
It's important to remember what you have in the deep ends of your pocket. You might think that you have way too much change to remember that, but you'll see that's it's actually pretty easy once you start keeping your change to a minimum.

2: Preemptively count your change.
I guess this kind of conflicts with rule 1, but when you're waiting at a line to pay, now is the time to get all your change out and count it. Most people I see in lines turn their brain off, look at those celebrity rags, and when they realize they have to pay 5.23$ they waste 10 seconds searching through their pockets for a quarter to avoid receiving a lot of change.

3: Pre-compute the total
This is a though one because it's not always realistically possible. For example, if you're doing your groceries and you have 20 items, there's no way you can actually get an accurate amount. If you can get the total up to the cents, then you're probably officially mad. ;) But most transaction seems to be one or two items, such as buying a coffee. In that case you can probably know approximately how much it's going to cost after taxes and plan for it.

4: Giving the right amount
Now comes the hardest part. When you get the total and need to choose how much to give. The objective is to minimize the amount of coins you have in your pocket. You want every coin in your pocket to be the minimum amount you can have. Let's state what that minimum is first. This is in $CND, but just remove the 2$ coins and it works with $USD

4 1¢
2 10¢
3 25¢
2 2$

It's pretty easy. You never want more than 4 pennies. Then, you don't want more than one 5¢, and never more than 25¢ in 10¢ and 5¢. Then you don't want more than 3 25¢. The rest is only for Canadian money. You don't want more than one 1$, and never more than 4$ in 1$ and 2$. In all cases the highest amount of coins you'll be carrying is 11, or 9 in $USD.

Alright, so what can we do now to minimize that amount easily. The easiest thing we can do first is try to get rid of pennies. It's easy because most people (I hope...) can take a total and see how many pennies they need to give to not receive any (for my mathematically-oriented friend, the "total mod 5").
Once you have that, the second easiest thing to do is reduce that to a multiple of 25¢. Say, if the amount to pay if 6.43$, you want to lower that amount to a multiple of 25¢, and the closest one is 6.25$. So you need to give 43¢-25¢=18¢ in coins.
Now that you understand those two tricks, you can extend the logic to make sure you never have two 5¢ and never four 25¢.

Let's look at an example. Say I need to pay 6.43$, I might give 11.18$ so that I'll get 4.75$ back. So I got rid of 1 1$, 1 10c, 1 5c, 3 1c (6 coins) and got back 2 2$, 3 25c (5 coins), so I have 1 less coin. If I had simply given a 10$, I would've received 3.57 so 1 2$, 1 1$, 2 25c, 1 5c and 2 1c (7 coins). Everyone's happier! Just make sure to pre-calculate it so as not to waste the time of the people waiting in line behind you, you don't want to be the douchebag wasting everyone's time.

I hope that helped.

New purpose

Well, I think I've finally found something to write about. After a participating in this discussion on the dslreports forums, I realize I might have something to talk to people about.

I've thus decided to call my blog "Optimizing the world". I'll try to post ways to optimize your daily life without too much trouble. I'll try not to post too many irrelevant stuff, but I can't promise anything.

Have fun!