# Solved – Understanding the mean and rate of an exponential distribution

Background:

In the field of Civil Traffic Engineering the arrival of the vehicles in a road is random process modelled by exponential distribution .

Illustrative example:

Along this line, let's consider the following example:
We have a road which is `800 m` long, and we have `X` number of vehicles (let's say `20`) moving at constant velocity `10 m/s`. If we want to have uniform distribution of vehicles in the road, we would need to insert a vehicle every `4 s`; Calculated by: `road-length`/`vehicle-velocity`/`number-of-vehicles` `=` `800`/`10`/`20` `=` `4`.

Question:

However, as it is given here the distribution for such a scenario has to be exponential. What would be the interval for vehicle insertion, and more specifically the `mean` and the `rate` of the exponential function for the values given above:

• `road-length` = `800 m`
• `vehicle-velocity` = `10 m/s`
• `number-of-vehicles` = `20`

If you notice some poor explanation in my example due to misunderstanding of basic concepts please correct me.

Contents

Exponential refers to the time between cars. Instead of having the cars inserted exactly every 4 seconds, generate a random number according to the exponential distribution with mean of 4.

The density function of the exponential function is \$f(t ; lambda) = lambda e^{-lambda t}\$ and defined for \$t>0\$. The mean of the distribution is \$frac{1}{lambda}\$. So use an exponential function with \$lambda =frac{1}{4}\$ and the random numbers you generate will have a mean of 4. In other words, \$lambda=frac{1}{4}\$ will give us a rate of 1 car every 4 seconds. In general, if we want a rate of \$k\$ cars every \$x\$ seconds, we can set \$lambda=frac{k}{x}\$.

Depending on the software library you use, it is possible that the exponential function is defined as \$f(t ; beta) = frac{1}{beta} e^{-frac{1}{beta} t}\$ where \$lambda\$ was changed to \$frac{1}{beta}\$. If this is the case, then use an exponential function with \$beta=4\$ and those random numbers generated will give a mean of 4.

Given a random number generator (between 0 and 1), you can generate your own exponentially distributed numbers using \$frac{-ln(r)}{lambda}\$. In this case, create 20 random numbers between 0 and 1. Then for each number \$r\$, calculate \$frac{-ln(r)}{frac{1}{4}}\$ and you'll have 20 exponentially distributed numbers with mean=4 to use as your headway.

Lets look at a complete example. Say we have 20 cars travelling 10 m/s on 4 roads where each road is 800m long. Using a similar equation from the original question, this will give us a rate of

\$\$ begin{align} frac{1}{distance (m)} times speed Big(frac{m}{s}Big) times totalCars (c) times frac{1}{roads(r)} &= rate Big(frac {c} {s times r}Big) \ frac{1}{800(m)} times 10 Big(frac{m}{s}Big) times 20 (c) times frac{1}{4(r)} &= frac {1 (c)} {16 (s times r)} end{align} \ \$\$

This a rate of 1 car per 16 seconds per road. To simulate this, generate 4 exponentially distributed random numbers with \$lambda=frac{1}{16}\$. This will be the time until the first car for each road. Then as each car enters the road, immediately generate another number to determine how long until the next car enters the same road.

Rate this post