# Probability Calculations on Highway

I read this Google Interview Question.

Q:If the probability of observing a car in 30 minutes on a highway is 0.95, what is the probability of observing a car in 10 minutes (assuming constant default probability)?

A:The trick here is that .95 is the probability for 1 or more cars, not the probability of seeing just one car. The prob. of NO cars in 30 minutes is 0.05, so the prob of no cars in 10 minutes is the cube root of that, so the prob of seeing a car in 10 minutes is one minus that, or ~63%

My question is, if The probability of NO cars in 30 minutes is 0.05, why the probability of no cars in 10 minutes is the cube root of that ??

Which algorithm used in this question?

## 5 Answers

The unstated (or, rather, very vaguely stated) assumption in the problem is that the probabilities of observing a car during any given non-overlapping time intervals of equal length are equal and independent.

(Of course, this assumption can't really be true in practice, even if "observing a car" is taken to be a point event — for example, if the road has $n$ lanes and you observe a different car within each of $n$ consecutive 1 millisecond intervals, you're not going to observe another one within the next millisecond — but it can be a fairly good approximation if the intervals are of moderate length and the road not very busy.)

This assumption (almost; see comments) implies that the arrival of cars is (assumed to be) a Poisson process. More specifically, it implies that the probability of no cars arriving within any given 10 minute interval is the same. Since we know that the probability of no cars arriving within a 30 minute interval equals the product of the probabilities of no cars arriving in each of the three consecutive 10 minute intervals within it, the answer follows.

To be specific, let $A$, $B$ and $C$ denote the events "no cars are observed within the first / second / third 10 minutes" respectively. Then we have

$$\mathrm{Pr}[A \text{ and } B \text{ and } C] = \mathrm{Pr}[A] \cdot \mathrm{Pr}[B \text{ if } A] \cdot \mathrm{Pr}[C \text{ if } A \text{ and } B].$$

Since the events $A$, $B$ and $C$ are independent by assumption, we get

$$\mathrm{Pr}[A \text{ and } B \text{ and } C] = \mathrm{Pr}[A] \cdot \mathrm{Pr}[B] \cdot \mathrm{Pr}[C],$$

and, since by assumption $\mathrm{Pr}[A] = \mathrm{Pr}[B] = \mathrm{Pr}[C]$,

$$\mathrm{Pr}[A \text{ and } B \text{ and } C] = \mathrm{Pr}[A]^3.$$

We know that $\mathrm{Pr}[A \text{ and } B \text{ and } C] = 0.05$, and we want to solve for $\mathrm{Pr}[A]$ (which, by assumption, equals the a priori probability of observing no cars within any given 10 minute interval), so we take the cube root of both sides and get

$$\mathrm{Pr}[A] = \sqrt[3]{\mathrm{Pr}[A \text{ and } B \text{ and } C]} = \sqrt[3]{0.05} \approx 0.3684.$$

Subtract that from one to get $\mathrm{Pr}[\text{not } A] \approx 0.6316$.

• After posting this, I happened to come across a remark elsewhere saying that the assumption I gave may not actually be strong enough to imply that the process is Poisson; apparently there are "quasi-Poisson" processes which have independent Poisson distributed event counts over disjoint intervals, with mean proportional to the interval length, but which are not actually Poisson processes. In any case, this shouldn't affect the rest of the answer, for which the weaker assumption is sufficient. – Ilmari Karonen Jul 18 '11 at 14:13
• Just to be sure, I edited the assumption to make sure it actually implies exactly the conditions I need (independence and equality). – Ilmari Karonen Jul 18 '11 at 14:25
• The unstated (or, rather, very vaguely stated) assumption in the problem is that the probabilities of observing a car during any given non-overlapping time intervals of equal length are equal ... - I guess that statement implies the Uniform distribution more appropriately than the Poisson distribution. – kaartic Apr 15 '17 at 5:37
• As per the assumption, probabilities of observing a car during any given non-overlapping time intervals of equal length are equal and independent. Then, Why isn't the probability of seeing a car in an 30 minute interval equal to the product of the probabilities of seeing a car in the first, second and third 10 minute intervals? – kaartic Apr 15 '17 at 5:54
• @kaartic: The probability of not seeing a car in any of the 10 min intervals (and, thus, the probability of not seeing one in the entire 30 min interval) is equal to the probability of not seeing a car in the first 10 min interval, times the probability of not seeing one in the second interval, times that of not seeing one in the third interval. This holds because the event "not seeing a car in any of the 10 min intervals" is the intersection of the events "not seeing a car in the $n$-th 10 min interval" for $n\in\{1,2,3\}$ and because, by assumption, the latter events are independent. – Ilmari Karonen Oct 15 '17 at 9:17

The question seems rather ambiguous, but let's assume cars arrive as a Poisson process rate $\lambda$. If this is the case, the distribution of the time (from now) to the first arrival of the car is exponential with parameter $\lambda$. Therefore probability of no cars arriving is $P(T>t) = exp(-\lambda t)$. Thus

$P(T>10min) = \exp(-\lambda \times 10) = \exp(-\lambda*30/3) = \exp(-\lambda*30))^{\frac{1}{3}} = \sqrt[3]{P(T>30min)}$

Alternatively you could approximate by a binomial model. Suppose in 10 minutes the chance of no car arriving is $p$. Then in thirty minutes (assuming each period is independent) the probability of no cars passing is $p^3$. Whence, $p=\sqrt[3]{0.05}$.

Let's say that the probability of no cars in 30 minutes can be decomposed as (you assume constant probability)

P10 = probability of no cars in 10 minutes

P30 = P10 * P10 * P10 = P10^3 = 0.05

Thus P10 = cuberoot(0.05)

• Note that this was possible only because of the constant assumption over probability. – Mauro Jul 18 '11 at 8:36
• I already asking why P30 =P10^3 .. – Soner Gönül Jul 18 '11 at 8:46
• @Soner, because probability of (A and B) equals (probability of A) times (probability of B), provided A and B are independent events - and the hidden-but-plausible assumption is that what happens in any one 10-minute interval is independent of what happens in any other (non-overlapping) 10-minute interval. – Gerry Myerson Jul 18 '11 at 12:37

For curiosity, I saw other solutions and found that everyone is solving via probability of not observing a car in 10 minutes.

Let's answer it in a straight way.

Assumption: Considering Probability of observing a car in any given non-overlapping time interval of equal length are equal and independent. Reason: Question clearly states "assuming constant default probability"

Let 'p' be the probability of observing a car in any 10 minutes interval.

Now let's generate the probability of observing a car in 30 minutes, let it be P(30).

Let's divide 30 minutes time interval into three 10 minutes intervals as A, B and C.

P(A) = Probability of seeing a car in first 10 minutes
P(B) = Probability of seeing a car in second 10 minutes
P(C) = Probability of seeing a car in third 10 minutes


As all are independent events so,

P(A) = P(B) = P(C) = p


Similarly,

P(not A) = Probability of not seeing a car in first 10 minutes
P(not B) = Probability of not seeing a car in second 10 minutes
P(not C) = Probability of not seeing a car in third 10 minutes


As all are independent events so,

P(not A) = P(not B) = P(not C) = 1-p


Then,

P(30) = P(A) + P(not A)*P(B) + P(not A)*P(not B)*P(C)


It can be seen in this way:

Consider an event, We are tossing a coin 3 times a row and we want to find what is the Probability of getting at least 1 head.

P(getting at least 1 head) = P(getting head in 1st toss) + P(getting head in 2nd toss given in 1st toss we got tail) + P(getting head in 3rd toss, given in 1st and 2nd toss we got a tail)
P(getting at least 1 head) = 1/2 + 1/2*1/2 + 1/2*1/2*1/2 = 7/8


Similarly,

P(30) = p + (1-p)*p + (1-p)*(1-p)*p
=> 0.95 = p + p - p^2 + p + p^3 - 2p^2
=> 0.95 = p^3 - 3p^2 + 3p
=> 1-0.95 = 1 - p^3 + 3p^2 - 3p
=> 0.05 = (1-p)^3
=> p = 1 - (0.05)^(1/3)
=> p ~= 0.6316


P(probability of observing a car in 10 minutes) = 0.6316

Assuming a Poisson Distribution, we know that the probability mass function is:

$$\text{P}(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}$$

The probability that no cars pass in thirty minutes is $$1 - 0.95 = 0.05$$: $$\text{P}(X=0) = 0.05 = \frac{\lambda^0 e^{-\lambda}}{0!} = e^{-\lambda}$$

We can solve for lamda by taking the log of both sides: $$-\text{ln}(0.05) = \lambda$$

$$\lambda = 2.995 \approx 3$$

(To answer the OP's question, this is where the cube root comes from, because the $$ln$$ is the inverse of $$e$$ and gives us the exponential value.)

There are three cars every thirty minutes, which is $$0.1$$ every minute. So, we multiply that by 10 minutes and get $$\lambda=1$$ for units of 10 minutes.

Then we calculate the probability for exactly 0 cars in 10 minutes: $$\text{P}(X=0) = \frac{\lambda^0 e^{-1}}{0!} = 0.368$$

Then, to find the probability of at least one car, we just subtract that from one:

$$\text{P}(X>0) = 1 - 0.368 = 0.632$$

The probabilities (p) for the given number of cars (k) in the 10 minute interval looks like this: