QuoteOriginally posted by: maratikuslet's fix n = 20, c =10%. Generate uniform (x_1, ..., x_20): x_1+...+x_20=1 and each x_i is between 0 and 10%.thx. but one more question, if i think (x1, ..., xn) as coordinates, could you further clarify whether the p.d.f. of each coordinate is U(0,c) (when marginalized over other x's), or the point determined by the vector (x1, ..., xn) is uniform within the polytope, which is determined by the intersection of the hyperplane x1+...+xn=1 and the hypercube with side length of c?if the latter case, as crmorcom said, you can use independent exponential variables plus the rejection method to satisfy the [0,c] bound;(if c=1, then the polytope is just unit simplex, and no need for rejection)----- ----- this part is WRONG----- -----another more efficient way (w/o rejection but requires sorting) is to use order statistics. for example, if n=3, the polytope in general is a hexagon (except when c=0.5 or 1, and no solution for c<0.5). denote its vertices as v1,...,v6 (see them as vectors) with coordinates: (0,c,1-c) and the permutations. now generate five U(0,1) and sort them as 0<y1<...<y5<1, get the six spacings between them: z1=y1-0, z2=y2-y1, ..., y6=1-y5. then the vector (x1,x2,x3)=y1*v1+...+y6*v6 is what you want.----- ----- ----- ----- -----the former case is much more complicated. back to the simple n=3 case, the question basically asks a way to generate a density distribution on a hexagon so that the projected density to each direction is uniform. seems to me it's possible - will post more if i got any progress.QuoteOriginally posted by: zerdnaGenerate n numbers x(i) from U(0,1), divide them by the r=max(X)/c , then subtract from each of new numbers the difference a=(1-sum(x(i))/r))/n, or something like that. The random numbers are now from U(-a, 1/r)...zerdna, would you mind explaining why the above process would generate uniform r.v.s? it's not clear to me why it would.
Last edited by wileysw
on October 11th, 2009, 10:00 pm, edited 1 time in total.