# Average passanger waiting time - probability density function - normal distribution

#### Patman

##### New Member
Hello guys,
so we got this additional task to solve for a post-modul at university:

- The intermediate arrival time of a bus is normal distributed
- The expected value of the intermediate arrival time during rush hour is 4 minutes
- The standard deviation of the intermediate arrival time is 50 sec (50/60min)

A passanger enters the bus stop at a random time (statistically evenly distributed). What will be his waiting time for the next bus.
1. How does the distribution (probability density function) for the passangers waiting time look like?
2. What is the expected average waiting time of the passanger?
3. Define the standard deviation of the passangers waiting time?
4. Define the probability that the passanger has to wait more than 5 Minutes during rush hour?

I could find a lot of example while googling for the probability densitiy function of bus arrival times. But nothing for the passanger and nothing with normal distribution. Our professor mentioned something about forward recurrence time, but I couldn't find anything about that.
Hope someone can help me out here or at least show me a way of solving it.
And please tell me if something isn't understandable, just translated this task from my mother language.

#### fed2

##### Active Member
i think equation 4from
http://www.columbia.edu/~ks20/stochastic-I/stochastic-I-RRT.pdf
gives the waiting times. here is an r simulation verifying

C-like:
waitTime = function(t){
min(  arrivalTimes[ arrivalTimes > t ]  ) - t
}

runOne = function(i){
Y = rnorm(  1000, 4, 50/60   )
arrivalTimes = cumsum( Y )
t = runif(1, 50,300)
waitTime(t)
}
times = as.vector( unlist(  lapply( 1:8000, runOne )  ) )

mypnorm = function(x){ 1 - pnorm(x,4,50/60) }
eq4 = function(x){
integrate( mypnorm, 0, x  )$value/4 } quantile(times) eq4(9.946654e-01) #good enough for government work #### Patman ##### New Member i think equation 4from http://www.columbia.edu/~ks20/stochastic-I/stochastic-I-RRT.pdf gives the waiting times. here is an r simulation verifying C-like: waitTime = function(t){ min( arrivalTimes[ arrivalTimes > t ] ) - t } runOne = function(i){ Y = rnorm( 1000, 4, 50/60 ) arrivalTimes = cumsum( Y ) t = runif(1, 50,300) waitTime(t) } times = as.vector( unlist( lapply( 1:8000, runOne ) ) ) mypnorm = function(x){ 1 - pnorm(x,4,50/60) } eq4 = function(x){ integrate( mypnorm, 0, x )$value/4
}
quantile(times)
eq4(9.946654e-01) #good enough for government work
Amazing. Thx a lot. Stragely I can't run the code in R. The 3rd code junk "times =as.vector..." gives me an error that the object "arrivalTimes" could not be found.

#### fed2

##### Active Member
oh i see, need to pass arrivalTimes.

C-like:
waitTime = function(t, arrivalTimes ){
min(  arrivalTimes[ arrivalTimes > t ]  ) - t

}

runOne = function(i){
Y = rnorm(  1000, 4, 50/60   )
arrivalTimes = cumsum( Y )
t = runif(1, 50,300)
waitTime(t, arrivalTimes)
}

times = as.vector( unlist(  lapply( 1:8000, runOne )  ) )

mypnorm = function(x){ 1 - pnorm(x,4,50/60) }

eq4 = function(x){
integrate( mypnorm, 0, x  )\$value/4

}

quantile(times)

eq4(9.946654e-01)