[R] generate random numbers subject to constraints

Charles C. Berry cberry at tajo.ucsd.edu
Thu Mar 27 01:59:20 CET 2008


Ala' Jaouni <ajaouni <at> gmail.com> writes:

> 
> X1,X2,X3,X4 should have independent distributions. They should be
> between 0 and 1 and all add up to 1. Is this still possible with
> Robert's method?
> 

NO.

If they add to 1 they are not independent.

As Ted remarked, the constraints define two simplexes and the solution you seek
lies in their intersection.

However, depending on the choices of a, b, c, d, and n in a*X1+b*X2+c*X3+d*X4=n,
there may not be a solution that satisfies your constraints (no intersection
between the two simplexes - as when a<n, b<n, c<n and d<n), or the two
constraints share a vertex and nothing else (as when a=n, b<n, c<n, and d<n),
the two simplexes intersect along a line (as when a=n, b=n, c<n, d<n),  the
intersection of the two simplexes lies on a plane (as when a=b=c=n and d<n), or
the two simplexes are the same (a=n, b=n, c=n, and d=n).

Now you can develop sampling schemes that will satisfy any of these
possibilities, but are they really what you need?

To answer this question, you may need help in formulating this problem beyond
what a forum like this can provide.

HTH,

Chuck



More information about the R-help mailing list