Right at least once with high probability

Menu

Category Archives: Tricks

A while ago I came across this problem from Stanford’s Putnam seminar:

Two points are independently selected uniformly at random from a line of length . What is the probability that they are at least a distance apart, where ? (Putnam 1961 B2)

This problem has a very neat solution which exploits what I find to be a rather clever technique. We put the line on a coordinate system and say it runs from to . Let be the coordinate of the first point and be the coordinate of the second, where and are random variables which are clearly uniformly distributed. Now draw the unit square, as in the following diagram [1]:

The shaded region represents the area in which the points are at least apart. It has area , so the probability the two points are at least apart is simply .

This trick can be applied to a whole host of problems. As far as I can tell the only requirement is that we are sampling from uniform distributions. One somewhat classic problem is to find the probability density function of a random variable where . By the same trick we can compute the CDF of , we just need to split it into cases:

The CDF is therefore when and when . Differentiating gives us the triangular distribution when and when .

Looking at the last post I thought an interesting idea would be to generalize this to uniform random variables. This is of course a solved problem: the density function is known as the Irwin-Hall distribution. I wanted to take a run at it from our high-dimensional geometry perspective, since we can apply the same idea as above to the unit cube in dimensions to compute the CDF of Irwin-Hall.

Before we attack this we need to know how to compute the volume of the standard -simplex, or the volume of the set where the s are nonnegative. We’ll follow the explanation given in [2]. First let’s consider the simplex in defined by and the origin. This is just the set . We can fit exactly of these in the unit cube since there are such orderings and each point in the unit cube is in one of these simplices (I’m fudging some issues with the boundaries but it should be fine I think). Thus the original simplex has volume . We can map this simplex to the standard simplex by the transformation . This is a transformation with determinant one so the volume remains unchanged, so the volume of the standard simplex is .

I drew some pictures of the three dimensional case since some interesting things happen there. We’re keeping track of the volume underneath the plane that’s contained within the unit cube. Similar to the two-dimensional case, our function will be piecewise since it changes when it hits vertices of the cube. First our simplex increases at an obvious rate, maintaining a volume of . It looks kind of like this:

Then the function changes when passes . The way we compute the new volume is by taking the volume of the red simplex and subtracting out the volume of the blue simplices (outlined in the following figure), which gives us .

Finally the function changes for a last time when passes . We could just compute the volume of the missing simplex and subtract that from one, but we’ll try a method that works a little more generally. Note that the blue simplices have overlapped to form new simplices which are outlined in green below. Our method of computation is to take the red simplex, subtract out the blue simplices, and then add back in the green simplices. It’s basically inclusion-exclusion. This gives us .

This appears to generalize in a fairly simple manner. Note that our function changes based on the integer part of . The first piece of our function is naturally just . When hits , the plane hits exactly vertices (more precisely it hits ). Our volume computation then requires that we subtract out the newly formed simplices. These have side length and there are exactly of them, since one forms at each vertex.

If then we see that we will be computing . Each time crosses an integer the plane hits vertices (choose which of the coordinates are ) and exactly that many new simplices are formed to be added or subtracted out, depending on parity. Thus our CDF is exactly

And differentiating with respect to gives us our PDF

Admittedly there are easier ways to go about proving the expressions for the PDF or CDF are valid, but I like this one since it minimizes the amount of “clairvoyance” involved. As a whole I find this trick with the unit cube to be fairly useful whenever solving problems with uniform distributions. I’m not sure of legitimate practical applications but it seems to come up in contest math from time to time. Hopefully someday I will spot an opportunity to use it in a real-world setting.