mardi 9 avril 2019

A random array within some bounds

I have a an array params with errors e_params and bounds that the array can be params_bounds:

params = [0.2, 0.2]
e_params = [0.1, 0.05]
params_bounds = [(0.0, 1.0), (0.0, 1.0)]

I want to draw a random Gaussian realisation of params as follows:

import numpy as np
params_mc = np.random.normal(params, e_params)

Is there any way to make sure that the result params_mc is within the upper and lower bounds specified by params_bounds?

Thanks for any help here.




Aucun commentaire:

Enregistrer un commentaire