May-19-2017, 11:36 AM
Hi everyone,
I want to construct a matrix with aleatory numbers that are limited by previously determined values. These values are gave in arrays which contains the upper (ub) and lower bounds (lb). I know how to create a vector/array with these characteristics, like the code below shows:
Here's an example of desired output using the same bounds of the code above:
I want to construct a matrix with aleatory numbers that are limited by previously determined values. These values are gave in arrays which contains the upper (ub) and lower bounds (lb). I know how to create a vector/array with these characteristics, like the code below shows:
import numpy as np from random import random lb = np.array([1,2,3,4]) ub = np.array([5,6,7,8]) example = lb+(ub-lb)*random()Here's an output from the code above:
Output:[ 4.63529552 5.63529552 6.63529552 7.63529552]
Now, what's the fastest "pythonic" way to construct a matrix (4,4), which the values are limited by the upper and lower bounds? Here's an example of desired output using the same bounds of the code above:
Output:[ 4.63529552 5.63529552 6.63529552 7.63529552]
[ 3.53452228 4.53452228 5.53452228 6.53452228]
[ 1.43902942 2.43902942 3.43902942 4.43902942]
[ 2.70643708 3.70643708 4.70643708 5.70643708]
Thanks for the help.