Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use the Q-test to determine outlier in my dataset. However, I cannot find a function to do this is in Mathematica. Does anyone know if there is a function which does this in Mathematica?


share|cite|improve this question
Maybe you could describe the $Q$-test a little? – Dilip Sarwate Jan 20 '12 at 22:42
Not my idea of recreational mathematics, so I'm re-tagging as statistics. Maybe there's a better tag. – Gerry Myerson Jan 20 '12 at 23:05
@GerryMyerson If $Q$ means the complementary Gaussian cumulative distribution function, probability distributions and normal distribution might also be appropriate tags. – Dilip Sarwate Jan 21 '12 at 1:50
@Dilip, go for it. OP can always change it if it's wrong. – Gerry Myerson Jan 21 '12 at 2:10
Did you mean the Dixon Q-test? – J. M. Jan 26 '12 at 11:47

If it's Dixon's Q-test that you are referring to, it's not too hard to compute the statistic; it's the CDFs and quantiles that are a bit troublesome to do. As can be seen here, the formulae for the CDF are rather complicated, which is why Rorabacher just chooses to use spline interpolation on pretabulated values (which I presume were a bit difficult to generate). I am however told that the use of Dixon's test and other such procedures is passé, however.

Anyway, as I said the statistic itself is not too hard to compute:

qstat[data_?VectorQ, mode : Min | Max] := 
 With[{sd = Sort[data]}, (#2 - #1) & @@ 
    Take[sd, 4 Boole[mode === Min] - 2]]/(Max[data] - Min[data])

Choose mode as Min or Max, depending on whether you want to test the lowest value or the highest one as an outlier. Remember that once you've decided to remove one, it is poor form to reapply the test on the edited data.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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