任务。有一个计算器,但手头没有统计表。例如,您需要学生分布的关键点表来计算置信区间。使用Excel获取计算机?不运动。
不需要很高的精度,您可以使用近似公式。下列公式的想法是通过变换参数,可以将所有分布以某种方式简化为正态分布。近似值应既提供累积分布函数的计算,又提供其反函数的计算。
让我们从正态分布开始。
它需要计算功能
哪里
和常数
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
现在我们有了正态分布函数,我们给出一个参数并计算学生的t分布[2]:
辅助变量
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
粗略计算分布的想法
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
费舍尔分布(用于
, .
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.