A code golf question by xnor led to the following nice problem: let and be 2 random variables such that marginally, and . Find a joint distribution of such that .
You need and to be negatively correlated for this. I wrote the problem in the lab coffee room, leading to nice discussions (see also Xian’s blog post). Here are two solutions to the problem:
1. Let and . Then:
- and are both , hence
- and hence
2. A second solution, found by my colleague Amic Frouvelle, is to sample uniformly from the black area:
I quite like that the first solution is 1d but the second is 2d.