简体   繁体   English

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

[英]getting mean and standard deviation from best-fit normal distribution using seaborn library

I have a set of data and I used seaborn library to plot the histogram, apply kernel density estimate and fit a normal distribution to the data.我有一组数据,我使用seaborn库来绘制直方图,应用核密度估计并拟合数据的正态分布。 However I would like to extract the mean and standard deviation of the best-fit normal distribution.但是我想提取最佳拟合正态分布的均值标准差 How could I get these values as outputs from the function distplot of this library?我怎样才能从这个库的函数distplot得到这些值作为输出? My code:我的代码:

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])

A bug in seaborn library is that, it doesn't generate the label for the fitted normal distribution but it does for histogram or kernel density. seaborn库中的一个错误是,它不会为拟合正态分布生成标签,但会为直方图或核密度生成标签。
在此处输入图片说明

How can I get the normal distribution parameters and make a label for it in the plot?如何获取正态分布参数并在图中为其制作标签?

Don't get them as outputs from the plot;不要将它们作为情节的输出; use the estimator object you are passing to it:使用您传递给它的 estimator 对象:

norm.fit(C)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 求出特定点距cdf的正态标准偏差和分布平均值 - Find normal standard deviation from the cdf at a specific point and the distribution mean 给定均值和标准差,生成二维正态分布 - Generate two-dimensional normal distribution given a mean and standard deviation 给定均值和标准差,如何计算正态分布的概率? - How to calculate probability in a normal distribution given mean & standard deviation? 直方图、均值、标准差的正态分布,在数组的某个部分内 - Normal distribution of histogram, mean, standard deviation, within a certain part of an array 生成一个 numpy random 查看从均值 1 和标准差 2 的正态分布中抽取的 100 个随机数的数组 - Generating a numpy random see array of 100 random numbers drawn from a normal distribution with mean 1 and standard deviation 2 使用scipy.stats的分布均值和标准差 - Distribution mean and standard deviation using scipy.stats 如何从 Python 中的频率分布表中获取均值和标准差 - How to get Mean and Standard deviation from a Frequency Distribution table in Python 如何在Python中获取600个值的均值为零且标准偏差为σ= 2 dB的对数正态分布(即以dB为单位的正态分布)? - How to get log-normal distribution (i.e. a normal distribution in dB) with a zero mean and a standard deviation of σ = 2 dB for 600 values in python? 当在 python 中为正态分布绘制 pdf 并且标准偏差为 2 时,平均值是否仍然为零? - when plotting a pdf in python for a normal distribution and the standard deviation is 2, will the mean still be zero? 使用 seaborn 从外部数据源绘制标准偏差 - Plot standard deviation from external datasource using seaborn
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM