-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnp4.py
41 lines (32 loc) · 1.28 KB
/
np4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
x = np.arange(10)
# [0 1 2 3 4 5 6 7 8 9]
x = np.arange(4, 9)
# [4 5 6 7 8]
x = np.arange(3, 23, 4)
# [ 3 7 11 15 19]
x = np.linspace(0, 15, 10)
# [ 0. 1.66666667 3.33333333 5. 6.66666667 8.33333333 10. 11.66666667 13.33333333 15. ]
x = np.linspace(0, 15)
# [ 0. 0.30612245 0.6122449 0.91836735 1.2244898 1.53061224
# 1.83673469 2.14285714 2.44897959 2.75510204 3.06122449 3.36734694
# 3.67346939 3.97959184 4.28571429 4.59183673 4.89795918 5.20408163
# 5.51020408 5.81632653 6.12244898 6.42857143 6.73469388 7.04081633
# 7.34693878 7.65306122 7.95918367 8.26530612 8.57142857 8.87755102
# 9.18367347 9.48979592 9.79591837 10.10204082 10.40816327 10.71428571
# 11.02040816 11.32653061 11.63265306 11.93877551 12.24489796 12.55102041
# 12.85714286 13.16326531 13.46938776 13.7755102 14.08163265 14.3877551
# 14.69387755 15. ]
x = np.arange(20)
# [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
x = np.reshape(x, (4, 5))
# [[ 0 1 2 3 4]
# [ 5 6 7 8 9]
# [10 11 12 13 14]
# [15 16 17 18 19]]
x = np.random.random((2, 3))
# [[0.16605343 0.75125611 0.44105574]
# [0.10625777 0.91500736 0.36847429]]
x = np.random.randint(2, 12, size=(2, 3))
# [[ 7 4 10]
# [ 3 2 8]]