Skip to content

Commit d85e139

Browse files
committed
test gauss
1 parent 5d040cc commit d85e139

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

useful_scripts/multivariate_gaussian_pdf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ def pdf_multivariate_gauss(x, mu, cov):
2121
return float(part1 * np.exp(part2))
2222

2323
def test_gauss_pdf():
24+
from matplotlib.mlab import bivariate_normal
25+
2426
x = np.array([[0],[0]])
2527
mu = np.array([[0],[0]])
2628
cov = np.eye(2)
2729

28-
print(pdf_multivariate_gauss(x, mu, cov))
30+
mlab_gauss = bivariate_normal(x,x)
31+
mlab_gauss = float(mlab_gauss[0]) # because mlab returns an np.array
32+
impl_gauss = pdf_multivariate_gauss(x, mu, cov)
33+
34+
print('mlab_gauss:', mlab_gauss)
35+
print('impl_gauss:', impl_gauss)
36+
assert(mlab_gauss == impl_gauss), 'Implementations of the mult. Gaussian return different pdfs'
2937

30-
# prints 0.15915494309189535
3138

3239
if __name__ == '__main__':
3340
test_gauss_pdf()

0 commit comments

Comments
 (0)