Exercise
A large number of waiting time problems have an
exponential distribution of outcomes. We shall see (in Section \ref{sec 5.2}) that such outcomes are simulated by computing [math](-1/\lambda)\log(\mbox{rnd})[/math], where [math]\lambda \gt 0[/math]. For waiting times produced in this way, the average waiting time is [math]1/\lambda[/math]. For example, the times spent waiting for a car to pass on a highway, or the times between emissions of particles from a radioactive source, are simulated by a sequence of random numbers, each of which is chosen by computing [math](-1/\lambda)\log(\mbox{rnd})[/math], where [math]1/\lambda[/math] is the average time between cars or emissions. Write a program to simulate the times between cars when the average time between cars is 30 seconds. Have your program compute an area bar graph for these times by breaking the time interval from 0 to 120 into 24 subintervals. On the same pair of axes, plot the function [math]f(x) = (1/30)e^{-(1/30)x}[/math]. Does the function fit the bar graph well?