computation seems correct

master
Steve L. Nyemba 8 years ago
parent 61bbb2c5d2
commit 44674bb83c

@ -12,16 +12,19 @@ yr_ = np.sqrt(np.var(m[1,:]))
mn = np.array([list( (m[0,:]-xu_)/xr_),list( (m[1,:]-yu_)/yr_)])
cx = np.cov(mn)
n = m.shape[0]
x = np.array([2.5,3.1])
x = np.array([2.4,3.1])
u = np.array([xu_,yu_])
d = np.matrix(x - u)
d.shape = (n,1)
a = (2*(np.pi)**(n/2))*np.linalg.det(cx)**0.5
b = np.exp(-0.5*np.transpose(d) * (cx**-1)*d)
b = np.exp((-0.5*np.transpose(d)) * (np.linalg.inv(cx)*d))
from scipy.stats import multivariate_normal
xo= multivariate_normal.pdf(x,u,cx)
yo= (b/a)[0,0]
for row in np.transpose(m):
print ",".join([str(value) for value in row])
e= 0.001
print [yo,yo < e]
print [xo,xo < e]
#for row in np.transpose(m):
# print ",".join([str(value) for value in row])
#-- We are ready to perform anomaly detection ...

Loading…
Cancel
Save