I am working on Minkowski Distances, which is defined by:
I use a for loop to calculate it as follow,
import numpy as np
import random
A = np.random.randint(5, size=(10, 5))
B = [1, 3, 5, 2, 4]
for i in range(10):
dist = (sum((abs(A[i]-B))**5))**(1/5) # I set p=5 in this case
print("Distances: ", dist)
Is there any way I can avoid this loop using numpy techniques?