mirror of
https://github.com/rasbt/python_reference.git
synced 2024-11-23 20:11:13 +00:00
test gauss
This commit is contained in:
parent
5d040cc076
commit
d85e1393fd
|
@ -21,13 +21,20 @@ def pdf_multivariate_gauss(x, mu, cov):
|
|||
return float(part1 * np.exp(part2))
|
||||
|
||||
def test_gauss_pdf():
|
||||
from matplotlib.mlab import bivariate_normal
|
||||
|
||||
x = np.array([[0],[0]])
|
||||
mu = np.array([[0],[0]])
|
||||
cov = np.eye(2)
|
||||
|
||||
print(pdf_multivariate_gauss(x, mu, cov))
|
||||
mlab_gauss = bivariate_normal(x,x)
|
||||
mlab_gauss = float(mlab_gauss[0]) # because mlab returns an np.array
|
||||
impl_gauss = pdf_multivariate_gauss(x, mu, cov)
|
||||
|
||||
print('mlab_gauss:', mlab_gauss)
|
||||
print('impl_gauss:', impl_gauss)
|
||||
assert(mlab_gauss == impl_gauss), 'Implementations of the mult. Gaussian return different pdfs'
|
||||
|
||||
# prints 0.15915494309189535
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_gauss_pdf()
|
||||
|
|
Loading…
Reference in New Issue
Block a user