|
Modeling the
variables to calculate time for commuting to
work
Ultimately we
want our model to give output in terms of
time - the number of minutes and seconds our
commute will take. Therefore to
simplify the model, we'll convert each of
the variables to time rather than MPH before
adding the variables together.
The first
variable in our commuting algorithm is this:
Drive 2
miles on a highway, with 90% probability
you will be able to average 65 MPH the
whole way, but with a 10% probability
that a traffic jam will result in
average speed of 20 MPH.
Converting each scenario into time rather
than MPH requires simple arithmetic.
Driving 2 miles at 65 MPH requires (60 x 60)
x 2 ÷ 65 seconds, or 111 seconds. At
20 MPH, the time required is (60 x 60) x 2 ÷
20 seconds, or 360 seconds. To model
the probabilities, we'll use the RAND()
function to return a number between 0 and 1.
If the number is less than .9, we'll use the
65 MPH outcome, otherwise we'll use the 20
MPH outcome. An Excel equation
modeling this result is:
=IF(RAND() < .9,
111, 360)
The second
variable follows a traffic light through a
120 second cycle where RED lasts 90 seconds
and GREEN lasts 30 seconds. If we hit
it on green then there's no delay, but if we
hit it on red we wait until it turns green.
This problem is a little tricky because if
we make two separate references to RAND() in
the equation, each reference will return a
different value. Thus we have to find
an equation that uses RAND() only once.
The following equation does the trick:
=MAX(0, (RAND()
* 120) - 30)
Let's analyze the equation. The value
"RAND() * 120" inside the inner parentheses
simulates the number of seconds remaining in
the 120 second cycle after we arrive at the
traffic light. If we arrive during the
first 90 seconds of the cycle, we have to
wait until the first 90 seconds of the full
120 seconds are elapsed. This is equal
to (TIME REMAINING) - 30. If we arrive
during the last 30 seconds of the cycle, we
don't have to wait at all. In this
case, "TIME REMAINING - 30" is a negative
number, so MAX(0, TIME REMAINING) returns 0
wait time.
|