Commit 57dd9e33 authored by Ben Glocker's avatar Ben Glocker
Browse files

replaced deprecated matplotlib.mlab.normpdf with scipy.stats.norm.pdf

parent 8ae86f24
...@@ -281,18 +281,18 @@ ...@@ -281,18 +281,18 @@
The cell below will plot the GMM on top of the image histogram The cell below will plot the GMM on top of the image histogram
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import matplotlib.mlab as mlab from scipy.stats import norm
def plot_gmm(x, gmm): def plot_gmm(x, gmm):
omega = gmm.weights_ omega = gmm.weights_
mu = gmm.means_ mu = gmm.means_
sigma = np.sqrt(gmm.covariances_) sigma = np.sqrt(gmm.covariances_)
for ind in range(0,omega.shape[0]): for ind in range(0,omega.shape[0]):
plt.plot(x,omega[ind]*mlab.normpdf(x, mu[ind], sigma[ind]), linewidth=2, label='GMM Component '+str(ind)) plt.plot(x,omega[ind]*norm.pdf(x, mu[ind], sigma[ind]), linewidth=2, label='GMM Component '+str(ind))
plt.figure(figsize=(10, 4), dpi=100) plt.figure(figsize=(10, 4), dpi=100)
plt.hist(X, bins=num_bins, density=True, range=(lim_low, lim_high), label='Intensity histogram', color='lightgray'); plt.hist(X, bins=num_bins, density=True, range=(lim_low, lim_high), label='Intensity histogram', color='lightgray');
x = np.linspace(lim_low,lim_high,num_bins).reshape(-1,1) x = np.linspace(lim_low,lim_high,num_bins).reshape(-1,1)
plot_gmm(x,gmm) plot_gmm(x,gmm)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment