Use `scipy.stats` to compute bivariate normal
`matplotlab.mlab.bivariate_normal` is deprecated since matplotlib 2.2
and is removed since 3.0
@@ -2,9 +2,9 @@ import argparse
import contextlib
import time
-from matplotlib import mlab
import matplotlib.pyplot as plt
import numpy as np
+from scipy import stats
import cupy
@@ -107,9 +107,8 @@ def draw(X, pred, means, covariances, output):
y = np.linspace(-5, 5, 1000)
X, Y = np.meshgrid(x, y)
for i in range(2):
- Z = mlab.bivariate_normal(X, Y, np.sqrt(covariances[i][0]),
- np.sqrt(covariances[i][1]),
- means[i][0], means[i][1])
+ dist = stats.multivariate_normal(means[i], covariances[i])
+ Z = dist.pdf(np.stack([X, Y], axis=-1))
plt.contour(X, Y, Z)
plt.savefig(output)
