Computer simulation to answer: should you really run to catch the bus?
I was going to miss the bus the other day on my way to work, that is yet another stressful situation which we all know about. My instant instincts as always suggested that I should run to be able to catch it before I'd have to wait for the next one for 10 more minutes, but something deeper than my reptilian instincts this time, which must have looked more at the statistical long-term consequences of such “strategy”, suggested that maybe I should not? Yes, welcome to the mind of a “data guy”!
“Alert Strategy” vs. “Relaxed Strategy”
Have you ever wondered if the time saved by running truly outweighs the stress and effort? I have gone through a data-driven analysis on a Monte Carlo simulation of two strategies on Python: running to catch the bus when it approaches or is waiting at the bus stop (which I call “alert strategy”), versus consistently walking instead (called “relaxed strategy”). The particular question I am going to answer is: “how much time per trip on average would we expect to save in the long term by devising the ‘alert strategy’ over the ‘relaxed strategy’?”?
Initial conditions
Imagine every bus comes at the time interval of every 10 minutes, and you are 40 meters away within the visible range of the bus from the bus stop, which would mean it would take you a maximum 10 seconds to get to the stop by running. Assume that you and the bus show up at random times, and the bus always stays at the stop for 10 seconds, leaving its doors open in that time window before it departs.?
In below charts, you can see the behavior of the passenger as the bus approaches on "alert strategy". X axis is time, Y axis is location relative to the stop, the orange line represents the passenger and the blue line represents the bus.
Methodology
I used Monte Carlo simulation, that is simulating and running the experiment many times and track the metric (i.e. saved time), so that we will have the distribution pattern of that metric in the long term and be able to calculate the average, etc. for it.
In a single run of the experiment, the bus comes at a random relative to the passenger show up time. The clock starts ticking when the passenger reaches a certain distance from the bus. The simulation involves the movement of two objects at a time, that is the bus and the passenger with basic rules. The rules for the bus is it comes at regular intervals, and pauses for a certain amount of time at the stop before it departs. As for the passenger, they always keep moving towards the bus stop with a variable speed. If the passenger sees the bus approach or wait at the stop, they change speed to "running speed". Otherwise, they will always keep the "walking speed". The clock stops ticking as soon as both the passenger and the bus are at the bus stop, which means when the passenger gets into the bus.
By running the one-off simulation, we will be able to track the time the passenger waited for the bus. It could be that the bus was close enough that the passenger could reach it by running, it could be that they missed it even after running, or it could be that the passenger arrived too early without needing to run at all. In whichever scenario that the simulation faces, there will be one instance of the metric "time waited". Comparing that metric with the baseline of "time waited" for the relaxed strategy, one could get the value of the metric "time saved" by the "alert strategy".
To get the probabilistic distribution of this metric, we will need to run the experiment numerous times and track the metric every time. That is basically what Monte Carlo method is about.
Conclusion: Running saved the passenger only 30 seconds on average in the long term - why not, instead, wake up 30 seconds earlier then? ??
Devising a “relaxed strategy” where you always walk regardless, it will take 40 seconds for you to reach the stop and after that, it will take 300 more seconds on average until you depart the station by bus. This means that in the long term, it takes 340 seconds from when you head towards the bus stop until you depart.
However, devising the “alert strategy”, the simulation shows that this average time will be ~310 seconds, saving you 30 seconds per journey in the long term. In other words, being alert for the bus and prepared to run will bring you an advantage of 30 seconds in the long term every time you are about to take the bus. This is only the equivalent of saying that devising the “alert strategy” will save you just as much time as combining “relaxed strategy” with leaving your origin place (e.g. house) 30 seconds earlier every time will.?It also goes without saying that this simulation does not numerify the mental costs and the stress from being alert, as that is highly subjective and can differ from one person to another.
You would have saved 1.5 seconds by running regardless - 28.5 seconds is your real reward
It is also worth mentioning that “alert strategy” will entail running at heart. Imagine your destination (e.g. office) to your origin (e.g. house) was close enough so that you would walk the whole path on foot. If you run a part of this path, you will save time. Therefore, it is important to also note the average distance you will have to run on “alert strategy”.?
The simulation shows that you are expected to run ~2.1 meters per journey in the long term. Running a mere 2.1 meters of the entire path, without utilizing the bus at all, would still result in a time saving of 1.5 seconds due to the act of running. In other words, out of the whole 30 seconds you will save on the “alert strategy”, 1.5 seconds of it is your reward for the act of running and 28.5 seconds is your reward for being alert thereby running smartly.
领英推荐
Initial conditions matter
There are quite a number of parameters in the initial conditions that would affect the time saved. Some of them are: the duration during which the bus allows passengers to board at the stop, your running speed, the frequency at which buses arrive, and the visibility distance from your starting point to determine if the bus is approaching.
passenger_loc = -50 # Passenger's initial distance to the stop in meters
? ? ? ? constant_bus_speed = 10 # Bus speed in the simulation in m/s.
? ? ? ? constant_running_speed = 4 # Passenger's running speed in m/s.
? ? ? ? constant_walking_speed = 1 # Passenger's walking speed in m/s.
? ? ? ? constant_bus_in_stop_time = 10 # Number of seconds the bus will board passengers at the stop.
? ? ? ? bus_visibilty_distance = 40 # The distance of visibilit of the bus for the passenger before the bus stop.
? ? ? ? bus_interval = 600 # Frequency of bus arrivals in seconds.
? ? ? ? bus_loc = -round(random.uniform(-constant_bus_speed * bus_interval, 0)/constant_bus_speed) * constant_bus_speed # Bus initial location relative to the stop in meters. This is set as a random value between the distance a bus can travel within its frequency of commuting and the stop..
You can find the entire code at the bottom of this page
You can find the specific relationship between these parameters to the end time that is saved. The general idea is that higher values for each parameter lead to greater time savings. However, there is a point of diminishing returns where excessively high rates for any of the parameters will result in reaching a Pareto optimal state. Beyond this point, further increases in the parameters have less impact on the time saved, and the sensitivity to the parameters diminishes.
The longer the bus waits at the stop, the more tim
Code:
I have opened a whole new GitHub account for these LinkedIn series. Feel free to get the code for this simulation on GitHub.
https://github.com/mp4linkedin/linkedin_series/blob/main/bus_stop_strategies.py