python - 使用seaborn库从最佳拟合正态分布中获取平均值和标准差

标签 python scipy seaborn

我有一组数据,我使用seaborn库绘制直方图,应用核密度估计并对数据拟合正态分布。不过,我想提取最佳拟合正态分布的均值标准差。如何从该库的函数 distplot 中获取这些值作为输出? 我的代码:

import seaborn as sns
from scipy.stats import norm 
sns.set_style("darkgrid")
sns.set_context("paper", font_scale=1, rc={"lines.linewidth": 1.5, "axes.linewidth": 1.0, "axes.labelsize": 15, "xtick.labelsize": 10, "ytick.labelsize": 10, "font.family":'serif','font.serif':'Ubuntu'})

fig, axes = plt.subplots(1, 1, figsize=(10, 10))
sns.distplot(C,
            fit=norm, kde=True,
            fit_kws ={"color": "#fc4f30", "lw": 1.5},
            kde_kws={"color": "y", "lw": 1.5},
            hist_kws={"histtype": "stepfilled", "linewidth": 1, "alpha": 0.1, "color": "b"},
            norm_hist=True, ax=axes[0,0])

seaborn 库中的一个错误是,它不会生成拟合正态分布的标签,但会生成直方图或核密度的标签。
enter image description here

如何获取正态分布参数并在图中为其制作标签?

最佳答案

不要将它们作为绘图的输出;使用您传递给它的估计器对象:

norm.fit(C)

关于python - 使用seaborn库从最佳拟合正态分布中获取平均值和标准差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35996070/

相关文章:

scipy - scipy稀疏矩阵的元素明智exp()

python - Python 中的马尔可夫转移概率矩阵实现

macos - 运行时错误 : cannot get window extent w/o renderer with seaborn

python - 如何使用密度图识别异常值

Python - 连接或堆叠两个以上不同形状的数组

python - 从 CSV 中删除整行(如果为空)

python - 如何将 .get() 函数与单选按钮一起使用

numpy - Theano 由于 NumPy Fortran 在 Ubuntu 下混合而失败

python - 如何使用按钮向 Matplotlib 条形图和折线图添加排序功能

python -Django : Page Not found