tcdf tries to process more efficiently small positive integer DF up to 1e4 (without calling betainc).
Or this only helps the execution performance if x is a scalar but not for a vector. For a vector the execution time is ALWAYS worse, even for df==1.
Test Code:
tic;
x = [ 0.25 0.50 ];
df = [1,2,5,10,100,500, 1000, 2000];
for ii = df
t = toc();
for i=1:1000
y = tcdf(x, ii);
endfor
printf("df: %4d Time: %4.2f\n",ii, toc()-t);
endfor
Current code:
df: 1 Time: 0.67
df: 2 Time: 0.67
df: 5 Time: 0.68
df: 10 Time: 0.68
df: 100 Time: 0.73
df: 500 Time: 0.93
df: 1000 Time: 1.18
df: 2000 Time: 1.69
If I disable the code branch to avoid calling betainc (ks(:) = false), the execution is ALWAYS smaller:
df: 1 Time: 0.65
df: 2 Time: 0.60
df: 5 Time: 0.60
df: 10 Time: 0.60
df: 100 Time: 0.60
df: 500 Time: 0.60
df: 1000 Time: 0.60
df: 2000 Time: 0.60