# The probability of an event

And east and illustrative way of calculating the probability of an event via simulation is setting a "flag" with a value of 1 when the event has occurred, and a value of 0 when it has not. After running a simulation, the mean of this distribution of 0s and 1s will asymptotically approximate the probability of the said event. The following model illustrates this technique:

Two people agreed to meet under a clock between 1pm and 2pm. Each agrees to wait 20 minutes for the other. What is the probability that they meet?

The solution to the problem is provided below:

Here is a screenshot of the model:

Here is a screenshot of the model:

Uniform distribution was used to calculate the arrival time for the two persons. The departure time of the two persons is also calculated by simply adding the value of 20 (minutes they will wait) to their arrival time. The output is just a flag, returning a value of 1 if the times of the persons overlap, and a value of 0 if they don't.

This model has an embedded graph that provides a visual illustration of the time that person A and person B arrive and leave the spot under the clock. Whenever the two lines on the graph overlap, the output cell returns a 1 and when they don't, the output cell returns zero. Plots like this are useful to visually test the model functionality.

• No labels