import numpy as np
a1 = np.random.choice(7,5)
a1
array([5, 2, 0, 6, 3])
a2 = np.random.choice([0,1,2,3,4,5,6],5)
a2
array([5, 3, 6, 2, 1])
a3 = np.random.choice(np.array([0,1,2,3,4,5,6]),5)
a3
array([5, 0, 4, 1, 0])
a4 = np.random.choice([0,1,2,3,4,5,6],5,replace=False)
a4
array([1, 4, 0, 2, 3])
a5 = np.random.choice(np.array([0,1,2,3,4,5,6]),5,p=[0.1,0.1,0.1,0.1,0.1,0.1,0.4])
a5
array([5, 1, 1, 4, 4])
import numpy as np
a = np.array([[1,1,1],[2,2,2],[0,3,6]])
print(a)
b1 = np.argmax(a)
print(b1)
b2 = np.argmax(a, axis=0)
print(b2)
b3 = np.argmax(a, axis=1)
print(b3)
[[1 1 1]
[2 2 2]
[0 3 6]]
8
[1 2 2]
[0 0 2]
import numpy as np
y1 = np.linspace(-10.0,10.0)
y1
array([-10. , -9.59183673, -9.18367347, -8.7755102 ,
-8.36734694, -7.95918367, -7.55102041, -7.14285714,
-6.73469388, -6.32653061, -5.91836735, -5.51020408,
-5.10204082, -4.69387755, -4.28571429, -3.87755102,
-3.46938776, -3.06122449, -2.65306122, -2.24489796,
-1.83673469, -1.42857143, -1.02040816, -0.6122449 ,
-0.20408163, 0.20408163, 0.6122449 , 1.02040816,
1.42857143, 1.83673469, 2.24489796, 2.65306122,
3.06122449, 3.46938776, 3.87755102, 4.28571429,
4.69387755, 5.10204082, 5.51020408, 5.91836735,
6.32653061, 6.73469388, 7.14285714, 7.55102041,
7.95918367, 8.36734694, 8.7755102 , 9.18367347,
9.59183673, 10. ])
y2 = np.linspace(1,10,10)
y2
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
y3 = np.linspace(1,10,10,endpoint=False)
y3
array([ 1. , 1.9, 2.8, 3.7, 4.6, 5.5, 6.4, 7.3, 8.2, 9.1])
y4= np.linspace(1, 10, 6, retstep=True)
y4
(array([ 1. , 2.8, 4.6, 6.4, 8.2, 10. ]), 1.8)