Generating clustered random variables I am interested in choosing $n$ variables from a list of $N$ discrete variables uniformly distributed in the range $[0,1]$. I would like these variables to be clustered together, so the probability of choosing a tuple is higher when they are closer together.
I feel that the distribution
$P(x_1,\ldots x_n) \sim \exp\bigg[-\frac{1}{2\sigma^2}\bigg(\sum_i x_i^2 - n\mu_{\{x_1,\ldots x_n\}}^2\bigg)\bigg] = \exp\bigg[-\frac{\text{Variance}(x_1,\ldots x_n)}{2\sigma^2}\bigg]$
would fit, but I have no particular inclination toward it and wouldn't usually jump to a gaussian for bounded variables. I would simply like to preference bunched variables without removing spatial uniformity (thus the gaussian of the variance).
For a program, I need to select a set of $\{x_1,\ldots x_n\}$ with $n$ independent randoms, but I'm not too familiar with the stat terminology, so I'm having trouble finding how to do this. I can make some rough approximations to calculate marginals if $1 >> \sigma >> 1/N$. But I'd like something easier to work with and more sound.
My dream answer has a nice distribution for this kind of problem, quick variable set generation, good performance for $n<<N$ ($n=3$ nominal case), works well for non-repeating variables. Bonus if it's easily extendable to higher dimensional metrics.
This seems a pretty generic problem, so I assume there is some duplicate out there, but I can't find it, sorry.
 A: Well I'll post my approximation to this. I'm not great with random variables, so this'll probably be a bit amateur.
Assume $\sigma<<1$, i.e. that $\{x_i\}$ in a set will gather together much closer than the size of the range, $1$. Assume $N>>\sigma$, so that sums become integrals. Define a function of $m$ variables:
$P^m(\{x_i\}) = P^m_0 \exp\bigg[-\frac{1}{2\sigma^2}\bigg(\sum_{i\leq m} x_i^2 - m\mu_{\{x_i\}}^2\bigg)\bigg], \qquad P^m_0 = \sqrt{m}(2\pi)^{\frac{m-1}{2}}\sigma^{m-1}$
First, select $x_1$ randomly between $0$ and $1$. Then select $x_2$ using probability $P^2(x_1, x_2)$ (with $x_1$ fixed), then $x_3$ using $P^3(x_1, x_2, x_3)$, etc. Then the variables will be distributed as the joint probability in the question ($P^n$).
This works alright. It's easy to calculate and easy to generalize to higher dimensions. But it gives too much weight to $x_i$ near the edges, when $x_i \lesssim \sigma$ or $x_i \gtrsim (1-\sigma)$; the conditional probability should be less there since there are fewer values to draw from near the edge: $\frac{1}{2^n}<\frac{P_{\text{edge}}}{P_{\text{middle}}}<\frac{1}{2}$. I can correct for this to some extent. More pressing, the sum->integral approximation is not great in my case, $N\sim100$.
This will suit my purposes, but a better answer could easily supplant it.
