|
1 | 1 | import numpy as np
|
2 | 2 | import time
|
3 | 3 | import sys
|
| 4 | +import matplotlib.pyplot as plt |
4 | 5 |
|
5 | 6 |
|
6 | 7 | a = np.array([1,2,3])
|
|
11 | 12 |
|
12 | 13 | S = range(1000)
|
13 | 14 | print(S)
|
14 |
| -print(sys.getsizeof(5)*len(S)) # List - size of one element multiplied by the number of all elements, so we got the size of all elements |
| 15 | +print(sys.getsizeof(5)*len(S)) # List - size of one element multiplied by the number of all elements, |
| 16 | + # so we got the size of all elements |
15 | 17 | print(sys.getsizeof(5)) #size of one element
|
16 | 18 |
|
17 | 19 | D = np.arange(1000)
|
18 |
| -print(D.size * D.itemsize) # NumPy - size of one element multiplied by the number of all elements, so we got the size of all elements |
| 20 | +print(D.size * D.itemsize) # NumPy - size of one element multiplied by the number of all elements, |
| 21 | + # so we got the size of all elements |
19 | 22 |
|
20 | 23 | SIZE = 1000000
|
21 | 24 | L1 = range(SIZE)
|
|
61 | 64 | print("\n", np.sqrt(a)) #square
|
62 | 65 | print("\n", np.std(a)) #Standart Deviation (средне квадратическое отклонение)
|
63 | 66 |
|
64 |
| -b = np.array([(7,5,10),(25,34,2),(0,1,3)]) |
| 67 | +b = np.array([(7,5,10),(25,34,2),(7,1,3)]) |
65 | 68 |
|
66 | 69 | print("\n", a+b) #sum of matrices
|
67 | 70 | print("\n", a-b) #substraction of matrices
|
|
71 | 74 | print("\n"*2,np.vstack((a,b))) #concatenation along the first axis ->
|
72 | 75 | print("\n"*2,np.hstack((a,b))) #stack arrays in sequence horizontaly (column wise)
|
73 | 76 | print("\n", a.ravel()) #into a single column
|
| 77 | + |
| 78 | +x = np.arange(0, 3 * np.pi, 0.1 ) |
| 79 | +y = np.sin(x) |
| 80 | +z = np.cos(x) |
| 81 | +plt.plot(x,y) #sin plot |
| 82 | +plt.plot(x,z) #cos plot |
| 83 | +plt.show() |
| 84 | + |
| 85 | +ar = np.array([2, 5, 10]) |
| 86 | +print("\n", np.exp(ar)) #exponential |
| 87 | +print("\n", np.log(ar)) #natural log с основой 2 |
| 88 | +print(np.log10(ar)) #с основой 10 |
0 commit comments