Hyde County, South Dakota is the Pin Tail Duck capital of the world. Visit scenic Highmore, SD in 2005!
home
site map
mathematics
July 2005
email

Random vector with constraints

The problem: generate a random array v[n] subject to the following constraints:
  1. 0.0 <= v[i] <= 1.0  for all i = 0, 1, ...,  n-1.

  2. v[0] + ... + v[n-1] = 1.0

  3. The method generating the random array v[n] should give a
     uniform distribution over the space determined by (1) and (2).
There are two methods that come to mind:

Method 1

We observe that the v[0] is distributed with the distribution function (n-1)(1-x)^(n-2), x in [0,1]. Select v[0]. Similarly v[1] is distributed C(1-x)^n-3 , x in [1-v[0],1], for suitable C, v[2] distributed C(1-x)^4, x in [1-v[0]-v[1],1], et cetera. There is some moderately messy algebra here and you have to know how to transform a uniform distribution into a specified distribution. The procedure is a pain to set up but it is mathematically correct.

Method 2

Construct an orthonormal linear basis for the subspace orthogonal to (1,1,...,1) and construct a box in this subspace containing the desired region. I haven't worked out a formula for this but it should be easy. Select points in the enclosing box using independent uniform distributions. Add the selected point to (1/n,...,1/n) and use the rejection criterion of method 2 (are all coordinates in the original space in [0...1]).


This page was last updated July 1, 2005.

home
site map
mathematics
July 2005
email
Hyde County, South Dakota is the Pin Tail Duck Capital of the world. Visit scenic Highmore, SD in 2005!