top | item 39200485

(no title)

dmillar | 2 years ago

Early in my career, when I first started interviewing, I used to ask a version of this to recent grads. It was never a make-or-break question, but I found it to be a great way to a.) see how people approach problem solving and probability and b.) see how they respond when you start asking whys (even if they answered/guessed 1/3). It's something that takes zero code to answer, and the intuition is easy to grok once explained.

The other part I particularly enjoyed was the people who initially guessed wrong, but then got to the answer intuitively almost always sent me code proving the answer.

For the record, my question was: "Two points are randomly and uniformly selected on a line 0.0 to 1.0. What is the most probable distance between the two points?"

discuss

order

kilotaras|2 years ago

  > what is the most probable distance between the two points?
  > even if they answered/guessed 1/3
1/3 is not the most probable distance, it's the expected value. The most probable distance does not exist, but PDF(d) is strictly decreasing for (d>0).

dmillar|2 years ago

You're right. Thinking back, I think I asked "what's the average distance" not "what's most probable".

LatticeAnimal|2 years ago

> Two points are randomly and uniformly selected on a line 0.0 to 1.0. What is the most probable distance between the two points?

Unless I am reading this wrong, I think all values between 0 and 1 have an equal probability (of 0).

The probability that a random uniform variable will equal any number between 0 and 1 is zero. It seems to follow that the probability of the difference between two uniform variables equaling any exact value would also be 0.

Have I missed something obvious? If zero really is the correct answer, that is pretty tricky.

dmillar|2 years ago

You have two random uniform variables and the distance/difference/change between to finite points.

Put another way (and code it up if you want). Select two random uniformly distributed points between 0 and 1. Do this 10_000 times, whats the average distance between the two?

This gets to the question of "most probable" vs "expected value". A conversation I always welcomed.