我正在使用Canopy 2.1.3发行版(在Ubuntu 16.04上),您可能知道其中包含matplotlib软件包。只要运行在树冠的外壳import matplotlib.pyplot as plt给我
ImportError:Matplotlib基于qt的后端需要安装外部PyQt4,PyQt5或PySide软件包,但未找到。
我已经用Synaptic安装了所有三个软件包,但是问题仍然存在。这可能与环境变量有关吗?还是因为Canopy的Python 3.5和Ubuntu的Python 2.7冲突?
编辑:我终于通过从Canopy的程序包管理器安装了PyQt。
应该使用以下方法来计算PDF:
bins = [20 23 31.5 57 62.5 89 130]; % classes of values of my random variable
mean = 23;
std = mean/2;
values = mean + std*randn(1000,1); % the actual values of the RV
% method 1
[num, bins] = hist(values, bins); % histogram on the previously defined bins
pdf2 = num/trapz(bins, num);
trapz(bins, pdf2) % checking the integral under the curve, which is indeed 1
ans =
1
% method 2
pdf1 = normpdf(bins, mean, std); % …Run Code Online (Sandbox Code Playgroud)