# CDF and PDF of semaphore waiting time

Imagine we have a semaphore that alternates every 40 seconds between green and red.

Waiting time is 0 when the semaphore is green, and when it is red it is the remaining time until it turns green.

I want to model the distribution of waiting times on this semaphore.

Starting with the CDF I have:

$$F(x) = \begin{cases} 0 && \text{if } x < 0\\ 0.5 && \text{if } x = 0 && \textit{half the time we don't need to wait}\\ 0.5 + \frac{0.5}{40} x && \text{if } x > 0 \text{ and } x<=40 && \textit{all waiting times ]0-40] are equally likely}\\ 1 && \text{if } x > 40 \end{cases}$$

Is the PDF of this distribution given by the following function?

$$PDF(x) = \begin{cases} 0 && \text{if } x < 0\\ 0.5 && \text{if } x = 0\\ \frac{0.5}{40} && \text{if } x > 0 \text{ and } x<=40\\ 0 && \text{if } x > 40 \end{cases}$$

And is the expected time waiting on this semaphore given by:

\begin{align*} \int_0^{40} x f(x) dx = \int_0^{40} x . \frac{0.5}{40} dx = 10 \end{align*}

• This distribution does not have a density at $x=0$, but instead a point probability $\mathbb{P}(X=0)=0.5$. Though this does not affect the expectation when you add $0\times 0.5$, it would have had an impact if the point probability was somewhere else. – Henry Feb 23 '16 at 18:44
• What if it was at some other point, let's say $x=100$? How would I calculate the expected value in that case? Would I do 10 +0.5*100 = 60? – JC1 Feb 23 '16 at 21:19
• Yes: for point probabilities you just do the usual $\sum_i x_i \mathbb{P}(X=x_i)$ as you would for a discrete distribution. The integral is the absolutely continuous version of this sum, so when you have a mixture of the two you do both. You could check the total probability is $1$ with $\sum_i \mathbb{P}(X=x_i) + \int f(x)\, dx$ so that you do not miss something. – Henry Feb 23 '16 at 22:06

This distribution's density is not defined at $x=0$, but instead we have a point probability $P(X=0) = 0.5$.