home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / gerald / 5_08 / stats < prev    next >
Text File  |  1992-04-12  |  5KB  |  170 lines

  1. %OP%VS4.12 (10-Feb-92), Gerald Fitton, R4000 2915 6625 6368 
  2. %OP%TNN
  3. %OP%DP4
  4. %OP%IRN
  5. %OP%PL0
  6. %OP%HM0
  7. %OP%FM0
  8. %OP%BM0
  9. %OP%LM4
  10. %OP%PT0
  11. %OP%WC2,1728,1072,1748,0,52,0,48
  12. %CO:A,150,0%Custom function sheet
  13.  
  14. Statistics
  15. ⌐ G A Nicholas February 1992
  16.  
  17.  
  18. Parameters for functions
  19.  
  20. sciform(number,no of significant figures)
  21. mean_stdev_number(range)
  22. sem(range)
  23. one_tailed_z_to_p(z)
  24. one_tailed_p_to_z(p)
  25. one_tailed_t_to_p(t,no of degrees of freedom)
  26. one_tailed_p_to_t(p,no of degrees of freedom)
  27. confidence_limits(range,probability)
  28. t_test(range,population mean)
  29. paired_t_test(range1,range2,population mean of differences)
  30. f_test(range1,range2)
  31. pooled_t_test(range1,range2)
  32. linear_regression_y_on_x(y_range,x_range)
  33.  
  34.  
  35. Function definitions
  36.  
  37. %V%%L%function("sciform","x:number","n:number")
  38. %V%%L%if(@x=0)
  39. %V%%L%     result(string(@x,@n-1))
  40. %V%%L%elseif(@x>0)
  41. %V%%L%     if(log(@x)-int(log(@x))>=0)
  42. %V%%L%          result(join(string(10^(log(@x)-int(log(@x))),@n-1),"e",string(int(log(@x)),0)))
  43. %V%%L%     else
  44. %V%%L%          result(join(string(10^(log(@x)-int(log(@x))+1),@n-1),"e",string(int(log(@x))-1,0)))
  45. %V%%L%     endif
  46. %V%%L%else
  47. %V%%L%     if(log(-@x)-int(log(-@x))>=0)
  48. %V%%L%          result(join("-",string(10^(log(-@x)-int(log(-@x))),@n-1),"e",string(int(log(-@x)),0)))
  49. %V%%L%     else
  50. %V%%L%          result(join("-",string(10^(log(-@x)-int(log(-@x))+1),@n-1),"e",string(int(log(-@x))-1,0)))
  51. %V%%L%     endif
  52. %V%%L%endif
  53.  
  54.  
  55. %V%%L%function("mean_stdev_number","range:array")
  56. %V%%L%avg(@range)
  57. %V%%L%sciform(A45,5)
  58. %V%%L%std(@range)
  59. %V%%L%sciform(A47,5)
  60. %V%%L%string(count(@range),0)
  61. %V%%L%join("mean = ",A46," ; standard deviation = ",A48," ; n = ",A49)
  62. %V%%L%result(A50)
  63.  
  64.  
  65. %V%%L%function("sem","range:array")
  66. %V%%L%std(@range)/sqr(count(@range))
  67. %V%%L%sciform(A55,5)
  68. %V%%L%join("sem = ",A56)
  69. %V%%L%result(A57)
  70.  
  71.  
  72. %V%%L%function("one_tailed_z_to_p","z:number")
  73. %V%%L%abs(@z)
  74. %V%%L%1+A62*(0.049867347+A62*(0.0211410061+A62*(0.0032776263+A62*(3.80036e-5+A62*(4.88906e-5+A62*5.383e-6)))))
  75. %V%%L%0.5/A63^16
  76. %V%%L%sgn(@z)*(A64-0.5)+0.5
  77. %V%%L%result(A65)
  78.  
  79.  
  80. %V%%L%function("one_tailed_p_to_z","prob:number")
  81. %V%%L%0.5-sgn(0.5-@prob)*(0.5-@prob)
  82. %V%%L%sqr(-2*ln(A70))
  83. %V%%L%A71-(2.30753+0.27061*A71)/(1+A71*(0.99229+0.04481*A71))
  84. %V%%L%A72*sgn(0.5-@prob)
  85. %V%%L%result(A73)
  86.  
  87.  
  88. %V%%L%function("one_tailed_t_to_p","t:number","df:number")
  89. %V%%L%if(abs(@t)<3,@t,@t*(1+0.037*ln(abs(@t))^2.5/(2*@df-1)))
  90. %V%%L%sgn(A78)*(8*@df+1)*sqr(@df*ln(1+A78*A78/@df))/(8*@df+3)
  91. %V%%L%one_tailed_z_to_p(A79)
  92. %V%%L%result(A80)
  93.  
  94.  
  95. %V%%L%function("one_tailed_p_to_t","prob:number","df:number")
  96. %V%%L%one_tailed_p_to_z(@prob)
  97. %V%%L%sgn(A85)*sqr(@df*(exp((A85*(8*@df+3)/(8*@df+1))^2/@df)-1))
  98. %V%%L%if(abs(A86)<3)
  99. %V%%L%     result(A86)
  100. %V%%L%else
  101. %V%%L%     A86/(1+0.05*ln(abs(A86))^2/(2*@df-1))
  102. %V%%L%endif
  103. %V%%L%result(A90)
  104.  
  105.  
  106. %V%%L%function("confidence_limits","range:array","prob:number")
  107. %V%%L%count(@range)-1
  108. %V%%L%string(A96,0)
  109. %V%%L%avg(@range)
  110. %V%%L%sciform(A98,5)
  111. %V%%L%std(@range)/sqr(count(@range))
  112. %V%%L%(100-@prob)/200
  113. %V%%L%one_tailed_p_to_t(A101,A96)
  114. %V%%L%sciform(A102*A100,5)
  115. %V%%L%join(string(@prob,1),"%PC% confidence limits = ",A99," ▒ ",A103," ; degrees of freedom = ",A97)
  116. %V%%L%result(A104)
  117.  
  118.  
  119. %V%%L%function("t_test","range:array","mu:number")
  120. %V%%L%abs(avg(@range)-@mu)/(std(@range)/sqr(count(@range)))
  121. %V%%L%sciform(A109,5)
  122. %V%%L%join("t = ",A110," ; ","degrees of freedom = ",string(count(@range)-1,0))
  123. %V%%L%result(A111)
  124.  
  125.  
  126. %V%%L%function("paired_t_test","range_1:array","range_2:array","mu:number")
  127. %V%%L%count(@range_1)
  128. %V%%L%@range_1-@range_2
  129. %V%%L%abs(avg(A117))
  130. %V%%L%std(A117)
  131. %V%%L%A119/sqr(A116)
  132. %V%%L%(A118-@mu)/A120
  133. %V%%L%join("mean difference = ",sciform(A118,5)," ; t = ",sciform(A121,5)," ; degrees of freedom = ",string(A116-1,0))
  134. %V%%L%result(A122)
  135.  
  136.  
  137. %V%%L%function("F_test","range_1:array","range_2:array")
  138. %V%%L%string(count(@range_1)-1,0)
  139. %V%%L%std(@range_1)
  140. %V%%L%string(count(@range_2)-1,0)
  141. %V%%L%std(@range_2)
  142. %V%%L%if(A128>=A130,join(A127,",",A129),join(A129,",",A127))
  143. %V%%L%if(A128>=A130,(A128/A130)^2,(A130/A128)^2)
  144. %V%%L%join("s1 = ",sciform(A128,5)," (",A127,") ; s2 = ",sciform(A130,5)," (",A129,") ; F(",A131,") = ",sciform(A132,5))
  145. %V%%L%result(A133)
  146.  
  147.  
  148. %V%%L%function("pooled_t_test","range_1:array","range_2:array")
  149. %V%%L%count(@range_1)
  150. %V%%L%avg(@range_1)
  151. %V%%L%std(@range_1)
  152. %V%%L%count(@range_2)
  153. %V%%L%avg(@range_2)
  154. %V%%L%std(@range_2)
  155. %V%%L%sqr(((A138-1)*A140^2+(A141-1)*A143^2)/(A138+A141-2))
  156. %V%%L%sciform(abs((A139-A142)/(A144*sqr(1/A138+1/A141))),5)
  157. %V%%L%join("mean1 = ",sciform(A139,5)," ; mean2 = ",sciform(A142,5)," ; t = ",A145," ; degrees of freedom = ",string(A138+A141-2,0))
  158. %V%%L%result(A146)
  159.  
  160.  
  161. %V%%L%function("linear_regression_y_on_x","range_y:array","range_x:array")
  162. %V%%L%index(linest(@range_y,@range_x),2,1)
  163. %V%%L%sciform(A151,5)
  164. %V%%L%index(linest(@range_y,@range_x),1,1)
  165. %V%%L%sciform(A153,5)
  166. %V%%L%(count(@range_x)*sum(@range_x*@range_y)-sum(@range_x)*sum(@range_y))/(count(@range_x)*(count(@range_x)-1)*std(@range_x)*std(@range_y))
  167. %V%%L%string(A155,4)
  168. %V%%L%join("gradient = ",A152," ; y_intercept = ",A154," ; corr coeff = ",A156)
  169. %V%%L%result(A157)
  170.