When I was working in Yahoo at Suntec City, I used to take the MRT to work every day and my route is completely sheltered right to the doorsteps of the office so the weather didn’t really have much effect on me. I still take the MRT to the office now that I am at Garena, but there is a short distance from the MRT station to the office, about 5 minutes of walking, where it is subject to the elements.

Now I don’t take any umbrellas along with me, so with the recent change in weather (it has been raining cats and dogs and all sorts of mammals in between) I have been caught a few times in some unpleasant wetness. It is during one of these wet commutes from home to office I was thinking of ways of making sure that will not happen again.

The idea was like this. I will place some umbrellas at the office and also at home. Whenever I leave the house or the office and if it is raining, I will take the umbrella to the office or back home respectively. Naturally if it’s not raining then I wouldn’t want to look like a dork and carry one.

Therein lies the problem. Let’s say I keep 1 umbrella at the office and another at home. If it rains when I’m leaving the office, I will carry that one home, leaving 2 at home and none at the office. If it rains the next day when I leave home it’s ok, I will just take an umbrella to the office, making it 1 – 1 again. If it doesn’t rain and therefore I don’t take any umbrellas to the office, I will be left with 2 – 0. If it happens to rain when I’m leaving the office I’m stuck with getting wet again.

What if I have 2 umbrellas at the office and 2 at home? In this case I will be caught wet only if the same occurrence (rain when leaving the office followed by no rain when leaving the house) happens 2 days in a row, which probability is lower than if it happens just once. Still, that can happen and I want to get assurance that the risk of getting wet is really minimal. In that case, the question becomes, how many umbrellas should I leave at the office and similarly at home such that the probability of getting wet is negligible? Note that it doesn’t really matter if one place has more umbrellas than the other since it will be the same as the lower number of umbrellas in the long run.

To find out, I used a popular (and really pragmatic and therefore very ‘engineering’) method of finding probabilities — the Monte Carlo simulation method. The name sounds fancy but it’s really just an algorithm that uses repeated random samples to find the answer. In our case, what we want to do is to find out, over large sample, the average number of trips I will make before I run the risk of getting wet.

To find this, I will need to inspect the probability that it will rain at any given day. For easy of calculations, I use a probability between 1% chance that it will rain and 99% chance that it will rain. Why don’t I include 0% or 100%? This is because if it is 0% it means it will never rain and so I will never need to use an umbrella, and if it 100% it will always rain and therefore I will always bring an umbrella back or forth.

On top of that, I will run the simulation for the case where I have 2 umbrellas at home and at the office, up to 50 umbrellas at home and at the office. To give a large enough representation, I run this over 1000 iterations (more will be better but it will take too long to run). This is the Ruby code for the simulation.

require 'rubygems' require 'faster_csv' umbrellas_range = 2..50 probability_range = 1..99 @location = :home total_trips = {} iterations = 1000 def walks_to(loc) location = loc @num_of_trips += 1 end def office?() @location == :office; end def home?() @location == :home; end def raining?(probability) rand(99) < probability; end FasterCSV.open('umbrellas.csv', 'w') do |csv| csv << [''] + probability_range.to_a umbrellas_range.each do |umbrellas| probability_range.each do |probability| total_trips[probability] = 0 iterations.times do @num_of_trips = 0 wet = false home = umbrellas office = umbrellas while not wet if home? walks_to :office if raining?(probability) if home > 0 home -= 1 office += 1 else wet = true end end elsif office? walks_to :home if raining?(probability) if office > 0 office -= 1 home += 1 else wet = true end end end end total_trips[probability] += @num_of_trips end end row = [umbrellas] total_trips.sort.each { |pair| row << pair[1]/iterations } csv << row end end

The Ruby program writes to a simple CSV file called *umbrellas.csv* with the first row being the probability, and the first column the number of umbrellas at each location. If you chart each row with the y-axis being the number of trips and the x-axis being the probability of rain from 1% to 99%, you will find a chart like this:

Now that I have the average number of trips that I will make before I get wet, I want to actually see what that means for Singapore. To do this, I went to the National Environment Agency’s website and dug out the weather statistics for Singapore. There is a statistic that gives the average number of rainy days in any given month for the past 118 years. I take that for each month and divide that with the number of days in that month to derive the monthly probability of rain as in the following table:

Month |
Probability of rain |

January | 48% |

February | 39% |

March | 45% |

April | 50% |

May | 45% |

June | 43% |

July | 42% |

August | 45% |

September | 47% |

October | 52% |

November | 63% |

December | 61% |

Finally I match that with the Monte Carlo simulation I made earlier. The average number of trips for each month, must be between 56 to 62 days (each trip is one way only, so every day is 2 trips). For example, the statistics shows that the wettest months are in November and December which is 63% and 61% probability of rain respectively. This means I will need to have 38 umbrellas at each location for each of these 2 months (please check your *umbrellas.csv file*; open it up with Excel). In February where the probability of rain is the lowest (39%), I will only need 23 umbrellas at each location to almost guarantee that I will not get wet (the whole deal assumes at the end of each month, I replenish each location with the necessary number of umbrellas, of course).

That evening when I proudly told my wife my findings at home, she stared at me for while (frostily if I might add) then gave me a small folding umbrella, which I now carry in my laptop bag.

And that is the reason why engineers should get married.

(I have been inspired by this book — Digital Dice : Computational Solutions to Practical Probability Problems, by Paul J. Nahin)

lol awesome experiment! Agree with your conclusions too :)

lol.. your findings are good in a comic strip :D

Interesting, the eyes of technical..

You are a genius sir.

heh. I have thought about that (especially during the rainy months!!!) – but never went to that extent to do the math… Good on u!!! Now i know i just need 30+ umbrellas….

OR, how about a “group umbrella pool”? Although i guess the only difference for that would be if people leave at different times – and there is a variability in the rain/no rain factor because of that….

I was just thinking of the folding umbrella while reading the article.

I”ve a habit of carrying one since long time ago. My wife doesn’t and says she can always count on a friendly stranger to ferry you across, to which I stared at her blankly and said “just carry one and stop being a liability to others…”. Well, she’s still not carrying one.

Nice simulation. The use of Monte Carlo sampling will help you to localize around a global maximum and hence you are getting close to observation data. If the seasons of rain becomes irregular, then other forms of sampling or additional heuristic will be required.

Really, Flash is elelcxent. You can watch videos on desktop YouTube on your phone counting videos that were blocked for YouTube’s mobile version of the site.

fjcGz3 dlafwzbujzov

CtKeup mezgmowmodye

Or, you can call your colleague to come down and fetch you an umbrella, given that next time your colleague is caught in the rain, you will be the hero.

But then you got to calculate the probability of your colleague being earlier than you in the office * probability colleague is available . Deviate that with the probability of colleague getting sick and going for oversea trips, that will do the trick!

Okay, get married is easier.

Nice story. My gf will probably do the same thing.

But seriously, real man just walk in the rain.

I suppose this is jsut an excuse for u to write codes. :)

I gave up on umbrellas. The folding umbrellas are too flimsy to stand up to gusts.

Instead, I wear a hat and a good coat. On rainy days, I’ll take a backpack with a rain cover. I have both hands free, and I don’t have to fuss around with opening and closing umbrellas. Yay!

On the downside, I’ve chased my hat across a sidewalk before. You may want a sturdy hat with a strap for the wind. =)

Nice simulation, though!

good one :)

Very interesting indeed. I liked the way you converted your thoughts into a program which I think is very appreciative and thoughtful.

:)

Omg. Things that run inside an engineer’s head…

What if when you start going to work it’s still sunny but when you reach your work place it rains?

Isn’t the probability a bit high? Usually there’s at most 2 rains a day, so 3hrs/24hrs, which is <<50%.

Now we take some smaller probability, like 12%, i think u'll need less umbrellas, and the solution is feasible.

But if you walk under rain and think about your wife who gave you the umbrella, then it should be more fun than some calculation.

Logistics fabulous, colleagues saw also buy, really good, like a friend and quickly start Oh bags received, the quality is very good, I liked it, my colleagues also say good to see, has been introduced to them, the seller attitude is very good, very patient, there is a need also to buy later received the bag, good quality, and customer service call back to say when the bag when it will send the goods to, very good, logistics is also fast, will continue to focus on bags received, the quality is also good, leather is very good, feel good, color is, the capacity is also great, very good seller services, logistics is also fast, the next will be in to it! Bags received.

Mlb 2011 Mvp Race http://gvcvn.com/GoAre.aspx?ajBlMGYwYjUyOTg5NTIxMjU.html