Created
August 18, 2017 13:06
-
-
Save vlavorini/b11d44ee6e9741f70a75d201260c908d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def gaussian(d, bw): | |
return np.exp(-0.5*(d/bw)**2) / (bw*np.sqrt(2*np.pi)) | |
def meanshift_vec(points): | |
dists=poinc_dist_vec(points) #the matrix of the distances | |
weights = gaussian(dists, sigma) #the matrix of the weights | |
expd_w=np.dot(weights, points) #the weighted vectors | |
summed_weight=np.sum(weights,0) # the array of the summed weights, for normalize the weighted vectors | |
shifted_pts=expd_w/np.expand_dims(summed_weight,1) #the normalized vectors | |
return shifted_pts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment