Created
February 10, 2019 15:28
-
-
Save abhishek-Kumar009/ed62c93c6d2c3ed1009e21ad8c14ad06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multivariateGaussian(X, mu, sigma2): | |
n = np.size(sigma2, 1) | |
m = np.size(sigma2, 0) | |
#print(m,n) | |
if n == 1 or m == 1: | |
# print('Yes!') | |
sigma2 = np.diag(sigma2[0, :]) | |
#print(sigma2) | |
X = X - mu | |
pi = math.pi | |
det = np.linalg.det(sigma2) | |
inv = np.linalg.inv(sigma2) | |
val = np.reshape((-0.5)*np.sum(np.multiply((X@inv),X), 1),(np.size(X, 0), 1)) | |
#print(val.shape) | |
p = np.power(2*pi, -n/2)*np.power(det, -0.5)*np.exp(val) | |
return p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment