Skip to content

Instantly share code, notes, and snippets.

@toyballz
Created November 10, 2020 18:00
Show Gist options
  • Save toyballz/05225866ccf3fc8c0131a8c668fa8539 to your computer and use it in GitHub Desktop.
Save toyballz/05225866ccf3fc8c0131a8c668fa8539 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment