I am having trouble fitting a multivariate gaussian distribution to my dataset, more specifically, finding a mean vector (or multiple mean vectors). My dataset is an N x 8 matrix and currently I am using this code:
muVector = np.mean(Xtrain, axis=0) where Xtrain is my training data set.
For the covariance I am building it using a arbitrary variance value (.5) and doing:
covariance = np.dot(.5, np.eye(N,N) where N is the number of observations.
But when I construct my Phi matrix, I am getting all zeros. Here is my code:
muVector = np.mean(Xtrain, axis=0)
# get covariance matrix from Xtrain
cov = np.dot(var, np.eye(N,N))
cov = np.linalg.inv(cov)
# build Xtrain Phi
Phi = np.ones((N,M))
for row in range(N):
temp = Xtrain[row,:] - muVector
temp.shape = (1,M)
temp = np.dot((-.5), temp)
temp = np.dot(temp, cov)
temp = np.dot(temp, (Xtrain[row,:] - muVector))
Phi[row,:] = np.exp(temp)
Any help is appreciated. I think I might have to use np.random.multivariate_normal()? But I do not know how to use it in this case.