How we can generate a random vector E=[e_1,e_2,e_3.…,e_N] in R^N such that sum_i^N e_i=T and 0 <= e_i <= d_i AAi in 1,2,3,…,N where d_i specifies the upper bound on each element of the vector. Is this problem over constrained? if yes, any guidance to for relaxation.

hommequidort0h

hommequidort0h

Answered question

2022-09-14

How we can generate a random vector E = [ e 1 , e 2 , e 3 . , e N ] R N such that i N e i = T and 0 e i d i i 1 , 2 , 3 , , N where di specifies the upper bound on each element of the vector. Is this problem over constrained?

Answer & Explanation

crearti2d4

crearti2d4

Beginner2022-09-15Added 9 answers

An obvious necessary condition is to have i = 1 N d i T
If you don't care about choosing uniformly, the simplest is to generate N random numbers 0 r i d i , and compute R = i = 1 N r i
In the case R<T, increase the e i one by one to their maximum until the i = 1 N e i = T as needed. The procedure is guaranteed to work if i = 1 N d i T
Otherwise (if R>T), then set e i = T r i / R. Then, by construction,
i = 1 n e i = i = 1 n T r i R = T R i = 1 n r i = T .

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?