This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am toyballz on github. | |
* I am toyballz (https://keybase.io/toyballz) on keybase. | |
* I have a public key ASDOQTH6n30d7e07_vBfQLditFh2KyFTrsh_X7ZTFqGKrAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
#create the vectors | |
x = np.array([3,5]) | |
s = np.array([3,2]) | |
#use the formula | |
projection_x_on_s = (np.dot(x,s)/np.dot(x,x))*s | |
print(projection_x_on_s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @ is explicit operator for the dot product | |
def proj_matrix(v): | |
return v @ np.linalg.inv(v.T@v) @ v.T | |
def proj(vector, plane): | |
return proj_matrix(vector) @ plane |