File Exchange

image thumbnail


version 1.0 (1.77 KB) by

Finds the Tukey's q studentized range critical value.

1 Download


View License

This function finds the Tukey's q studentized range critical value. This modified macro is based on the Fortran77 algorithm AS 190.2 Appl. Statist. (1983). It needs the sample degrees of freedom (must be the same for each sample), the k number of samples and the p-cumulative probability value (default=0.95). It gives a very good approximation for 0.8 < p < 0.995).

Comments and Ratings (5)

Sav Deb

The last if condition, return values only for v<120. For v> it returns errors!!

Sav Deb

Is there a better mode to obtain the q-vaue?
Has someone already converted Fortran routines prtrng() and qrtrng to m files?

Other solution?



Mark (view profile)

The statistics toolbox does have a private function that implements AS 190 and 190.2 under toolbox/stats/private/stdrinv.m from R2011a. It is called from the multcompare tool when doing the default Tukey HSD comparison.

The note accompanying the code is
% Based on Fortran program from statlib,
% Algorithm AS 190 Appl. Statist. (1983) Vol.32, No. 2
% Incorporates corrections from Appl. Statist. (1985) Vol.34 (1)

William Rose

William Rose (view profile)

qTukey() not very accurate.
qTukey implements an algorithm (AS 190.2, called qtrng0() in the Fortran) which was only intended to be a first approximation of Tukey's q. qtrng0 was intended to serve as a startup estimate for the more accurate routine, AS 190.1, called qtrng() in the Fortran. qtrng() uses AS 190, called prtrng() in the Fortran. ptrng() computes a p value for a given q statistic. qtrng() computes q for a desired probability p by recursively calling prtrng() and updating its estimate for q, until the desired accuracy is achieved (p within 0.001 in the Fortran code). If someone converts the Fortran routines prtrng() and qrtrng to m files, then we will have a good algorithm for estimating Tukey's q. Fortran code at

Liran Carmel

Not accurate. For example, qtukey(20,11,0.99) is 6.1422, while in the tables it is 6.190.

MATLAB Release
MATLAB 5.3 (R11)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video