4

I want to generate three random variables a, b and c such that (i) a+b+c=0; and (ii) each one is uniformly distributed in (-1,1).

The two-variable version is easy: a=2*rand()-1; b=-a. (Note: rand() is uniformly distributed in (0,1))

The following solution doesn't work because c's range is too large: a=2*rand()-1; b=2*rand()-1; c=-a-b.

The following solution doesn't work either because c is not uniformly distributed: a=2*rand()-1; b=2*rand()-1; c=(-a-b)/2.

Wu Yongzheng
  • 1,707
  • 17
  • 23
  • 1
    Your last statement that c=(-a-b)/2 is not uniformely distributed if a and b are, is the answer to your question: it is mathematically impossible, what you ask for. An interesting question would be, if there is such a common distribution for a, b and c such that they can sum up to 0. – coproc Oct 22 '12 at 09:32
  • 1
    I'm not sure that your proof is correct, although I upvoted it initially. because a,b are not necessary independent. Actually they must be not intependent, to make it work. Although I still don't believe that what the OP wants is possible. – sega_sai Oct 22 '12 at 11:04
  • possible duplicate of [Choosing n numbers with fixed sum](http://stackoverflow.com/questions/5622608/choosing-n-numbers-with-fixed-sum) – finnw Oct 22 '12 at 11:48
  • @sega_sai good point, you make there. So it seems it is possible! (see the second example in my answer below). – coproc Oct 22 '12 at 11:57
  • @liuminzhao I didn't say a and b are independent, so P(a=-1 and b=-1) can be different from P(a=-1)*P(b=-1). Coming back to your question, while P(a=-1) and P(b=-1) are both positive, P(a=-1 and b=-1) can be 0. There is no self-contradiction. – Wu Yongzheng Oct 29 '12 at 06:30
  • @WuYongzheng You are right. The case seems to be hard for me. `a`, `b`, and `c` sit in a hyperplane within a cube. So far I have no idea how to do that. I would follow to see any answers. – liuminzhao Oct 29 '12 at 18:11

3 Answers3

1

Would they be evenly distributed though?

I would say throw 3 dice but the expected value would be 10.5 which can never occur, so I am going to say throw 3 special dice that run only from 1 to 5, and they must sum to 9.

Possible combinations are:

  • 1,3,5 (*6)
  • 1,4,4 (*3)
  • 2,2,5 (*3)
  • 2,3,4 (*6)
  • 3,3,3 (*1)

There are 6 combinations of 1,3,5 and 2,3,4, 3 combinations of 1,4,4 and 2,25 and only one combination of 3,3,3. This is 19 possible combinations (out of 125 possible scenarios).

Within these we get these dice getting rolled these number of times. (remember in 2,2,5 you count 3* for each 2, so that is 6 rolls of a 2).

  • 1 : 9
  • 2 : 12
  • 3 : 15
  • 4 : 12
  • 5 : 9

so whilst the original distribution is uniform, once you put in the constraint you see it is no longer uniform. (Note that these numbers add to 57 as a confirmation, 19 different combinations with 3 throws in each).

CashCow
  • 30,981
  • 5
  • 61
  • 92
  • (Press return too early. Please ignore my previous comment.) I'm not sure if I understand it correctly. You are looking at the discrete version of this problem. That is: (i) their sum is 9; and (ii) the out come of each dice is evenly distributed among 1,2,3,4 and 5. You are trying to show that this is not possible. I think it's possible and can give a solution: generate the following five outcome with equal probability. (1,3,5), (2,5,2), (3,2,4), (4,4,1), (5,1,3). – Wu Yongzheng Oct 23 '12 at 07:21
1

Before we know whether it is possible what you ask for, you might be interested in the answer to a slightly different question:

Is it possible to have three equally distributed variables a,b,c such that they always add up to zero?

The answer is yes: you take for instance three uniformely distributed variables a0,b0,c0 and with s=a0+b0+c0 you can get a=a0-s/3, b=b0-s/3 and c=c0-s/3 with the required property. If you start with a0,b0,c0 = 1.5*rand()-0.75 the resulting a,b,c will be in [-1,1] and the distribution of a,b,c will approx. look like this:

enter image description here

Now if you want the a,b,c to be closer to a uniform distribution over [-1,1] you can try something like a0,b0,c0 = 0.75*(2*rand()-1)^(1/3) which will produce a distribution for a,b,c similar to this:

enter image description here

coproc
  • 6,027
  • 2
  • 20
  • 31
1

Wu, you are correct, there is a solution. Here is the construction. Generate a = 2*rand()-1. Now if a < 0, then let b = a + 1. Otherwise, let b = a - 1. Finally, let c = -(a+b).

It's not too hard to show that a, b, and c are identically distributed uniformly on [-1,1]. Interestingly, the solution is symmetrical in that all three pairwise correlations are -1/2. And it only needs one call to the random generator.

soakley
  • 233
  • 11
  • 15
  • Greate solution. It's a equilateral triangle inside the cube. – Wu Yongzheng Oct 03 '13 at 02:58
  • 1
    The method only samples from a couple of lines. If a < 0, then it's the line 2a+c+1=0. If a >= 0, then it's the line 2a+c-1=0. – soakley Jan 29 '14 at 23:44
  • Three line segments to be exact. – Wu Yongzheng Jan 30 '14 at 03:38
  • 1
    I'm only seeing the two segments mentioned (with the appropriate constraints based on the problem). Where is the third? – soakley Jan 30 '14 at 23:02
  • To be clear: These three random variables are uniform but not independent. The solution space is a hexagon (cube centered around origin intersecting with a plane containing the origin). The two line segments are inside this hexagon, so valid solutions. – MSalters Sep 01 '23 at 12:30