code 41026;
real procedure KENDALL(X, N); value X, N; real X, N;
begin
integer I, G, IX; real P;
if N < 0 ∨ ENTIER(N) < N then
STATAL3 ERROR(“KENDALL”, 2, N);
G:= N × (N - 1) / 2; IX:= G + ENTIER(-(G - X) / 2) × 2;
if IX ≥ G then KENDALL:= 1 else
if IX < -G then KENDALL:= 0 else
if N > 9 then
KENDALL:= PHI(IX + 1 / SQRT(N × (N - 1) × (N+N+5) / 18))
else if IX > 0 then
begin P:= 0; for I:= G step -2 until IX + 2 do
P:= P + KENDALLPROB(I, N); KENDALL:= 1 - P
end else
begin P:= 0; for I:= -G step 2 until IX do
P:= P + KENDALLPROB(I, N); KENDALL:= P
end
end KENDALL;
eop