home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1995-05-27 | 2.0 KB | [ TEXT/CWIE]
open in: MacOS 8.1
extracted
|
Win98
extracted
|
DOS
extracted
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary ).
You can browse this item here: ChiSquare.c
Confidence Program Detection Match Type Support
66%
dexvert
Compact Compressed (Unix) (archive/compact)
ext
Supported
10%
dexvert
MacBinary (archive/macBinary)
fallback
Supported
1%
dexvert
Text File (text/txt)
fallback
Supported
100%
file
MacBinary II, inited, Sat May 27 14:46:39 1995, modified Sat May 27 14:46:39 1995, creator 'CWIE', type ASCII, 1362 bytes "ChiSquare.c" , at 0x5d2 494 bytes resource
default (weak)
99%
file
data
default
74%
TrID
Macintosh plain text (MacBinary)
default
25%
TrID
MacBinary 2
default (weak)
100%
siegfried
fmt/1762 MacBinary (II)
default
100%
lsar
MacBinary
default
id metadata key value macFileType [ TEXT] macFileCreator [ CWIE]
hex view +--------+-------------------------+-------------------------+--------+--------+ |00000000| 00 0b 43 68 69 53 71 75 | 61 72 65 2e 63 00 00 00 |..ChiSqu|are.c...| |00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000040| 00 54 45 58 54 43 57 49 | 45 01 00 00 00 00 00 00 |.TEXTCWI|E.......| |00000050| 00 00 00 00 00 05 52 00 | 00 01 ee ab ed 24 0f ab |......R.|.....$..| |00000060| ed 24 0f 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.$......|........| |00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 d1 60 00 00 |........|.....`..| |00000080| 2f 2a 0d 43 68 69 53 71 | 75 61 72 65 2e 63 0d 43 |/*.ChiSq|uare.c.C| |00000090| 6f 70 79 72 69 67 68 74 | 20 31 39 39 30 2d 31 39 |opyright| 1990-19| |000000a0| 39 32 20 a9 20 44 65 6e | 69 73 20 47 2e 20 50 65 |92 . Den|is G. Pe| |000000b0| 6c 6c 69 0d 50 43 68 69 | 53 71 75 61 72 65 28 29 |lli.PChi|Square()| |000000c0| 20 63 61 6c 63 75 6c 61 | 74 65 73 20 74 68 65 20 | calcula|tes the | |000000d0| 73 69 67 6e 69 66 69 63 | 61 6e 63 65 20 6c 65 76 |signific|ance lev| |000000e0| 65 6c 20 61 74 20 77 68 | 69 63 68 20 61 20 66 69 |el at wh|ich a fi| |000000f0| 74 20 6d 61 79 20 62 65 | 20 72 65 6a 65 63 74 65 |t may be| rejecte| |00000100| 64 2e 0d 0d 41 6c 73 6f | 20 73 65 65 3a 20 42 69 |d...Also| see: Bi| |00000110| 6e 6f 6d 69 61 6c 2e 63 | 2c 20 45 78 70 6f 6e 65 |nomial.c|, Expone| |00000120| 6e 74 69 61 6c 2e 63 2c | 20 4e 6f 72 6d 61 6c 2e |ntial.c,| Normal.| |00000130| 63 2c 20 55 6e 69 66 6f | 72 6d 2e 63 0d 0d 48 49 |c, Unifo|rm.c..HI| |00000140| 53 54 4f 52 59 3a 0d 31 | 2f 37 2f 38 34 09 64 67 |STORY:.1|/7/84.dg| |00000150| 70 09 77 72 6f 74 65 20 | 69 74 20 69 6e 20 46 4f |p.wrote |it in FO| |00000160| 52 54 52 41 4e 0d 38 2f | 39 2f 38 39 09 64 67 70 |RTRAN.8/|9/89.dgp| |00000170| 09 74 72 61 6e 73 6c 61 | 74 65 64 20 69 74 20 74 |.transla|ted it t| |00000180| 6f 20 43 0d 34 2f 35 2f | 39 30 09 64 67 70 09 74 |o C.4/5/|90.dgp.t| |00000190| 65 73 74 65 64 20 69 74 | 20 61 67 61 69 6e 73 74 |ested it| against| |000001a0| 20 74 61 62 6c 65 73 20 | 69 6e 20 41 62 72 61 6d | tables |in Abram| |000001b0| 6f 77 69 74 7a 20 69 6e | 20 53 74 65 67 75 6e 2e |owitz in| Stegun.| |000001c0| 20 57 6f 72 6b 73 20 66 | 69 6e 65 2e 0d 34 2f 38 | Works f|ine..4/8| |000001d0| 2f 39 30 09 64 67 70 09 | 72 65 6e 61 6d 65 64 20 |/90.dgp.|renamed | |000001e0| 66 69 6c 65 20 43 68 69 | 53 71 75 61 72 65 2e 63 |file Chi|Square.c| |000001f0| 20 66 72 6f 6d 20 50 43 | 68 69 53 71 75 61 72 65 | from PC|hiSquare| |00000200| 2e 63 0d 37 2f 33 30 2f | 39 31 09 64 67 70 09 6e |.c.7/30/|91.dgp.n| |00000210| 6f 77 20 75 73 65 20 4e | 41 4e 20 64 65 66 69 6e |ow use N|AN defin| |00000220| 65 64 20 69 6e 20 56 69 | 64 65 6f 54 6f 6f 6c 62 |ed in Vi|deoToolb| |00000230| 6f 78 2e 68 0d 31 2f 31 | 32 2f 39 32 09 64 67 70 |ox.h.1/1|2/92.dgp| |00000240| 09 52 65 6e 61 6d 65 64 | 20 4e 6f 72 6d 61 6c 50 |.Renamed| NormalP| |00000250| 44 46 28 29 20 74 6f 20 | 4e 6f 72 6d 61 6c 50 64 |DF() to |NormalPd| |00000260| 66 28 29 2e 0d 2a 2f 0d | 23 69 6e 63 6c 75 64 65 |f()..*/.|#include| |00000270| 20 22 56 69 64 65 6f 54 | 6f 6f 6c 62 6f 78 2e 68 | "VideoT|oolbox.h| |00000280| 22 0d 0d 64 6f 75 62 6c | 65 20 50 43 68 69 53 71 |"..doubl|e PChiSq| |00000290| 75 61 72 65 20 28 64 6f | 75 62 6c 65 20 63 68 69 |uare (do|uble chi| |000002a0| 53 71 75 61 72 65 2c 69 | 6e 74 20 6e 29 0d 2f 2a |Square,i|nt n)./*| |000002b0| 0d 52 65 74 75 72 6e 73 | 20 6f 6e 65 20 6d 69 6e |.Returns| one min| |000002c0| 75 73 20 74 68 65 20 63 | 75 6d 75 6c 61 74 69 76 |us the c|umulativ| |000002d0| 65 20 70 72 6f 62 61 62 | 69 6c 69 74 79 20 6f 66 |e probab|ility of| |000002e0| 20 74 68 65 0d 43 68 69 | 2d 53 71 75 61 72 65 20 | the.Chi|-Square | |000002f0| 64 69 73 74 72 69 62 75 | 74 69 6f 6e 20 66 6f 72 |distribu|tion for| |00000300| 20 76 61 6c 75 65 20 63 | 68 69 73 71 20 77 69 74 | value c|hisq wit| |00000310| 68 20 6e 20 64 65 67 72 | 65 65 73 20 6f 66 20 66 |h n degr|ees of f| |00000320| 72 65 65 64 6f 6d 2e 0d | 54 68 65 20 66 6f 72 6d |reedom..|The form| |00000330| 75 6c 61 20 69 73 20 66 | 72 6f 6d 20 41 62 72 61 |ula is f|rom Abra| |00000340| 6d 6f 77 69 74 7a 20 61 | 6e 64 20 53 74 65 67 75 |mowitz a|nd Stegu| |00000350| 6e 2c 20 45 71 73 2e 20 | 32 36 2e 34 2e 34 20 61 |n, Eqs. |26.4.4 a| |00000360| 6e 64 20 32 36 2e 34 2e | 35 2c 20 70 67 20 39 34 |nd 26.4.|5, pg 94| |00000370| 31 2e 0d 54 68 65 20 66 | 6f 72 6d 75 6c 61 20 69 |1..The f|ormula i| |00000380| 73 20 65 78 61 63 74 2e | 0d 52 61 6e 67 65 3a 20 |s exact.|.Range: | |00000390| 63 68 69 73 71 3e 3d 30 | 2e 30 2c 20 6e 3e 3d 30 |chisq>=0|.0, n>=0| |000003a0| 2c 0d 52 65 74 75 72 6e | 73 20 7a 65 72 6f 20 69 |,.Return|s zero i| |000003b0| 66 20 6e 20 69 73 20 7a | 65 72 6f 2e 0d 0d 4d 2e |f n is z|ero...M.| |000003c0| 20 41 62 72 61 6d 6f 77 | 69 74 7a 20 61 6e 64 20 | Abramow|itz and | |000003d0| 49 2e 41 2e 20 53 74 65 | 67 75 6e 20 28 31 39 36 |I.A. Ste|gun (196| |000003e0| 34 29 20 48 61 6e 64 62 | 6f 6f 6b 20 6f 66 20 6d |4) Handb|ook of m| |000003f0| 61 74 68 65 6d 61 74 69 | 63 61 6c 20 66 75 6e 63 |athemati|cal func| |00000400| 74 69 6f 6e 73 2e 20 44 | 6f 76 65 72 2e 0d 2a 2f |tions. D|over..*/| |00000410| 0d 7b 0d 09 64 6f 75 62 | 6c 65 20 78 2c 61 2c 50 |.{..doub|le x,a,P| |00000420| 3b 0d 09 69 6e 74 20 69 | 2c 69 69 3b 0d 09 0d 09 |;..int i|,ii;....| |00000430| 69 66 28 63 68 69 53 71 | 75 61 72 65 3c 30 2e 30 |if(chiSq|uare<0.0| |00000440| 20 7c 7c 20 6e 3c 30 29 | 20 72 65 74 75 72 6e 20 | || n<0)| return | |00000450| 4e 41 4e 3b 09 2f 2a 20 | 72 65 74 75 72 6e 20 4e |NAN;./* |return N| |00000460| 41 4e 20 74 6f 20 73 69 | 67 6e 61 6c 20 65 72 72 |AN to si|gnal err| |00000470| 6f 72 20 2a 2f 0d 09 78 | 20 3d 20 73 71 72 74 28 |or */..x| = sqrt(| |00000480| 63 68 69 53 71 75 61 72 | 65 29 3b 0d 09 69 66 28 |chiSquar|e);..if(| |00000490| 6e 25 32 20 21 3d 20 30 | 29 20 7b 0d 09 09 2f 2a |n%2 != 0|) {.../*| |000004a0| 20 6e 20 69 73 20 6f 64 | 64 20 2a 2f 0d 09 09 50 | n is od|d */...P| |000004b0| 20 3d 20 32 2e 30 2a 4e | 6f 72 6d 61 6c 28 2d 78 | = 2.0*N|ormal(-x| |000004c0| 29 3b 0d 09 09 61 20 3d | 20 32 2e 30 2a 4e 6f 72 |);...a =| 2.0*Nor| |000004d0| 6d 61 6c 50 64 66 28 78 | 29 2a 78 3b 0d 09 09 69 |malPdf(x|)*x;...i| |000004e0| 69 20 3d 20 28 6e 2d 31 | 29 2f 32 3b 0d 09 09 66 |i = (n-1|)/2;...f| |000004f0| 6f 72 28 69 3d 31 3b 69 | 3c 3d 69 69 3b 69 2b 2b |or(i=1;i|<=ii;i++| |00000500| 29 7b 0d 09 09 09 50 20 | 2b 3d 20 61 3b 0d 09 09 |){....P |+= a;...| |00000510| 09 61 20 2a 3d 20 63 68 | 69 53 71 75 61 72 65 2f |.a *= ch|iSquare/| |00000520| 28 32 2a 69 2b 31 29 3b | 0d 09 09 7d 0d 09 7d 0d |(2*i+1);|...}..}.| |00000530| 09 65 6c 73 65 20 7b 0d | 09 09 2f 2a 20 6e 20 69 |.else {.|../* n i| |00000540| 73 20 65 76 65 6e 20 2a | 2f 0d 09 09 50 20 3d 20 |s even *|/...P = | |00000550| 30 2e 30 3b 0d 09 09 61 | 20 3d 20 73 71 72 74 28 |0.0;...a| = sqrt(| |00000560| 32 2e 30 2a 50 49 29 2a | 4e 6f 72 6d 61 6c 50 64 |2.0*PI)*|NormalPd| |00000570| 66 28 78 29 3b 0d 09 09 | 69 69 20 3d 20 6e 2f 32 |f(x);...|ii = n/2| |00000580| 3b 0d 09 09 66 6f 72 28 | 20 69 3d 31 3b 69 3c 3d |;...for(| i=1;i<=| |00000590| 69 69 3b 69 2b 2b 29 7b | 0d 09 09 09 50 20 2b 3d |ii;i++){|....P +=| |000005a0| 20 61 3b 0d 09 09 09 61 | 20 2a 3d 20 63 68 69 53 | a;....a| *= chiS| |000005b0| 71 75 61 72 65 2f 28 32 | 2a 69 29 3b 0d 09 09 7d |quare/(2|*i);...}| |000005c0| 0d 09 7d 0d 09 72 65 74 | 75 72 6e 20 50 3b 0d 7d |..}..ret|urn P;.}| |000005d0| 0d 0d 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |000005e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |000005f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000600| 00 00 01 00 00 00 01 90 | 00 00 00 90 00 00 00 5e |........|.......^| |00000610| 6f 70 79 72 69 67 68 74 | 20 31 39 39 30 20 a9 20 |opyright| 1990 . | |00000620| 44 65 6e 69 73 20 47 2e | 20 50 65 6c 6c 69 0d 50 |Denis G.| Pelli.P| |00000630| 0b 43 68 69 53 71 75 61 | 72 65 2e 63 02 00 00 00 |.ChiSqua|re.c....| |00000640| 54 45 58 54 43 57 49 45 | 01 00 00 14 00 c0 00 00 |TEXTCWIE|........| |00000650| 00 00 54 45 58 54 43 57 | 49 45 01 00 00 14 00 c0 |..TEXTCW|IE......| |00000660| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000670| 00 00 a2 45 51 ef 00 00 | 05 52 00 00 01 ee 0d 48 |...EQ...|.R.....H| |00000680| 49 53 54 4f 52 59 3a 0d | 31 2f 37 2f 38 34 09 64 |ISTORY:.|1/7/84.d| |00000690| 67 70 09 77 72 6f 74 65 | 20 69 74 20 69 6e 20 46 |gp.wrote| it in F| |000006a0| 4f 52 54 52 41 4e 0d 38 | 2f 39 2f 38 39 09 64 67 |ORTRAN.8|/9/89.dg| |000006b0| 70 09 74 72 61 6e 73 6c | 61 74 65 64 20 69 74 20 |p.transl|ated it | |000006c0| 74 6f 20 43 0d 34 2f 35 | 2f 39 30 09 64 67 70 09 |to C.4/5|/90.dgp.| |000006d0| 74 65 73 74 65 64 20 69 | 74 20 61 67 61 69 6e 73 |tested i|t agains| |000006e0| 74 20 74 61 62 6c 65 73 | 20 69 6e 20 41 62 72 61 |t tables| in Abra| |000006f0| 6d 6f 77 69 74 7a 20 69 | 6e 20 53 74 65 67 75 6e |mowitz i|n Stegun| |00000700| 00 00 00 1e 00 50 00 20 | 01 dd 02 3d 00 50 00 20 |.....P. |...=.P. | |00000710| 01 dd 02 3d 00 00 00 7f | 00 00 00 00 00 00 00 00 |...=....|........| |00000720| 00 00 00 00 00 16 00 01 | 00 00 02 1c 00 00 02 26 |........|.......&| |00000730| 0b 50 43 68 69 53 71 75 | 61 72 65 00 00 00 00 48 |.PChiSqu|are....H| |00000740| 00 09 4d 6f 6e 61 63 6f | 00 00 00 00 00 00 00 00 |..Monaco|........| |00000750| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000760| 00 00 00 03 00 04 00 3d | 00 03 01 a0 02 7d 00 3d |.......=|.....}.=| |00000770| 00 03 01 a0 02 7d ab ec | ec 32 00 00 02 02 00 00 |.....}..|.2......| |00000780| 02 02 00 00 00 00 00 00 | 00 00 00 04 00 01 00 01 |........|........| |00000790| 00 00 01 00 00 00 01 90 | 00 00 00 90 00 00 00 5e |........|.......^| |000007a0| 00 93 d4 b8 13 78 00 00 | 00 1c 00 5e 00 01 4d 50 |.....x..|...^..MP| |000007b0| 53 52 00 02 00 12 4d 57 | 42 42 00 00 00 36 03 f0 |SR....MW|BB...6..| |000007c0| ff ff 00 00 00 00 00 00 | 00 00 03 ef ff ff 00 00 |........|........| |000007d0| 00 22 00 00 00 00 03 ed | ff ff 00 00 00 3c 00 00 |."......|.....<..| |000007e0| 00 00 03 f0 ff ff 00 00 | 00 88 00 00 00 00 00 00 |........|........| |000007f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| +--------+-------------------------+-------------------------+--------+--------+