Skip to content

Instantly share code, notes, and snippets.

@ortsed
Created January 22, 2020 19:07
Show Gist options
  • Save ortsed/9402bdd623e9edbc0d4222c6436d1582 to your computer and use it in GitHub Desktop.
Save ortsed/9402bdd623e9edbc0d4222c6436d1582 to your computer and use it in GitHub Desktop.
Multivariate Gaussian
def multivariateGaussian(X, mu, sigma):
k = len(mu)
sigma=np.diag(sigma)
X = X - mu.T
p = 1/((2*np.pi)**(k/2)*(np.linalg.det(sigma)**0.5))* np.exp(-0.5* np.sum(X @ np.linalg.pinv(sigma) * X,axis=1))
return p
p = multivariateGaussian(X, mu, sigma)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment