%%% Examples of Large N Approximations clc format compact format short g % Stirling's Formula n=[1:10,20:10:100]; fact=factorial(n); approx1 = (n/exp(1)).^(n).*sqrt(n); approx2 = (n/exp(1)).^n.*sqrt(2*pi*n); error1= abs(fact-approx2)./fact*100; [n;fact;approx1;approx2; error1]' % Binomial v. Poisson n=1000 p=0.004 l=4 k=0:1:10; list1=[n:-1:n-10+1]; list2=[1:10]; bcoeffs=[1, cumprod(list1)./cumprod(list2)]; binom=bcoeffs.*p.^k.*(1-p).^(n-k); poisson=exp(-4)*4.^k./factorial(k); [k;binom;poisson]'