Created
August 6, 2017 13:03
-
-
Save vlavorini/baf9e916edbd973fdbf4c99daef7b9e5 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 poinc_dist_np(points): | |
u''' | |
if expanded, the following is equal to: | |
expd=np.expand_dims(points,2) | |
tiled=np.tile(expd, points.shape[0]) | |
trans=np.transpose(points) | |
num=np.sum(np.square(trans-tiled), axis=1) | |
#num | |
den1=1-np.sum(np.square(points),1) | |
dend=np.expand_dims(den1,1) | |
den1M=np.matrix(dend) | |
den=den1M * den1M.T | |
return 1+2*np.divide(num, den) | |
''' | |
return 1+2*np.divide(np.sum(np.square(np.transpose(points)-np.tile(np.expand_dims(points,2), points.shape[0])), axis=1), np.matrix(np.expand_dims(1-np.sum(np.square(points),1),1)) * np.matrix(np.expand_dims(1-np.sum(np.square(points),1),1)).T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment