Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from numpy.linalg import inv
- ton=np.array([4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8])
- tof=np.array([4,4,6,6,6,8,8,8,4,4,4,6,6,6,8,8,8,4,4,4,6,6,6,8,8,8])
- feed=np.array([4,6,4,6,2,6,2,4,2,4,6,4,6,2,6,2,4,2,4,6,4,6,2,6,2,4])
- current=np.array([1.5,1.1,1.5,1.5,1.1,1.5,1.1,1.1,1.9,1.9,1.5,1.9,1.2,1.1,1.8,1.5,1.1,2.1,1.9,1.5,2,1.8,1.5,1.9,1.9,1.5])
- voltage=np.array([55,65,45,55,65,45,55,65,45,55,65,45,55,65,45,55,65,45,55,65,45,55,65,45,55,65])
- speed=np.array([1.6,1.2,1.8,1.4,1.1,1.6,1.3,1.1,2.2,1.7,1.4,1.8,1.5,1.2,1.6,1.4,1.1,2.9,1.9,1.5,2.1,1.6,1.4,2,1.7,1.3])
- ra=np.array([1.64,1.69,1.85,2.03,1.99,1.86,1.83,1.84,2.02,1.84,1.88,1.67,1.64,1.71,1.8,2.18,2.03,1.98,2.01,1.82,2.5,1.75,2.72,2.23,1.88,1.95])
- O=[1 for i in range(26)]
- o=np.array(O)
- X=[]
- for i in range(26):
- a=[ton[i],tof[i],feed[i],current[i],voltage[i],speed[i]]
- X.append(a)
- X=np.matrix(X)
- Y=np.matrix(ra)
- Z=(np.transpose(X))*(X)
- Z=np.linalg.inv(Z)
- Z=Z*(np.transpose(X))
- Z=Z*(np.transpose(Y))
- test=np.matrix([4,4,2,1.9,45,1.9])
- print(test*Z) #expected value is 1.8
Add Comment
Please, Sign In to add comment