使用seaborn库获取最佳正态分布的均值和标准差

3

我有一组数据,使用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

我该如何获取正态分布参数并在图表中添加标签?

1个回答

2
不要从绘图中获取它们作为输出;使用您传递给其的估计器对象:
norm.fit(C)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接