使用 SciPy 的分位数-分位数图 [英] Quantile-Quantile Plot using SciPy

查看:93
本文介绍了使用 SciPy 的分位数-分位数图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将如何使用 Python 创建 qq-plot?

How would you create a qq-plot using Python?

假设您有大量测量值,并且正在使用一些以 XY 值作为输入的绘图函数.该函数应根据某些分布(正态、均匀...)的相应分位数绘制测量值的分位数.

Assuming that you have a large set of measurements and are using some plotting function that takes XY-values as input. The function should plot the quantiles of the measurements against the corresponding quantiles of some distribution (normal, uniform...).

结果图让我们可以在我们的测量中评估是否遵循假设的分布.

The resulting plot lets us then evaluate in our measurement follows the assumed distribution or not.

http://en.wikipedia.org/wiki/Quantile-quantile_plot

R 和 Matlab 都为此提供了现成的函数,但我想知道在 Python 中实现的最简洁的方法是什么.

Both R and Matlab provide ready made functions for this, but I am wondering what the cleanest method for implementing in in Python would be.

推荐答案

更新:正如人们所指出的,这个答案不正确.probplot 不同于分位数-分位数图.在您在解释或传达您的发行版关系时出错之前,请查看这些评论和其他答案.

Update: As folks have pointed out this answer is not correct. A probplot is different from a quantile-quantile plot. Please see those comments and other answers before you make an error in interpreting or conveying your distributions' relationship.

我认为 scipy.stats.probplot 会做你想做的.有关更多详细信息,请参阅文档.

I think that scipy.stats.probplot will do what you want. See the documentation for more detail.

import numpy as np 
import pylab 
import scipy.stats as stats

measurements = np.random.normal(loc = 20, scale = 5, size=100)   
stats.probplot(measurements, dist="norm", plot=pylab)
pylab.show()

结果

这篇关于使用 SciPy 的分位数-分位数图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆