3
$\begingroup$

I'm using QuantilePlot to assess if my data fits a normal distribution using Mathematica 11.3.

My data set is large, 500000 points. A histogram of my data plotted with a normal distribution visually shows excellent agreement.

Here I use QuantilePlot to compare with a normal distribution (I get the same result if I explicitly use a normal distribution as the second data set):

QuantilePlot[data, ImageSize -> Large]

The quantile plot shows the quantiles of 'data', and two parallel dotted lines representing the reference line. The data set falls almost perfectly on the lower of the two lines.

I can't find any reference to QuantilePlot plotting two parallel lines as the reference line. My data matches the lower of these two lines very well, but it is not clear what that means.

I tried plotting the quantiles of data against itself:

QuantilePlot[data, data, ImageSize->Large]

Plot of two parallel diagonal dotted lines with data points along the lower of the two.

This should be a perfect match, and it is, but again with the lower dotted line.

To try this for yourself I came up with:

normaldist=RandomVariate[NormalDistribution[1,0.5],100000];
QuantilePlot[normaldist, normaldist, PlotRange->{{0,0.02},{-0.01,0.02}}, ImageSize->Large]

Plot of two parallel diagonal dotted lines with data points along the lower of the two.

What is the second dotted line? All the examples in the documentation do not show a second line until you 'zoom in' using PlotRange.

$\endgroup$
  • 1
    $\begingroup$ This feels like a bug to me. Contact WRI Support to see if they agree. $\endgroup$ – Edmund Feb 21 at 12:42
  • $\begingroup$ Seems the issue is related to specifying the PlotRange option. Remove that option and the plot appears with the single reference line. $\endgroup$ – Edmund Feb 21 at 12:44
  • 1
    $\begingroup$ The second line does not appear with version "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" $\endgroup$ – Bob Hanlon Feb 21 at 15:28
  • $\begingroup$ Only one line in both "10.4.1 for Linux x86 (64-bit) (April 11, 2016)" and "11.3.0 for Linux x86 (64-bit) (March 7, 2018)". $\endgroup$ – corey979 Feb 22 at 12:07
1
$\begingroup$

At first glance this appears to be a bug. I suggest reporting it to WRI Support.

As a workaround you only need to remove the PlotRange option and the plot will display with the single reference line.

QuantilePlot[normaldist, normaldist, 
   ImageSize -> Large
   ReferenceLineStyle -> Directive[Orange, Thick]]

Mathematica graphics

Hope this helps.

$\endgroup$
  • $\begingroup$ Thanks for answering. The first plot I posted did not use the PlotRange option, and still had the double line. I think in your example there are still two lines, just so close together as to be indistinguishable, and that's why when you look at a smaller region using PlotRange you can see them. $\endgroup$ – L.Cowie Feb 21 at 13:13
  • $\begingroup$ @L.Cowie Most likely a bug. Contact WRI Support. $\endgroup$ – Edmund Feb 21 at 13:26
1
$\begingroup$

I ended up making a Quantile-Quantile plot myself to get around this. It's really slow and doesn't give the exact same result as QuantilePlot (less points?). But it will do. Perhaps someone else has a better way?

qsize = 0.00001;
quantiles = Quantile[data, #] & /@ Range[qsize, 1, qsize];
normalquantiles = 
  Quantile[NormalDistribution[Mean[data], 
      StandardDeviation[data]], #] & /@ Range[qsize, 1, qsize];
Show[ListPlot[Transpose[{normalquantiles, quantiles}], 
  PlotRange -> {{87.6, 89.65}, All}, ImageSize -> Large], 
 Plot[x, {x, 86, 92}, PlotStyle -> Directive[{Lighter, Dotted}]]]

Gives

Quantile-Quantile plot with dotted line representing a perfect fit and data points close to line

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.