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