Fog Creek Software
Discussion Board




cars on the road 

3/5 or 60%

Let Prob of observing a car in 5 minutes = x
Prob of not observing a car in 5 minutes = 1-x
Prob of not observing a car in 20 minutes =
            Prob of not oberving a car in first 5 minutes
        * Prob of not oberving a car in second  5 minutes
        * Prob of not oberving a car in third 5 minutes
        * Prob of not oberving a car in last 5 minutes
    = (1-x)^4

This is also equal to = 1 - 609/625 = 16/625

( 1 -x ) ^ 4 = 16/625

x = 3/5

Pankaj Gupta
Wednesday, May 22, 2002

Hi

I think, Gupta, your calculation method is wrong.

First: have you tried to 'test' if your answer is correct ?
Secod: I thing by multiplying 1-x for times you are calculating probability of not apearing car in ALL 5 min. intervals. The task is to find probability for ANY 5 min. inteval but not probability for ALL 5 min. intervals when car apears.  So i thing the solution is simpler:

Probability of apearing car in any 5 min. interval is p/4 where p = 609/625

If you want to get probability of apearing car in ALL 5 min. intervals then you have to do multiplication of all probalilities.

Paulius
Thursday, May 23, 2002

I do agree with Paulius.
For me the easiest calculation is:
609/2500  (which is 4 * 625, easy going...)

Pe Woerner
Thursday, May 23, 2002

No I think, pankaj's solution is flawless.

pr(seeing car in atleast one interval) = 1-pr(not seeing in ALL intervals)

vivek gupta
Thursday, May 23, 2002

1-pr(not seeing in ALL intervals) = pr(seeing cars in every 5.min interval). I think this is different from seeing car at one of 5 min. intevals in 20 min. period

Paulius
Thursday, May 23, 2002

If we go by your formula , then
pr(not seeing in ALL intervals) + pr(seeing cars in every 5.min interval)=1
which means you will either see a car in each of the intervals or you don't see car at all in any interval. Which is clearly not true because you miss the cases where you see car in some but not all intervals.

vivek gupta
Thursday, May 23, 2002

true...

shailesh kumar
Friday, May 24, 2002

P(see a car in 20 minutes) = 609/625
so P(don't see in 20 mins) = 16/625

I think we all agree on this. It means that in any 20 minute period, the prob. of not seeing any cars is 16/625. Let's call this P(no_car_20)

And P(no_car_5) = prob. of not seeing any cars in any 5-minute period.

If we take the 4th power of P(no_car_5), we get P(no_car_20).

(because any 20 minute period contains 4 CONSEQUTIVE 5-minute perioids, so the prob. that you don't see a car in 20 minutes is equal to the prob. of not seeing one in 5 minutes, multiplied by itself 4 times).

So P(no_car_5) = 4th root of (16/625)
= (4th root of 16) / (4th root of 625)
= (2 / 5)
= 0.4

(Funny how all the numbers work out nicely eh?)

Or you can work it out like this:

P(don't see in 1 minute) =  20th root of (16/625)

so P(don't see one in 5 minutes) = (20th root of 16/625)^5

Which, using a calculator, gives 0.4 again

Adrian Gilby
Friday, May 24, 2002

Damn. Forgot to say ... so Pankaj is right.

Adrian Gilby
Friday, May 24, 2002

Ok, let's modify probability of apearing car in 20 min. period and let it be equal to 1. Now by calculating probability using method i proposed we are getting 1/4, by calculating probability using method Gupta probosed we are getting 1.
Interpretations are welcome ? :)

Paulius
Friday, May 24, 2002

Yup, and Pankaj and Vivek are correct. Look at it like this -- if you're absolutely guaranteed to see a car in _any_ 20 minute period, then you must be seeing a car _constantly_.

So if prob(see_car_in_20_minutes) == 1
then
prob(see_car_in_any_arbitrary_time_period) == 1

Adrian

Adrian Gilby
Friday, May 24, 2002

Paulius,

I think you are reading the question as saying there's one car and its talking about the probability of seeing *the* car.

Most of the other posters are looking at the question in a different way. Specifically that in any given time period you can see 0 cars go past, 1 car go past, 2 cars go past, 3 cars go past, and so on. Seeing "a car" go past counts as any of these cases except the 0-car one.

With that assumption, if the probability of seeing a car in 20 minutes is 1, there is *never* a moment when a car is not visible. Because if there was, sooner or later the random distribution would give you 20 minutes-worth of such moments in a row and p(see car in 20 minutes) would therefore be less than 1. Therefore in every 5 minute interval (or 1 second interval or 1 microsecond interval) there is a car visible with probability 1.

A.T.
Friday, May 24, 2002

Probability c = 609/625 we can treat like we did first 625 observations and found that 609 observations were successfull (car appeared in 20 min. period). How many observations we can do in 5 min. intervals during same time ? I think 2500 while cars were comming same way.
The more observations we do the near our result will get to c. If we want to get c we have to do infinit number of observations.

Paulius
Friday, May 24, 2002


the solution hinges on the assumption that the probability of seeing a car is the same in *every* 5 minute interval.  pankaj's solution is perfect.

Vin
Friday, May 24, 2002

I just stumbled across this forum and I though I'd mention another way to solve this problem, one that incidentally doesn't rely on the numbers being so judiciously chosen (but on the other hand does require a calculator.)

This approach involves modelling the arrival of cars as a Poisson process. For a discussion of a Poisson process, see, e.g., http://www.math.uah.edu/stat/poisson/. The given quantity is the probability that we see at least one car in 20 minutes. In the language and formulas of the Poisson process this is P(N_20 >= 1) = 1 - e^(-r*20) = 609/625, where r is the unknown arrival rate parameter. Solving for r gives r = 0.18326. Now all we need to determine is P(N_5 >= 1), which is the same formula with 5 substituted for 20, and works out to 0.6.

Paulias made the observation that as we let the probability of seeing one car in 20 minutes go to 1, the probability of seeing a car in 5 minutes also goes to one. Using the Poisson formulas, you can see that as P_20 goes to 1, r, the arrival rate, goes to infinity. You may think of this case as an infinite number of cars arriving over any time interval when P_20 = 1 (though strictly speaking the model simply breaks down, as log(0) is undefined.)

Carter Shanklin
Monday, June 03, 2002

Pankaj's explanation of how he arrives at the solution is, in my opinion, the most direct --and therefore the most simple-to-understand.  Good job :)

Jim Tran
Tuesday, June 04, 2002

just wanted to point out that the main reason that
the first answer is correct is that the numbers in
the question are all nice members of the "power of
four department", which is how youre hinted
towards the answer in the first place..

Cheradenine Zakalwe
Wednesday, June 05, 2002

Pankaj is correct.  Sometimes.

The grammer of the question allows two interpretations:

"The probability of observing a car in 20 minutes on a highway is 609/625."

Can mean (grammarically):

'The probability of seeing one and only one car in 20 minutes on a highway is 609/625.'

Or

'The probability of seeing at least one car in 20 minutes on a highway is 609/625.'

Pankaj, has, of course, solved the second one.

The other answer is 4*(x*(1-x)^3) = 609/625

Which, if you look carefully, is a power 4 equation.

One with only imaginary roots.

So the answer is either 60%.  Or about +/- 41% or 57% when time is imaginary.

Which may explain why I have no job and Pankaj is probably someplace rather posh.

(Anybody need something programmed?)

J. Martin
Thursday, June 06, 2002

The 5-minute analogue of the statement 'The probability is 609/625 of seeing one and only one car in 20 minutes' is 'The probability is x of seeing one and only one car in 5 minutes.'

But J. Martin's equation, '4*x*(1-x)^3 = 609/625' is NOT equivalent to 'The probability is 609/625 of seeing exactly one car in 5 minutes.'

The equation '4*x*(1-x)^3 = 609/625' is equivalent to 'The probability is 609/625 of seeing exactly one car in 5 minutes and none for the following 15 minutes, or no cars for five minutes and exactly one car in the next five minutes and no cars for the following ten minutes, or no cars for ten minutes and exactly one car in the next 5 minutes and no cars in following 5 minutes, or no cars for fifteen minutes and exactly one car in the next 5 minutes'.

To find the probability of seeing exactly one car in 5 minutes, given the probability of seeing exactly one car in 20 minutes, we'd need to know the probability distribution. The Poisson process is a good way to model this kind of problem, but doesn't work here because no Poisson distribution can give a probability of 609/625.

rob mayoff
Friday, June 14, 2002

(Note to anybody not reading the full discussion:  I agree with Pankaj.  This a tangent to some degree.  Please read my post above.)

"But J. Martin's equation, '4*x*(1-x)^3 = 609/625' is NOT equivalent to 'The probability is 609/625 of seeing exactly one car in 5 minutes.'" --Rob Mayoff

Correct.  But I fail to see where I had claimed that.  The probability of seeing exactly one car in 5 minutes is x in my equation.  Not 609/625. 

" To find the probability of seeing exactly one car in 5 minutes, given the probability of seeing exactly one car in 20 minutes, we'd need to know the probability distribution."  --Rob Mayoff

We were given this additional information: "assuming constant default probability".

***You can skip this paragraph***
To get mathematical here, I take that to mean that P(t) = c, where P is the probability of the event at time t, and c is constant.  The probability of P over 20 minutes is the integral from t0 to t0 + 20 of P(t).
***You can skip the above paragraph***

Of course there is no solution using Poisson to the problem of exactly one and only one car in twenty minutes. 

It is because the 20 minute probablity of 609/625 is too high.  The highest that probability could have been to still give an answer is 42%, which would give an x value of 25%.  If x increases or decreases from 25%, the final probability of seeing one and only one car in 20 minutes decreases from 42%.  It will never reach 609/625.

You get that from the expression 4*x*(1-x)^3.

Think of Poisson distributions as a big club.  When you run across a problem, try to use your mind to solve the problem first.  It is far more elegant.  I try to avoid Poisson except in cases where I am dead drunk, or dead tired.  Usually both.

J. Martin
Friday, June 14, 2002

I'm no mathematician, but I really don't get Andrian's idea that if the probability of seeing a car in any 20 minute time period is 1, then the probability of seeing a car in any 5 minute time period is also 1.

Consider a highway alongside the U.S. - Mexican border. A U.S. border patrol car patrols the highway every eight minutes.

Does not compute.

Marko
Tuesday, June 18, 2002

Poisson is to probability what the straight line is to calculus.    It should be the first tool you turn to for a quick and dirty calculation.  It is not "something to avoid because it is too complicated" 

Just because you do some arithmetic on probabilities given does not mean you can feel confident of the right answer.  You must state some assumption that gives you the license, so to speak, to perform the given calclations.

The problem leaves so much unstated that you should assume the simplest possible model in this context, which is the Poisson process.

MFT
Tuesday, June 18, 2002

So basically, no need to ask this question in an interview!

Muhammad Omer Iqbal
Tuesday, June 18, 2002

p =3/5 is the correct answer.

Here is how to verify it:

Let p(x) be the probability of seeing a car in X min.

p(2x) = 2p(x) - p(x)^2 (probability of seeing a car in both intervals of X - probability of seeing 2 cars during 2 intervals of X)

p(20) = 2p(10) - p(10)^2
p(10) = 2p(5) - p(5)^2 = 2*3/5 - (3/5)^2 = 21/25
p(20) = 2*21/25 - (21/25)^2 = 609/625

Dmitriy Furer
Monday, June 24, 2002

Paulius is wrong. The probability of seeing a car in 5 minutes is NOT p/4 (where p=probability of seeing a car in 20 minutes). If that was correct, then you could also argue that the probability of seeing a car in 40 minutes would be.. what, p*2 ? That would be p >=1 which as we all know is impossible.

Pankaj's reply is perfect.

Guillermo Rodriguez
Wednesday, July 03, 2002

*  Recent Topics

*  Fog Creek Home