MATLAB: Does NCTCDF return incorrect values for X = Inf and X = -Inf, for nonzero values of DELTA in Statistics Toolbox 7.6

nctdcfStatistics and Machine Learning Toolbox

When NCTCDF is used to calculate the value for the noncentral t-distribution with a nonzero noncentrality parameter in the following format,
P = nctcdf(X,NU,DELTA)
it produces incorrect values when X = Inf and X = -Inf. For example, with a noncentrality parameter of 1.5:
>> nctcdf(Inf,4,1.5) % incorrect - should be 1
ans =
0
>> nctcdf(-Inf,4,1.5) % incorrect - should be 0
ans =
1
This function works correctly for Inf and -Inf only when the noncentrality parameter is 0 because the function handles this as a special case:
>> nctcdf(Inf,4,0) % correctly returns 1
ans =
1
>> nctcdf(-Inf,4,0) % correctly returns 0
ans =
0

Best Answer

This bug has been fixed in Release 2012b (R2012b). For previous product releases, read below for any possible workarounds:
This is a bug in NCTCDF in Statistics Toolbox 7.6. As a workaround, use very large numbers smaller than realmax (like 10^12 and -(10^12)) instead of Inf and -Inf:
>> nctcdf(10^12,4,1.5) % correctly returns 1
ans =
1
>> nctcdf(-(10^12),4,1.5) % for 64 bit, returns 1.1102e-016
ans =
1.1102e-016