No title

Anonymous Coward 2018-03-05 13:06:08.862005 UTC

1#sigma
2 for i in range(Nclasses):
3 sigma_temp = np.zeros((Ndims))
4 #Collect vectors from class k
5 for j in range(Npts):
6 if labels[j] == classes[i]:
7 x = X[j,:]
8 #Subtract mu
9 x = x - mu[i,:]
10 #Square each element individually
11 x = np.square(x)
12 #Sum over vectors to gain a single vector
13 sigma_temp += x
14 #Divide by number of vectors in k
15 sigma_temp /= N_k[i]
16 #Convert to a diagonal matrix
17 sigma[i,:,:] = np.diag(sigma_temp)