DrawQQplot

(Source code, png)

../../_images/DrawQQplot.png
DrawQQplot(*args)

Draw a QQ-plot.

Refer to QQ-plot.

Available usages:

VisualTest.DrawQQplot(sample1, sample2, n_points)

VisualTest.DrawQQplot(sample1, distribution);

Parameters:
sample1, sample22-d sequences of float

Tested samples.

ditributionDistribution

Tested model.

n_pointsint, optional

The number of points that is used for interpolating the empirical CDF of the two samples (with possibly different sizes).

It will default to DistributionImplementation-DefaultPointNumber from the ResourceMap.

Returns:
graphGraph

The graph object

Notes

The QQ-plot is a visual fitting test for univariate distributions. It opposes the sample quantiles to those of the tested quantity (either a distribution or another sample) by plotting the following points cloud:

\left(x^{(i)},
      \theta\left(\widehat{F}\left(x^{(i)}\right)\right)
\right), \quad i = 1, \ldots, m

where \widehat{F} denotes the empirical CDF of the (first) tested sample and \theta denotes either the quantile function of the tested distribution or the empirical quantile function of the second tested sample.

If the given sample fits the tested distribution or sample, then the points should be almost aligned (up to the uncertainty associated with the estimation of the empirical probabilities) with the first bisector whose equation is:

y = x, \quad x \in \Rset

Examples

>>> import openturns as ot
>>> from openturns.viewer import View

Generate a random sample from a Normal distribution:

>>> ot.RandomGenerator.SetSeed(0)
>>> distribution = ot.WeibullMin(2.0, 0.5)
>>> sample = distribution.getSample(30)
>>> sample.setDescription(['Sample'])

Draw a QQ-plot against a given (inferred) distribution:

>>> tested_distribution = ot.WeibullMinFactory().build(sample)
>>> QQ_plot = ot.VisualTest.DrawQQplot(sample, tested_distribution)
>>> View(QQ_plot).show()

Draw a two-sample QQ-plot:

>>> another_sample = distribution.getSample(50)
>>> another_sample.setDescription(['Another sample'])
>>> QQ_plot = ot.VisualTest.DrawQQplot(sample, another_sample)
>>> View(QQ_plot).show()

Examples using the function

Draw the QQ-Plot

Draw the QQ-Plot

Test identical distributions

Test identical distributions