below is the code to create multiple sets of 0’s and fill it with random numbers, im then taking the first column and calculating the maximum value, the problem is I need to be able to do this for every row (i.e rows 2 through 10)
ive tried putting it into a for loop however it doesnt work with the traditional y=1, mx[:,y], y = y+1
can anyone offer some help? cheers
import pylab
mx = pylab.zeros ((10,6))
for j in range(0,10):
mx[j] = pylab.randn()
p = mx[:,1]
a = max (p)
If you are looking for the max of rows 2 through 10,
then use
mx.max(axis=1)to find the max of all rows, and then slice it down to just rows 2 through 10:For example, if
Then
Finally, as larsman has already shown, you can use
mx = np.random.randn(10, 6)to make the random matrix.