home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / MCAD254.ZIP / STAT / DISTRIB.MCD < prev    next >
Encoding:
Text File  |  1988-11-29  |  6.4 KB  |  238 lines

  1. .MCD 20000 0
  2. .CMD PLOTFORMAT logs=0,0 subdivs=1,1 size=5,15 type=l
  3. .CMD FORMAT  rd=d ct=10 im=i et=3 zt=15 pr=3 mass length time charge
  4. .CMD SET ORIGIN 0
  5. .CMD SET TOL 0.001000
  6. .CMD MARGIN 0
  7. .CMD LINELENGTH 78
  8. .CMD SET PRNCOLWIDTH 8
  9. .CMD SET PRNPRECISION 4
  10. .TXT 0 39 1 39 
  11. a1,38,39,37
  12. Copyright (c) 1988 by MathSoft, Inc.
  13. .TXT 2 -13 1 28 
  14. a1,27,57,26
  15. PROBABILITY DISTRIBUTIONS
  16. .TXT 2 -26 2 80 
  17. a2,79,78,140
  18. This application calculates values for the following cumulative distribution 
  19. functions.  The function and variable names are listed below.
  20. .TXT 3 25 5 22 
  21. a5,21,63,58
  22. Normal
  23. Chi-square
  24. Student's t
  25. F (variance ratio)
  26. Beta
  27. .TXT 6 -23 1 68 
  28. a1,67,76,66
  29. cnorm(x)           Normal distribution with mean 0 and variance 1
  30. .TXT 2 0 1 71 
  31. a1,70,75,69
  32. Pchi(chi2,v)       Chi-square distribution with v degrees of freedom
  33. .TXT 2 0 1 72 
  34. a1,71,76,70
  35. PA(t,v)            Student's t distribution with v degrees of freedom
  36. .TXT 2 0 1 70 
  37. a1,69,76,68
  38. PF(F,v1,v2)        F distribution with degrees of freedom v1 and v2
  39. .TXT 2 0 1 73 
  40. a1,72,76,71
  41. PB(x,v1,v2)        Beta distribution with degrees of freedom v1 and v2
  42. .TXT 2 0 1 15 
  43. a1,14,76,13
  44. [Ctrl][PgDn]
  45. .TXT 2 0 2 77 
  46. a2,76,76,139
  47. It is sometimes convenient to work with the complementary function giving 
  48. the tail of the distribution.  The complementary functions are:
  49. .TXT 3 0 1 71 
  50. a1,70,76,69
  51. Qnorm(x)           The complement or tail of the normal distribution
  52. .TXT 2 0 1 67 
  53. a1,66,76,65
  54. Qchi(chi2,v)       The complement of the chi-square distribution
  55. .TXT 2 0 1 58 
  56. a1,57,76,56
  57. QA(t,v)            The complement of the t distribution
  58. .TXT 2 0 1 59 
  59. a1,58,77,57
  60. QF(F,v1,v2)        The complement of the F distribution 
  61. .TXT 2 0 1 61 
  62. a1,60,76,59
  63. QB(F,v1,v2)        The complement of the beta distribution
  64. .TXT 2 0 2 79 
  65. a2,78,76,155
  66. These function definitions and the calculation routines follow Section 26 in 
  67. "Handbook of Mathematical Functions," by Abramowitz and Stegun, Dover, 1965.
  68. .TXT 4 -1 1 15 
  69. a1,14,76,13
  70. [Ctrl][PgDn]
  71. .TXT 2 0 1 77 
  72. a1,76,77,75
  73. You can use these definitions in place of tables.  Here are some examples:
  74. .TXT 2 0 1 46 
  75. a1,45,77,44
  76. Chi-square at 5.6 for 7 degrees of freedom:
  77. .EQN 0 51 1 19 
  78. Pchi(5.6,7)=?
  79. .TXT 2 -51 1 47 
  80. a1,46,77,45
  81. Student's t at 2.5 for 2 degrees of freedom:
  82. .EQN 0 53 1 17 
  83. PA(2.5,2)=?
  84. .TXT 2 -53 1 45 
  85. a1,44,78,43
  86. Beta at .3 for 6 and 8 degrees of freedom:
  87. .EQN 0 52 1 18 
  88. PB(.3,6,8)=?
  89. .TXT 2 -52 2 40 
  90. a2,39,40,52
  91. The probability of a standard normal 
  92. value > 1.5: 
  93. .EQN 0 52 1 18 
  94. Qnorm(1.5)=?
  95. .TXT 3 -52 2 40 
  96. a2,39,40,70
  97. The probability of t values > 2 when 
  98. there are 5 degrees of freedom:
  99. .EQN 0 55 1 15 
  100. QA(2,5)=?
  101. .TXT 3 -55 2 42 
  102. a2,41,40,78
  103. The probability of an F value > 2 when 
  104. there are 3 and 5 degrees of freedom:
  105. .EQN 0 53 1 21 
  106. QF(2,3,5)=?
  107. .TXT 3 -53 1 15 
  108. a1,14,77,13
  109. [Ctrl][PgDn]
  110. .TXT 1 0 5 80 
  111. a5,79,77,343
  112. Use the root function to find approximate α percentage points, that is, 
  113. values x such that the probability of a larger value is α.  The root function 
  114. requires an initial guess: for chi-square with df degrees of freedom use df 
  115. or 1.5df; when df = 1, use .5.  For t and F use 1.  With TOL = .00001 the 
  116. results are usually correct within 1%.
  117. .EQN 6 0 1 14 
  118. TOL~.00001
  119. .TXT 1 0 1 54 
  120. a1,53,77,52
  121. .1 point for Chi-square with 10 degrees of freedom:
  122. .EQN 2 15 1 8 
  123. x~10
  124. .EQN 0 26 1 35 
  125. root(Qchi(x,10)-.1,x)={18994}?
  126. .TXT 2 -41 1 63 
  127. a1,62,77,61
  128. .005 point for the t distribution with 2 degrees of freedom:
  129. .EQN 2 15 1 7 
  130. x~1
  131. .EQN 0 27 1 33 
  132. root(QA(x,2)-.005,x)={18994}?
  133. .TXT 2 -42 1 51 
  134. a1,50,77,49
  135. .05 point for F with degrees of freedom 2 and 5:
  136. .EQN 2 15 1 7 
  137. x~1
  138. .EQN 0 26 1 34 
  139. root(QF(x,2,5)-.05,x)={19010}?
  140. .TXT 1 -41 1 15 
  141. a1,14,77,13
  142. [Ctrl][PgDn]
  143. .TXT 2 0 1 58 
  144. a1,57,77,56
  145. The following screens contain the function definitions.
  146. .TXT 2 1 1 22 
  147. a1,21,75,20
  148. NORMAL DISTRIBUTION
  149. .TXT 2 0 1 40 
  150. a1,39,76,38
  151. cnorm is a built-in MathCAD function.
  152. .EQN 2 0 1 25 
  153. Qnorm(x)~1-cnorm(x)
  154. .TXT 5 -1 1 16 
  155. a1,15,76,14
  156. BETA FUNCTION
  157. .EQN 2 3 3 20 
  158. ß(a,b)~(Γ(a)*Γ(b))/Γ(a+b)
  159. .TXT 5 -3 1 26 
  160. a1,25,78,24
  161. CHI SQUARE DISTRIBUTION
  162. .TXT 2 0 1 45 
  163. a1,44,78,43
  164. Series approximations, good for small chi:
  165. .EQN 2 0 1 22 
  166. Pchi_index_~1;10
  167. .EQN 0 28 1 31 
  168. altneg(n)~if(mod(n,2),-1,1)
  169. .EQN 1 -29 10 81 
  170. Pchi_s(chi2,v)~(chi2/2)^(v/2)/Γ(v/2)*(2/v+Pchi_index_$(altneg(Pchi_index_)*(chi2/2)^Pchi_index_)/(Pchi_index_!*(v/2+Pchi_index_)))
  171. .TXT 14 0 1 60 
  172. a1,59,78,58
  173. Integral approximations, workable for high values of chi:
  174. .EQN 2 0 9 49 
  175. Pchi_i(chi2,v)~1/(2^(v/2)*Γ(v/2))*(2&chi2`t^(v/2-1)*exp(-t/2)&t)
  176. .EQN 14 0 1 73 
  177. Pchi(chi2,v)~if(chi2<2,Pchi_s(chi2,v),Pchi_s(2,v)+Pchi_i(chi2,v))
  178. .EQN 2 0 1 33 
  179. Qchi(chi2,v)~1-Pchi(chi2,v)
  180. .TXT 3 0 1 77 
  181. a1,76,78,75
  182. THE INCOMPLETE BETA FUNCTION   (used in defining Student's t, F, and beta)
  183. .TXT 2 0 1 26 
  184. a1,25,78,24
  185. Fundamental definition:
  186. .EQN 2 0 3 52 
  187. Iß_integral(x,a,b)~1/ß(a,b)*(0&x`t^(a-1)*(1-t)^(b-1)&t)
  188. .TXT 4 0 1 37 
  189. a1,36,78,35
  190. Practical transformation of above:
  191. .EQN 2 1 1 9 
  192. ε~.01
  193. .EQN 1 -1 4 27 
  194. Ißint1(x,a,b)~1/ß(a,b)*x^a/a
  195. .EQN 6 0 4 54 
  196. Ißint2(x,a,b)~1/ß(a,b)*(ε^a/a+(ε&x`t^(a-1)*(1-t)^(b-1)&t))
  197. .EQN 6 0 4 74 
  198. Ißint3(x,a,b)~1/ß(a,b)*((ε^b-(1-x)^b)/b+ε^a/a+(ε&1-ε`t^(a-1)*(1-t)^(b-1)&t))
  199. .EQN 6 0 1 80 
  200. Ißi(x,a,b)~if(x<ε,Ißint1(x,a,b),if(x<1-ε,Ißint2(x,a,b),Ißint3(x,a,b)))
  201. .TXT 7 0 1 44 
  202. a1,43,78,42
  203. Approximation accurate when a+b is large:
  204. .EQN 2 0 11 157 
  205. Ißs(x,a,b)~if((((a+b-1)*(1-x))≤0.8),Qchi((a+b-1)*(1-x)*(3-x)-(1-x)*(b-1),2*b),cnorm(3*(((b*x)^(1/3)*(1-1/(9*b))-(a*(1-x))^(1/3)*(1-1
  206. /(9*a)))/\(b^(-1/3)*x^(2/3)+a^(-1/3)*(1-x)^(2/3)))))
  207. .TXT 12 0 1 69 
  208. a1,68,78,67
  209. Use symmetry transformation, for better speed and higher accuracy:
  210. .EQN 2 0 1 67 
  211. Iß_series_flip(x,a,b)~if(x>0.5,Ißs(x,a,b),1-Ißs(1-x,b,a))
  212. .TXT 3 0 1 30 
  213. a1,29,78,28
  214. Define the master function.
  215. .EQN 2 0 1 62 
  216. Iß(x,a,b)~if((a+b≤6),Ißi(x,a,b),Iß_series_flip(x,a,b))
  217. .TXT 5 0 1 27 
  218. a1,26,78,25
  219. STUDENT'S t DISTRIBUTION
  220. .EQN 1 0 4 55 
  221. QA(t,v)~(t<0)+if(t<0,-1,1)*(1/2)*Iß(v/(v+t^2),v/2,1/2)
  222. .EQN 4 0 1 23 
  223. PA(t,v)~1-QA(t,v)
  224. .TXT 2 0 1 43 
  225. a1,42,78,41
  226. F (VARIANCE RATIO) DISTRIBUTION FUNCTION
  227. .EQN 2 0 3 35 
  228. QF(F,v1,v2)~Iß(v2/(v2+v1*F),v2/2,v1/2)
  229. .EQN 4 0 1 31 
  230. PF(F,v1,v2)~1-QF(F,v1,v2)
  231. .TXT 2 0 1 29 
  232. a1,28,78,27
  233. BETA DISTRIBUTION FUNCTION
  234. .EQN 2 0 3 27 
  235. PB(x,v1,v2)~Iß(x,v1/2,v2/2)
  236. .EQN 4 0 1 31 
  237. QB(x,v1,v2)~1-PB(x,v1,v2)
  238.