简体   繁体   English

QQ plot in python 理论分位数斧头错误

[英]Q-Q plot in python eror in the theorical quantile axe

I need to plot a QQ graph with the following information:我需要plot一个QQ图,信息如下:

spcs2k = np.array([[ 49, 524,  16,  87, 157,  58,   4,  41, 110,  90,   2,  41, 136,
        495, 249,  40,  48,   3,  72, 294,  49,  28, 163,  61,  89,   2,
        168, 286,  23,  67,  19,  11,  63,   4, 246, 130,   2, 378, 176,
        251,  78, 138,  97,  34,  33, 183,  12, 209,  82,  87,   9,  33,
         19,  77,  54,  28,  59,  88, 202,  12,  53,  86, 146,  26, 112,
        176,  35,  94, 180,  93,   8,  32,  26,   5, 145,  13,   5, 138,
        205,  42,  17, 134,  19,  54, 133, 134,  10, 173,   3,  59, 223,
        109, 175, 266, 314,  68, 283,  71,  77, 147,  32,  70, 131, 112,
         32,  29,  19,  28,  85,  25,  57,  16, 130, 157,  13, 167,  29,
          2, 442,  10, 150, 185,  95,  57,  63, 150,  41,  22,  72,  59,
          2,   8,   5, 156,  51, 161, 243, 152, 289,  93,  34, 140,  74,
         34,  37,   9, 121, 138,  94,  67,  65, 202,  67,  13, 240, 209,
          2, 296,   6,  61,   2, 134, 196]])

import statsmodels.api as sm
import scipy.stats as stats
from matplotlib import pyplot as plt

fig = sm.qqplot(spcsk2,stats.expon,line="45")
plt.show()

but i get this:但我明白了: 在此处输入图像描述

and the idea is get a similar graph like this:这个想法是得到一个类似的图表:

在此处输入图像描述

thanks for supporting me谢谢你支持我

Whoever has this problem should pass fit=True to the sm.qqplot method.有这个问题的人应该将fit=True传递给sm.qqplot方法。 This will auto-determine parameters such as loc, scale, and distargs.这将自动确定参数,例如 loc、scale 和 distargs。 See docs here: https://www.statsmodels.org/dev/generated/statsmodels.graphics.gofplots.qqplot.html .请在此处查看文档: https://www.statsmodels.org/dev/generated/statsmodels.graphics.gofplots.qqplot.html

The code works fine, it does what it should.代码工作正常,它应该做的。 QQ plot show if the data that you pass to it is normally distributed or not. QQ plot 显示您传递给它的数据是否为正态分布。 In your case this means that the values are not even vaguely normally distributed in spcs2k.在您的情况下,这意味着这些值在 spcs2k 中甚至不是模糊的正态分布。

If you run this code, you can see what it looks like on a dataset that came from normal distribution.如果您运行此代码,您可以在来自正态分布的数据集上看到它的样子。

data = np.random.normal(0,1, 1000)
fig = sm.qqplot(data, line='45')
plt.show()

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

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