Quantile-Quantile Plot using SciPy

后端 未结 9 2005
长情又很酷
长情又很酷 2020-12-04 06:44

How would you create a qq-plot using Python?

Assuming that you have a large set of measurements and are using some plotting function that takes XY-values as input. T

9条回答
  •  臣服心动
    2020-12-04 07:04

    To add to the confusion around Q-Q plots and probability plots in the Python and R worlds, this is what the SciPy manual says:

    "probplot generates a probability plot, which should not be confused with a Q-Q or a P-P plot. Statsmodels has more extensive functionality of this type, see statsmodels.api.ProbPlot."

    If you try out scipy.stats.probplot, you'll see that indeed it compares a dataset to a theoretical distribution. Q-Q plots, OTOH, compare two datasets (samples).

    R has functions qqnorm, qqplot and qqline. From the R help (Version 3.6.3):

    qqnorm is a generic function the default method of which produces a normal QQ plot of the values in y. qqline adds a line to a “theoretical”, by default normal, quantile-quantile plot which passes through the probs quantiles, by default the first and third quartiles.

    qqplot produces a QQ plot of two datasets.

    In short, R's qqnorm offers the same functionality that scipy.stats.probplot provides with the default setting dist=norm. But the fact that they called it qqnorm and that it's supposed to "produce a normal QQ plot" may easily confuse users.

    Finally, a word of warning. These plots don't replace proper statistical testing and should be used for illustrative purposes only.

提交回复
热议问题