As of Matplotlib 3.1, mlab.bivariate_normal is removed from matplotlib's library. I was wondering if there is a built-in class that does the same job elsewhere (or in matplotlib)? I searched for a bit but can't find it readily.
I realize that one can just copy the function here and use it but I was wondering if there is a built-in function that one can call.
As suggested by @tmdavison, scipy.stats.multivariate_normal()
can be used to replace matplotlib.mlab.bivariate_normal()
.
The call:
Z = matplotlib.mlab.bivariate_normal(X, Y, sig_x, sig_y, mu_x, mu_y, sig_xy)
becomes:
rv = scipy.stats.multivariate_normal([mu_x, mu_y], [[sig_x, sig_xy], [sig_xy, sig_y]])
Z = rv.pdf(np.dstack((X, Y)))
The matplotlib.mlab.bivariate_normal()
function had default values for all arguments except X
and Y
so you may have to add some extra values. The sig_x
and sig_y
values defaulted to 1.0
and all other arguments defaulted to 0.0
. So if you are replacing the call bivariate_normal(X, Y)
it would become multivariate_normal([0, 0], [[1, 0], [0, 1]]).pdf(np.dstack((X, Y)))
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.