Generating a uniformly distributed set of numbers with negatives? I have a number generator that can generate numbers between 0 and 1. I want to somehow use this generate a set of $N$ numbers that add up to $1$, and include negative numbers. These numbers must be uniformly distributed.
For example, if $N = 3$, one possible result might be $(0.4, -0.5, 1.1)$. Another might be $(0.2, 0.4, 0.4)$.
Is this possible? And if so, how would I go about it?
EDIT: I would rather the numbers are limited to be between $-1$ and $1$. So $(0.4, -0.5, 1.1)$ is no longer a possible combination.
 A: An $n$-tuple $(x_{1}, \cdots, x_{n})$ of independently, uniformly distributed numbers can be thought as a uniformly chosen point in an $n$-dimensional box (with probability measure chosen as the normalized Lebesgue measure on this box).
In this case, note that the region
$$D = \{ (x_{1}, \cdots, x_{n} ) \in \Bbb{R}^{n} : -1 \leq x_{j} \leq 1 \text{ and } x_{1} + \cdots + x_{n} = 1 \}$$
defines an $(n-1)$-dimensional flat surface. So it makes sense to choose the uniform distribution for this problem as the normalized surface measure on $D$.
Though we may devise a clever formula for generating such uniform samples on $D$, I will adopt a crude method.
Let $\Bbb{A}$ be the hyperplane containing $D$ and let $\pi : \Bbb{R}^{n} \to \Bbb{A}$ be the orthogonal projection onto $\Bbb{A}$. Choose a box $B$ in $\Bbb{R}^{n-1} \simeq \Bbb{R}^{n-1}\times\{0\}$ so that $D \subset \pi(B)$. If $U$ denotes the uniform distribution on $B$, then our desired uniform distribution for $D$ is given by
$$ \Bbb{E}[\pi U \vert \pi^{-1}D]. $$
Implementing this random variable is very simple:


*

*Generate an instance of random $n$-tuple $U$ on $B$.

*Calculate $\pi U$.

*Accept of discard this instance according to whether $\pi U$ lies inside $D$ or not.


It is easy to check that
$$ \pi(x_{1}, \cdots, x_{n}) = \left(x_{1} - \bar{x}+\frac{1}{n}, \cdots, x_{n} - \bar{x}+\frac{1}{n} \right), \qquad \bar{x} = \frac{x_{1} + \cdots + x_{n}}{n}. $$
Also it turns out that $B$ can be taken as $[-1-\sqrt{n}, 1+\sqrt{n}]^{n-1}$. The following is a simulation for $n = 3$ with $10000$ samples.
Proj[l_] := l - Mean[l] + 1/Length[l];
IsInD[l_] := And @@ Table[-1 <= l[[j]] <= 1, {j, 1, Length[l]}];
Rp[n_] := Module[{l},
   While[True,
    l = RandomVariate[UniformDistribution[{-1 - Sqrt[n], 1 + Sqrt[n]}], n - 1];
    AppendTo[l, 0];
    l = Proj[l];
    If[IsInD[l], Break[];];
    ];
   Return[l];
   ];


