dimanche 21 février 2021

setting constraints on random number list generation in python

I have the following random number list generator, each sample is from the bounds m=0 to the respective elements 'g' of list gen_limit

import numpy as np
m=0
gen_limit=[100,20,50,200,10,50]
rand_gen=list([np.random.uniform(m,g) for g in gen_limit])
>>> [54.99, 2.09, 10.61, 143.44, 7.08, 35.34]

is there any way to introduce a constraint, for example where rand_gen equals x = 100.0 ? e.g. sample output would be

[18.2575,2.09,10.61,26.6225,7.08,35.34,253.55] == 100



Aucun commentaire:

Enregistrer un commentaire