jeudi 22 novembre 2018

Conditional random number generator python numpy

I want to create a random number generator but with condition.

code is like below;

s_weights = []
num = 3
limit = 50000
np.random.seed(101)

for x in range(limit):
    weights = np.random.random(num)
    weights /= np.sum(weights)
    s_weights.append(weights)

it returns me 50.000 lists of numpy array of 3 weights (3,) like below

0.429134083359603413e-01 5.115615408184341906e-01 2.552505084560561729e-02

I want to limit first weight with rule of >=0.60

first weight should change between 0.60 - 1.00 and other two should change between 0.00 - 1.00

how can I modify the code?

thanks in advance




Aucun commentaire:

Enregistrer un commentaire