Wednesday, November 12, 2008

Wikipedia wants you to be mauled by a bear

Holy cow, a post!  It's not at all what I usually write about, but it's better than nothing.


Thursday, June 19, 2008

Experiments on habits

As you might have read in a previous post, my company is able to innovate so quickly because we keep don't hesitate trying out new stuff. If someone has an idea, it can go from a vague thought to running on live traffic in a matter of weeks. If the numbers say that it's a good idea, we keep it. If not, we throw it out, no regret. My coworker has an interesting post about how we do some form of A/B testing.

Experimentation is at the very heart of science. If you don't try anything new, you can't learn anything. This is why I try to vary my habits from time to time to try something different. Last November I spent the whole month without drinking caffeine. I wanted to prove that "I can stop whenever I want to but I just don't want to" was true for me. Also, I wanted to know if I would be more or less tired, sleep better, etc. Overall, I found that after a few days of not consuming caffeine (coffee, tea, coke, etc.) I didn't really crave it at all and that it didn't affect my overall health level.

Since last Monday I've started to eat vegetarian. I've been talking about this for months and finally did it. Well, I've actually been told that since I decided to eat seafood I'm rather a pescetarian. I'm not a very difficult person when it comes to food, I'll eat anything. So it's been weird for me to start being picky about what I eat, I feel almost guilty.

Thus far, I've been kind of hungry a lot. I'm eating a lot Indian food because they have a lot of very tasty meals without meat. That, salad and pasta.

I haven't decided exactly how long I'm going to keep this up, at least until the end of June, maybe a few weeks longer, I'll see how it goes. I have no intention of this becoming a permanent thing.

P.S. I actually meant to start this last Friday. I did, but then I accidentally eat a chicken caesar salad for dinner... Not a very good start!

Sunday, June 8, 2008

How much do you value your life?

Let's say you're asked how much a human life is worth. To avoid weird looks in most circles you would answer that it's invaluable, we can't quantify something like that. Of course, I don't hang out with what could be considered normal people so my follow up question would probably be "which life?" ;)

Let's use our own life as an example, as it's the one we're all most familiar with. We put a price on our life with our every day actions without realizing it. When you decide to drive instead of taking the bus, you gamble your life away. It's much more likely you'll die while driving than while taking the bus. But you think that the time and comfort savings are worth the chances of you dying in a car crash, and so you take the car. How about when you decide to buy more expensive fruits and vegetables. The taste might be similar to cheaper ones but the more expensive organic fruits are generally better for your health, and thus more likely to increase your life span.

Stanford professor Ronald Howard invented a concept called the micromort. A micromort is a one in a million chance of death. In other words, it's the amount of money you would have to give to someone for them to risk a one in a million chance of death. If someone's willing to receive (or, more likely, save) 20$ for a one in a million chance of death, then we can infer they value their life at 20 million dollars.

There's this book I like called Making Great Decions in Business and Life where the authors use this concept to analyze a car purchasing decision. They, previously in the book, penned the human life at an average of 10 millions, so 10$ for a micromort. I'll quote from the book:

Consider buying a car. For each million lighter cars--those weighing less than 2,500 pounds--that are on the roads, 109 people die each year. For each million heavier cars--those weighing 3,500 pounds--that are on the road, only 53 people die each year. If we use an average of 10,000 miles per year per vehicle, then each mile driven in a smaller car costs the driver 0.0109 micromorts while each mile in a larger car costs 0.0053 micromorts. If you keep this car for 100,000 miles, then the smaller car has a safety cost of $10,900 (1,090 micromorts times $10 per micromorts) while the larger car has a safety cost of only $5,300 (530 micromorts times $10 per micromort). The larger car undoubtedly costs more to purchase and operate, but given everything else equal--don't consider the smoother ride, the bigger trunk, or the worse mileage--it is worth $5,600 more purely on safety.

Think about this concept as you make trivial decisions in your daily life and you'll be amazed at the amount of risks you take.

Sunday, June 1, 2008

Wondering what I do for a living?

I know I haven't been writing anything lately and I apologize to whoever might read this blog (hi mom!). I don't usually post work related things but there's an interesting article in the NYT about my group at Google that might be of passing interest to people who know me. Maybe you'll better understand why I think the way I do when you see the kind of people I spent my work weeks with.

That is all. I've got a great post coming up, it's been in my head for months, I just need to put it down on paper... well, computer, whatever.

Tuesday, April 22, 2008

Male restroom etiquette

I'd love to write a whole article about this, but the video covers everything that needs to be said.

Friday, April 11, 2008

So much for automated traffic cops

Looks like a few cities couldn't resist the temptation of easy money from their constituents. Six cities have been found to have shortened the yellow light duration after installing red light camera. This has the effect of catching more people on red lights, at the cost of causing more accidents.

What is wrong with those cities' government? I thought they were supposed to serve the people, not get them read-ended.

Through Techdirt

Friday, March 21, 2008

Monte Carlo simulation

Sometimes, figuring out something deterministically is hard.  Sometimes, it's just plain impossible.

Let's say we have a model and we want to make sure that model is correct.  The best way to do that is to mathematically prove that it is correct.  This works well for simple model, but when you have insanely completed models it become a huge pain to try to prove it right.  What can you do to validate it?  We can use something called a Monte Carlo simulation.  This is also known as statistical sampling.
Here's how wikipedia describe the Monte Carlo method:
  1. Define a domain of possible inputs.
  2. Generate inputs randomly from the domain, and perform a deterministic computation on them.
  3. Aggregate the results of the individual computations into the final result.
I'll use the simplest of example to show how this can be done.  I want to write a test to know if a number is even or odd (told you it was going to be simple).  I'll write some code to test it:

def is_even(number):
  if number % 2 == 0:
    return True
    return False

This is Python code by the way, but it should be simple enough even for non programmer.  It's a function called is_even that takes an integer and returns true if the number modulo 2 is 0 and false otherwise.

Let's run a monte carlo simulator on that function to make sure it's right.  We'll generate n random integer between minus one billion and a billion and we expect that around 50% of them will be even.  We'll set n at a reasonable 100 000 runs.  The higher the number of runs, the more accurate the result will be, or rather the higher the confidence in the results will be.  It should look like this:

import random
n = 100000
number_even = 0
for i in range(n):
  random_number = random.randint(-1000000000, 1000000000)
  if is_even(random_number):
    number_even = number_even + 1

print '%f%% of numbers are even' % (float(number_even) / float(n))

When I run this I get this message back:
0.501340% of numbers are even

And without any kind of mathematical proof we have validated the model.  Though it's important to realize I haven't actually proved anything, I've simply shown that with a high probability (I'm too lazy here but we could actually find the confidence interval relatively easily) the model acts a certain way.

This example was, of course, way too trivial.  But this kind of reasoning is very useful when a system has too many different components which makes it difficult to accurately predict, such as a traffic flow system (think about elevator planning for example).