Aproximações simples e rápidas para funções estatísticas

Tarefa. Existe uma calculadora , mas nenhuma tabela estatística disponível . Por exemplo, você precisa de tabelas de pontos críticos da distribuição do Aluno para calcular o intervalo de confiança. Conseguir um computador com Excel? Não atlético.



Não é necessária grande precisão, você pode usar fórmulas aproximadas. A ideia das fórmulas abaixo é que, ao transformar o argumento, todas as distribuições podem ser de alguma forma reduzidas ao normal. As aproximações devem fornecer o cálculo da função de distribuição cumulativa e o cálculo de sua função inversa.



Vamos começar com a distribuição normal.



Φ(z)=P=12[1+erf(z2)]



z=Φ-1(P)=2erf-1(2P-1)



Requer o cálculo da função erf(x)e o inverso. Usei a aproximação [1]:



erf(x)=sEugn(x)1-exp(-x24π+umax21+umax2)



erf-1(x)=sEugn(x)-t2+t22-1umaemt1



t1 t2 — :



t1=1-x2,t2=2πuma+emt12



uma=0,147. Octave.



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]:



Ft(x,n)=Φ(1t1em(1+x2n))



t=Ft-1(P,n)=nexp(Φ-1(P)2t1)-n



t1



t1=n-1,5(n-1)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


χ2 [3]:



σ2=2noven,µ=1-σ2



Fχ2(x,n)=Φ((xn)1/3-µσ)



χ2=Fχ2-1(P,n)=n(Φ-1(P)σ+µ)3



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


( n/k3 n3) . χ2 [4], , .



σ2=2noven,µ=1-σ2



λ=2n+kx/3+(k-2)2n+4kx/3



Ff(x;k,n)=Φ((λx)1/3-µσ)



, .



q=(Φ-1(P)σ+µ)3



b=2n+k-2-4/3kq



D=b2+8/3knq



x=Ff-1(P;k,n)=-b+D2k/3



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




  1. Sergei Winitzki. A handy approximation for the error function and its inverse. February 6, 2008.
  2. Gleason J.R. A note on a proposed Student t approximation // Computational statistics & data analysis. – 2000. – Vol. 34. – №. 1. – Pp. 63-66.
  3. 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.
  4. 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.



All Articles