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