//////////////////////////////////////////////////////////////// // // ChiSquareTable.q // //////////////////////////////////////////////////////////////// (Def (ChiSquareTable numin numax ps) //////////////////////////////////////////////////////////////// // Input: // numin = min nu along vertical, e.g. 1 // numax = max nu along vertical, e.g. 100 // ps = probability levels in [0.,1.] along horizontal // e.g. [.9 .95 .975 .99 .995 .999] // Output: // Print a ChiSquare table similar to tables found at // http://www.itl.nist.gov/div898/handbook/eda/section3/eda3674.htm //////////////////////////////////////////////////////////////// (Local p f) (WithPrecision 100 (Write "nu\\p ") (Loop (In p ps) (Do (Write " {0:g-8}" p))) (WriteLine) (Loop (To nu numin numax) (Do (Write "{0:g3} " nu) (Loop (In p ps) (Do (Setq f (ChiSquareQuant nu p)) (Write " {0:g#9}" f))) (WriteLine)))) ) (Def (ChiSquareTableTest) // NIST's Tables //(ChiSquareTable 1 100 [.9 .95 .975 .99 .999]) //(ChiSquareTable 1 100 [.1 .05 .025 .01 .001]) // Our Tables (ChiSquareTable 1 100 [.9 .95 .975 .99 .995 .9975 .999 .9995 .99975 .9999]) (ChiSquareTable 1 100 [.1 .05 .025 .01 .005 .0025 .001 .0005 .00025 .0001]) )