简体   繁体   English

何时在 qqplot 中使用 line=r 和 line=45

[英]When to use line=r and line=45 in qqplot

Can anyone tell me when do we use line='r'??谁能告诉我我们什么时候使用 line='r'?

sm.qqplot(df['Delivery_time'], line='r')

and when do we use line=45?我们什么时候使用line=45?

sm.qqplot(df['Delivery_time'], line='45')

According to the documentation stats.mode l,line can be {None, “45”, “s”, “r”, “q”} “45” - 45-degree line “r” - A regression line is fit根据文档 stats.mode l,line can be {None, “45”, “s”, “r”, “q”} “45” - 45 度线 “r” - 拟合回归线

Let me add codes and output of the the two cases for better understanding.让我添加这两种情况的代码和输出以便更好地理解。

Case 1:, if we are comparing the distribution of a sample of data to a theoretical normal distribution, we might use line='r' to plot a regression line that shows how well the sample data fits the normal distribution.案例 1:如果我们将数据样本的分布与理论正态分布进行比较,我们可能会使用 line='r' 来绘制回归线,以显示样本数据与正态分布的拟合程度。

import numpy as np
import statsmodels.api as sm
import pylab as py
data_points = np.random.normal(0, 1, 100)   

sm.qqplot(data_points, line ='r')
py.show()

行='r'

Case 2: If the line='45' would refer to a 45-degree line, which is a line that has a slope of 1 and passes through the origin.情况 2:如果 line='45' 表示 45 度线,即斜率为 1 并通过原点的线。 This line is used as a reference for comparing the distribution of the data being plotted to a uniform distribution.这条线用作将绘制的数据的分布与均匀分布进行比较的参考。

import numpy as np
import statsmodels.api as sm
import pylab as py
data_points = np.random.normal(0, 1, 100)   

sm.qqplot(data_points, line ='45')
py.show()

输出:45 度角的参考线

For example, in the above case we are compare the distribution of a sample of data to a uniform distribution, we might use line='45' to plot a reference line that shows how well the sample data fits the uniform distribution.例如,在上述情况下,我们将数据样本的分布与均匀分布进行比较,我们可能会使用 line='45' 来绘制一条参考线,以显示样本数据与均匀分布的拟合程度。

Note:The line parameter can be used to customize the reference line on the QQ plot to better compare the distribution of the data being plotted to a theoretical distribution.注意:线参数可用于自定义 QQ 图上的参考线,以更好地将绘制的数据分布与理论分布进行比较。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM