# Find the expectation from probability

1. Oct 22, 2017

### jaus tail

1. The problem statement, all variables and given/known data
Assume that in a traffic junction, the cycle of the traffic signal lights is 2 minutes of green
(vehicle does not stop) and 3 minutes of red (vehicle stops). Consider that the arrival time of
vehicles at the junction is uniformly distributed over 5 minute cycle. The expected waiting
time (in minutes) for the vehicle at the junction is __________.

2. Relevant equations
E(x) = summation of (x) * P(x) over all values of x

3. The attempt at a solution

Adding them all I get answer for expected value as 1 / 25 * (6 + 6 + 6 + 5 + 3 ) = 26/25

How do I solve this?

#### Attached Files:

File size:
194.9 KB
Views:
32
2. Oct 22, 2017

### Staff: Mentor

You can't make a discrete version out of it like you did. What happens to cars that arrive in between?
The probability that a car has to wait 3 minutes is not 1/5, it is 0, because you would have to arrive "exactly" when the traffic lights get red.
That seems to imply the car has to wait even when it arrives at a green light?

3. Oct 22, 2017

### jaus tail

Cars in between? I'll have to take a small intervals. Like 0 to 0.5 and then move on? Yeah the 26/25 bothered me as well. I don't know how book gets 0.9.

But even with 1 minute interval, at least my answer should be a good approximate to 0.9. Currently I get 26/25. I don't know where is the mistake? Discrete should give me some close approximate value depending on step size.

4. Oct 22, 2017

### Ray Vickson

With probability 2/5 the car arrives in the 2-minute green-light period, so P(no wait) = 2/5. With probability 3/5 the car arrives somewhere in the 3-minute red-light period; the actual time of arrival in that 3-minute period is uniformly distributed over an interval of length 3, so the wait-time is uniformly distributed over the interval from 0 to 3. What is the mean of a uniformly-distributed quantity that can range from 0 to 3? Even if you have not had calculus yet, the answer is "intuitive" and goes along with common sense.

Now you just need to combine the two averages and their probabilities in an appropriate way.

Alternatively, you can assume that the car can arrive at any of N equally-spaced points in the interval from 0 to 5, but taking N = 5 is too small. Why? Well, suppose the first two minutes have a green light and the remaining 3 minutes have a red light. The car can arrive at any time from 0 to 5, but we approximate this by using equally-spaced discrete points, each being equally-likely. The problem is that 1 microsecond before t = 2 the light is green and so the car does not wait; 1 microsecond after t=2 the light is red and the car waits for 3 minutes. How should we characterize the point t = 2 exactly? If we just use the five points 1,2,3,4,5 or the 6 points 0,1,2,3,4,5, the single point t=2 can have a significant effect on the calculated answer. We need more points, so that the single point t = 2 does not affect the answer very much. So, doing the calculation where the arrival points are spaced apart by 30 seconds would give us an answer that is closer to the true value; having them spaced 15 seconds apart would be even better. A more accurate answer would be obtained by spacing the points closer together and increasing their number. Just make a table of the N equally-likely wait-time values {wait(1), wait(2), ... wait(N)}, then take their expectation; this is quite easy using a spreadsheet, for example. (Note that many of the wait-times in your table would be 0, and the others would range from near 0 to near 3.)

The true answer 0.9 would be obtained by having infinitely many points spaced 0 apart, which is the continuous situation, but using a large enough N should work well enough for practical purposes. Putting it all in a spreadsheet would be the easiest way to go.

Last edited: Oct 22, 2017
5. Oct 22, 2017

### Staff: Mentor

26/25=1.04 is not too far away from 0.9. See the previous post for two methods to get the exact result (0.9 is correct).

6. Oct 23, 2017

### jaus tail

This is genius. Thanks for this. 2/5 * 1.5 = 0.9.
But why did you take 2/5?
In 5 minute cycle there would be infinite cases of
Red for 3 minutes + green for 2 minutes
OR
green for 1 minute + red for 3 minutes + green for 1 minute
OR
Red for 2.5 minutes + green for 2 minutes + red for 0.5 minute

so wouldn't we have to add all the above Probability to get a P(car stops) which we multiply with 1.5

The book has given something like integration in its answer which I don't understand.

#### Attached Files:

File size:
118.1 KB
Views:
32
7. Oct 23, 2017

### Staff: Mentor

Huh?
A car can arrive anywhere within a 5 minute cycle. Within 2 of the 5 minutes it will encounter a green light and don't wait at all. Within the other three minutes it encounters a red light.

8. Oct 23, 2017

### Ray Vickson

You ask: why did you take 2/5? I did not--you did. Besides, (2/5)(1.5) ≠ 0.9.

9. Oct 23, 2017

### Ray Vickson

Integration is the limit of summation as the number of terms goes to infinity, while the size of each term goes to zero. Basically, just do what I said in #4, and split up the 5-minute interval into N equal parts, then tally up the waiting times for the N different arrival times that you get. Then take the N-term average. For larger and larger N you get a better and better estimate of the true answer. As I said before, if you let N go to infinity, the sum becomes some limiting value---and that limit is what we call the integral. The true answer is, indeed, given by an integral (in one way of doing it, anyway).

However, your method above is on the right track: see what you get when you multiply 1.5 by P(stop). Then see if you can understand why it works! Your textbook must have some material on this topic.

10. Oct 28, 2017

### jaus tail

Yeah it's 3/5 * 1.5 = 0.9
Textbook has a few paras on probability density function. I don't know which value to integrate. They've done this:

I don't know why f(x) is 1/5
And why is limits 0 to 5 broken as: 0 to 2 and 2 to 5
The limits can also be: 0 to 1 and 3 to 5

11. Oct 28, 2017

### haruspex

The general form of the average of one function h weighted according to another, k, is ∫hk/∫k. In a simple average over time that becomes ∫h(t).dt/∫.dt = ∫h.dt/Δt.
In the present case Δt=5.
Do you mean 0 to 3 and 3 to 5? Sure, but that just swaps the two integrals over. The result is the same. You can choose to start the 5 second period wherever you like within the cycle.

12. Oct 28, 2017

### jaus tail

I didn't understand the limits part.
When I meant 0 to 1 and 3 to 5
I meant that
signal is red from 0 to 1 and then from 3 to 5.
In the book why have they taken g(x) as 0 from 0 to 2 and not from 1 to 3.
I mean how are they sure that for the time interval of 5 minutes, we have the first 2 minutes as green and next 3 as red.
We can also have:
first 3 minutes as red and next 2 minutes as green.
There can be infinite variations.

Is there some definition of delta t that it becomes 5?

13. Oct 28, 2017

### jaus tail

Ok so X is the time when car comes and there is 1 car in five minutes so d(x)/d(t) = 1/5

14. Oct 28, 2017

### haruspex

Ok, you mean 0 to 1, 2 to 3 and 3 to 5, but with the 2 to 3 integral producing zero. You could also break it into five integrals of one second each.
As you say, infinitely many options, but all producing the same result.

15. Oct 28, 2017

### jaus tail

So if it's infinite options then shouldn't answer be addition of all results.
like P (A or B or ....) = P(only A) + P(only B) +....

16. Oct 28, 2017

### haruspex

Sort of, yes. In that view, dx/dt is the probability density function, f(t). As required of such a function ∫f.dt=1, and since it is uniform we have f=1/5.

17. Oct 28, 2017

### haruspex

Sure, but it is a continuous distribution, so you have to use integrals rather than sums.

18. Oct 28, 2017

### jaus tail

Does f(t) have some physical interpretation? Is it like number of cars arriving in one minute or something?
Thanks for the continuous help. The earlier method of 3/5 * 1.5 was so much simpler than integration.

19. Oct 28, 2017

### haruspex

A probability density function gives the relative likelihood of values in a vicinity. If we look at some range of possible values, (x,x+dx), of a random variable X, there is a probability P[x<X<x+dx] that X lies in that range. The probability density function f(x)=limdx→0(P[x<X<x+dx]/dx).
For a more physical view, it is like a mass density function, but in which the mass of the whole object is known to be 1.

20. Oct 28, 2017

### jaus tail

Thanks for the help.