Task. There is a calculator , but no statistical tables at hand . For example, you need tables of critical points of the Student's distribution to calculate the confidence interval. Get a computer with Excel? Not athletic.
Great accuracy is not needed, you can use approximate formulas. The idea of ββthe formulas below is that by transforming the argument, all distributions can be somehow reduced to normal. The approximations should provide both the calculation of the cumulative distribution function and the calculation of its inverse function.
Let's start with the normal distribution.
It requires calculating the function
Where
and the constant
function y = erfa(x)
a = 0.147;
x2 = x**2; t = x2*(4/pi + a*x2)/(1 + a*x2);
y = sign(x)*sqrt(1 - exp(-t));
endfunction
function y = erfinva(x)
a = 0.147;
t1 = 1 - x**2; t2 = 2/pi/a + log(t1)/2;
y = sign(x)*sqrt(-t2 + sqrt(t2**2 - log(t1)/a));
endfunction
function y = normcdfa(x)
y = 1/2*(1 + erfa(x/sqrt(2)));
endfunction
function y = norminva(x)
y = sqrt(2)*erfinva(2*x - 1);
endfunction
Now that we have the normal distribution functions, we give an argument and calculate the Student's t-distribution [2]:
where auxiliary variable
function y = tcdfa(x,n)
t1 = (n - 1.5)/(n - 1)**2;
y = normcdfa(sqrt(1/t1*log(1 + x**2/n)));
endfunction
function y = tinva(x,n)
t1 = (n - 1.5)/(n - 1)**2;
y = sqrt(n*exp(t1*norminva(x)**2) - n);
endfunction
The idea of ββcalculating the distribution roughly
function y = chi2cdfa(x,n)
s2 = 2/9/n; mu = 1 - s2;
y = normcdfa(((x/n)**(1/3) - mu)/sqrt(s2));
endfunction
function y = chi2inva(x,n)
s2 = 2/9/n; mu = 1 - s2;
y = n*(norminva(x)*sqrt(s2) + mu)**3;
endfunction
Fisher distribution (for
, .
function y = fcdfa(x,k,n)
mu = 1-2/9/k; s = sqrt(2/9/k);
lambda = (2*n + k*x/3 + k-2)/(2*n + 4*k*x/3);
normcdfa(((lambda*x)**(1/3)-mu)/s)
endfunction
function y = finva(x,k,n)
mu = 1-2/9/k; s = sqrt(2/9/k);
q = (norminva(x)*s + mu)**3;
b = 2*n + k-2 -4/3*k*q;
d = b**2 + 8/3*k*n*q;
y = (sqrt(d) - b)/(2*k/3);
endfunction
- Sergei Winitzki. A handy approximation for the error function and its inverse. February 6, 2008.
- Gleason J.R. A note on a proposed Student t approximation // Computational statistics & data analysis. β 2000. β Vol. 34. β β. 1. β Pp. 63-66.
- Wilson E.B., Hilferty M.M. The distribution of chi-square // Proceedings of the National Academy of Sciences. β 1931. β Vol. 17. β β. 12. β Pp. 684-688.
- Li B. and Martin E.B. An approximation to the F-distribution using the chi-square distribution. Computational statistics & data analysis. β 2002. Vol. 40. β β. 1. pp. 21-26.