macro zinvcdf p zp #This macro accepts a specified p value and finds the corresponding zp value #where p is the left tail area. The error is generally less than +/-0.001. #Example calling statement: # mtb> %zinvcdf 0.025 k1 #Answer is z = -1.960. #Copyright (c) Paul G. Mathews 9 Oct 01 All Rights Reserved #Mathews and Malnar, Statistical Consultants and Trainers #217 Third Street, Fairport Harbor, OH 44077 #440-350-0911 pmathews@apk.net mcolumn pref zref pinterp zinterp mconstant p zp n pgt50pct #Here are the look-up tables for interpolation. Successive values of p are geometric #progression with multiplicative factor of 1.25. set pref 0.000100 0.000125 0.000156 0.000195 0.000244 0.000305& 0.000381 0.000477 0.000596 0.000745 0.000931 0.001164& 0.001455 0.001819 0.002274 0.002842 0.003553 0.004441& 0.005551 0.006939 0.008674 0.010842 0.013553 0.016941& 0.021176 0.026470 0.033087 0.041359 0.051699 0.064623& 0.080779 0.100974 0.126218 0.157772 0.197215 0.246519& 0.308149 0.385186 0.481482 0.500000 0.601853 end set zref 3.71902 3.66226 3.60471 3.54634 3.48710 3.42697 3.36590& 3.30385 3.24077 3.17660 3.11130 3.04481 2.97705 2.90796& 2.83746 2.76546 2.69186 2.61657 2.53946 2.46041 2.37926& 2.29586 2.21000 2.12148 2.03005 1.93541 1.83724 1.73513& 1.62860 1.51708 1.39985 1.27602 1.14445 1.00366 0.85161& 0.68548 0.50110 0.29189 0.04643 0.00000 -0.25815 end if p>0.5 #Does left tail calculation only so fix p if necessary let pgt50pct=1 let p=1-p else let pgt50pct=0 endif let n=2 #Start through the look-up table while p>pref(n) let n=n+1 endwhile let pinterp(1)=pref(n-1) #Map the three values for quadratic interpolation let pinterp(2)=pref(n) let pinterp(3)=pref(n+1) let zinterp(1)=zref(n-1) let zinterp(2)=zref(n) let zinterp(3)=zref(n+1) %quadinterp pinterp zinterp p zp #Call the quadratic interpolation macro let zp=-round(zp,3) if pgt50pct let p=p+0.5 let zp=-zp endif print p zp #invcdf p #For checking the answer if required endmacro