Module 3 : Microscopic Traffic Flow Modeling
Lecture 13 : Vehicle Arrival Models: Count
1 2 3 4 5
 

Random variates following Poisson distribution

For simulation purposes, it may be required to generate number of vehicles arrived in a given interval so that it follows typical vehicle arrival. This is the reverse of computing the probabilities as seen above. The following steps give the procedure:
  1. Input: mean arrival rate $ \mu$ in an interval $ t$
  2. Compute $ p(x=n)$ and $ p(x\leq n)$
  3. Generate a random number $ X$ such that $ 0\leq X\leq 1$
  4. Find $ n$ such that $ p(x\leq n-1) \le X$ and $ p(x\leq n) \ge X$
  5. Set $ n_i=n$, where $ n_i$ is the number of vehicles arrived in $ i^{th}$ interval.
The steps 3 to 5 can be repeated for required number of intervals.

Numerical Example

Generate vehicles for ten minutes if the flow rate is 120 vph.

Solution

The first two steps of this problem is same as the example problem solved earlier and the resulted from the table is used. For the first interval, the random number ($ X$) generated is 0.201 which is greater than $ p(0)$ but less than $ p(1)$. Hence, the number of vehicles generated in this interval is one ($ n_i=1$). Similarly, for the subsequent intervals. It can also be computed that at the end of 10th interval (one minute), total 23 vehicle are generated. Note: This amounts to 2.3 vehicles per minute which is higher than given flow rate. However, this discrepancy is because of the small number of intervals conducted. If this is continued for one hour, then this average will be about 1.78 and if continued for then this average will be close to 2.02.
Table 1: Vehicles generated using Poisson distribution
No X n
1 0.201 1
2 0.714 3
3 0.565 2
4 0.257 1
5 0.228 1
6 0.926 4
7 0.634 2
8 0.959 5
9 0.188 1
10 0.832 3
  Total 23

Random variates following Exponential distribution

One can generate random variate following negative exponential distribution rather simply due to availability of closed form solutions. The method for generating exponential variates is based on inverse transform sampling:
$\displaystyle t$ $\displaystyle =$ $\displaystyle f^{-1}(X)$  

has an exponential distribution, where $ f^{-1}$, called as quantile function, is defined as
$\displaystyle f^{-1}(X)$ $\displaystyle =$ $\displaystyle \frac{\log (1-X)}{\lambda}.$  

Note that if $ X$ is uniform, then $ 1-X$ is also uniform and $ \lambda=1/\mu$. Hence, one can generate exponential variates as follows:
$\displaystyle t$ $\displaystyle =$ $\displaystyle -\mu\times\log(X)$  

where, $ X$ is a random number between 0 and 1, $ \mu$ is the mean headway, and the resultant headways generated ($ t$) will follow exponential distribution.

Numerical Example

Simulate the headways for 10 vehicles if the flow rate is 120 vph.

Solution

Since the given flow rate is 120 vph, then the mean headway ($ \mu$) is 30 seconds. Generate a random number between 0 and 1 and let this be 0.62. Hence, by the above equation, $ t=30\times(-\log(0.62))=14.57$. Similarly, headways can be generated. The table below given the generation of 15 vehicles and it takes little over 10 minutes. In other words, the table below gives the vehicles generated for 10 minutes. Note: The mean headway obtained from this 15 headways is about 43 seconds; much higher than the given value of 30 seconds. Of, course this is due to the lower sample size. For example, if the generation is continued to 100 vehicles, then the mean would be about 35 seconds, and if continued till 1000 vehicles, then the mean would be about 30.8 seconds.
Table 2: Headways generated using Exponential distribution
No $ X$ $ t$ $ \sum~t$
1 0.62 14.57 14.57
2 0.17 53.70 68.27
3 0.27 39.14 107.41
4 0.01 157.36 264.77
5 0.26 40.01 304.78
6 0.47 22.72 327.5
7 0.96 1.38 328.88
8 0.24 42.76 371.64
9 0.59 15.94 387.58
10 0.45 24.05 411.63
11 0.26 40.82 452.45
12 0.11 67.39 519.84
13 0.10 69.33 589.17
14 0.73 9.63 598.8
15 0.31 34.74 633.54

Evaluation of the mathematical distribution

The mathematical distribution such as negative exponential distribution, normal distribution, etc needs to be evaluated to see how best these distributions fits the observed data. It can be evaluated by comparing some aggregate statistics as discussed below.

Mean and Standard deviation

One of the easiest ways to compute the mean and standard deviation of the observed data and compare with mean and standard deviation obtained from the computed frequencies. If $ p_i^c$ is the computed probability of the headway is the $ i^{th}$ interval, and $ N$ is the total number of observations, then the computed frequency of the $ i^{th}$ interval is given as:
$\displaystyle f_i^c$ $\displaystyle =$ $\displaystyle p_i^c\times N.$  

Then the mean of the computed frequencies ($ \mu^c$) is obtained as
$\displaystyle \mu^c$ $\displaystyle =$ $\displaystyle \frac{\Sigma f_i^c\times(\frac{2h_i+\delta h}{2})}{N},$  

where $ h_i$ is the lower limit of the $ i^{th}$ interval, and $ \delta h$ is the interval range. The standard deviation $ \sigma^c$ can be obtained by
$\displaystyle \sigma^c$ $\displaystyle =$ $\displaystyle \frac{\Sigma(h_i^m - \mu^c)^2 f_i^c}{N}.$  

If the distribution fit closely, then the mean and the standard deviation of the observed and fitted data will match. However, it is possible, that two sample can have similar mean and standard deviation, but, may differ widely in the individual interval. Hence, this can be considered as a quick test for the comparison purposes. For better comparison, Chi-square test which gives a better description of the suitability of the distribution may be used.

Chi-square test

The Chi-square value ($ X^2$) can be computed using the following formula:
$\displaystyle X^2_C$ $\displaystyle =$ $\displaystyle \sum_{i=1}^{n}\frac{(f_i^o-f_i^c)^2}{f_i^c}$  

where $ f_i^o$ is the observed frequency, $ f_i^c$ is the computed (theoretical) frequency of the $ i^{th}$ interval, and $ n$ is the number of intervals. Obviously, a $ X^2$ value close to zero implies a good fit of the data, while, high $ X^2$ value indicate poor fit. For an objective comparison Chi-square tables are used. A chi-square table gives $ X^2$ values for various degree of freedom. The degree of freedom (DOF) is given as
$\displaystyle DOF$ $\displaystyle =$ $\displaystyle n-1-p$  

where n is the number of intervals, and p is the number of parameter defining the distribution. Since negative exponential distribution is defined by mean headway alone, the value of p is one, where as Pearson and Normal distribution has the value of p as two, since they are defined by $ \mu$ and $ \sigma$. Chi-square value is obtained from various significant levels. For example, a significance level of 0.05 implies that the likelihood that the observed frequencies following the theoretical distribution is is 5%. In other words, one could say with 95% confidence that the observed data follows the theoretical distribution under testing.