N_karag ευχαριστω για την απαντηση.Τα ειδα και εκανα μια υλοποιηση οπως παρακατω
import sys
import numpy as np
import pandas as pd
import scipy as sp
from scipy.spatial.distance import mahalanobis
import matplotlib.pyplot as plt
import numpy
import scipy.spatial.distance
A = numpy.array([[1.0151, -0.8201, -0.2968,-0.5684, 1.4887, -0.8185],
[-0.8463, 1.5214, 0.0543, -1.0871, 0.7791, -0.4214],
[0.001, -0.0746, -1.385, -0.5394, 0.3708, 1.6272],
[1.4672, 1.0127, -0.7713, -0.2665, -0.962, -0.4801],
[0.5175, -0.3852, 1.25, -1.5165, -0.5298, 0.664]])
print('\nA=',A)
covar = numpy.cov(A, rowvar=0)
print('\ncovar=',covar)
if(A.shape[1:2]==(1,)):
invcovar = numpy.linalg.inv(covar.reshape(1,1))
else:
invcovar = numpy.linalg.inv(covar)
print('\ninvcovar=',invcovar,'\n')
for i in range(len(A)):
if i==4:
print ('mahala distance between ','A'+str(i),'A'+str(i-4),scipy.spatial.distance.mahalanobis(A,A[i-4],invcovar))
quit()
print ('mahala distance between ','A'+str(i),'A'+str(i+1),scipy.spatial.distance.mahalanobis(A,A[i+1],invcovar))
#plt.scatter(A)
#plt.show()
δουλευει αλλα θελει χτενισμα
Σε χαιρετω