Goldman Sachs Interview Question
Software Engineer / DevelopersLet me try to prove it mathematically:
let's assume the position of the first point is y (0<=y<=1). So the probability dense function of the distance to the second point is:
f(x) = 2, o<=x<=y
f(x) = 1, a<x<=1-y
therefore, we can get the expectation as: definite integral (x*f(x))dx from 0 to 1, and get E(x) = y*y-y+1/2 (here y is a parameter).
Now we need to compute the expectation of E(x) given all the possible values of y.
Then according to the Central limit theorem, we can calculate the expectation as: definite integral (y*y-y+1/2)dy from 0 to 1 (here y is a variable), and get result as 1/3.
Not sure if this is a correct proof.
Let a and b be random, uniformly distributed variables such that 0<=a<=1 and 0<=b<=1. These are our two points on the line. We can say that the expected distance between the two points is the expected probability that a third, randomly distributed point, c, 0<=c<=1 lies between a and b. c is no different from a and b so the odds that c lies between a and b is 1/3.
distance 'd' will be between 0 < d < 1
- Anonymous February 23, 2010