Numpy Revision

“Discover the power of NumPy arrays – a fundamental data structure in Python for efficient numerical computing. Learn how to manipulate, analyze, and perform complex mathematical operations on multidimensional arrays with ease. Unlock the potential of NumPy for faster, more efficient data processing and scientific computing.”

import numpy as np # 3 by 3 ko matrix create garcha 
np.random.rand(3,3)
 
# array([[0.87612984, 0.48702927, 0.32388041],
       [0.04236177, 0.42151749, 0.1251573 ],
       [0.62588125, 0.90828501, 0.43026473]])


print(np.random.randint(0,10, size=[2,2])) # if you want integer 
# [[6 8]
   [2 6]]


#pick 10 items from  a given list with equal probability 
# print(np.random.choice(['a', 'e', 'i', '0', 'u'], size = 10))
# There is less comma in numpy
# data type is differnt
# ['e' 'u' 'e' 'e' 'i' 'a' 'e' '0' 'a' '0']


print(np.random.choice([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], size = 16))
#[2 9 4 5 2 8 7 8 3 9 0 6 4 5 5 5]



# if you want to work with probability 
# print(np.random.choice(['a', 'e', 'i', '0', 'u'], size = 10, p=[0.1, 0.2, 0.1, 0.2, 0.3]))
aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher']
print(np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3]))

#Statistical Function
# Min # Max # Mean @ Median @ SD
# Min is average
# quantity lying at the midpoint of a frequency
# how linear is variance is measured by SD 
print(np.min(normal_array))

a = [1, 2, 3, 4, 5, 6, 7]
b = np.array(a)
print(b)
np.mean(b)

# Matrix Operations 
# if you want determinant of the matrix then you can calculate 
# inverse, trace = can be seen during confusion matrix 
# Transpose 
import scipy.linalg as slin
import numpy as np 
a = np.array ([[]])
slin.det(a)
slin.inv(a)


# Solving the value of x, y, z
import numpy as np
import scipy.linalg as slin

a = np.array([[1,2,7], [3,4,12], [23,4,1]])
b = np.array([12,9,3])
np.linalg.solve(a,b)
# array([  5.27586207, -32.12068966,  10.13793103])


# matrix 
#vector # derivative, 
# computational power is need because it has large number of matrix (eg. Photo)
# Mathematics is important if you want to solve a complex problem 
# If you want to work on already existing problem then less mathematics is needed 
# Eigenvalue Problem in Numpy

Leave a Comment