%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:5270
File Name:KHI2
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Norm





\ClrText
""
""
\Locate 2,2,"risque \@F9@"
""
" "?\->I





' choix de calcul \@24
\ClrText
"    test khi sur"
""
" 1 rep et H0  \->  [1]"
""
" +s rep obs   \->  [2]"

\Do
\Getkey\->K
K=62\=>\Goto1
\LpWhile K\<>72







' creation matrice \@24
\ClrText
"     matrice"
""
"nombre variables \@F9O "?\->P
{4,P+1}\->\Dim \Mat A



\@F9\nPrI,P-1)\->S



' repartition de pie \@24
\For 1\->X \To P
\ClrText
"\@F9OH0 "
\Locate 5,1,X
?\->\Mat A[1,X]
\Next 






' verification total = 1 \@24
\For 1\->X \To P
\Mat A[1,P+1]+\Mat A[1,X]\->\Mat A[1,P+1]
\Next 

\If \Mat A[1,P+1]\<>1
\Then 
\ClrText
\Orange \Locate 2,2,"total \<>1 \!mark\!mark"
\Orange \Locate 2,4,\Mat A[1,P+1]
\Do:\LpWhile \Getkey\<>31
\Stop
\IfEnd





' effectifs observes \@24
\For 1\->X \To P
\ClrText
"eff obs "
\Locate 9,1,X
?\->\Mat A[2,X]
\Next 




' total effectifs observes \@24
\ClrText
\Locate 2,2,"total:"
\For 1\->X \To P
\Mat A[2,P+1]+\Mat A[2,X]\->\Mat A[2,P+1]
\Next 
\Locate 9,2,\Mat A[2,P+1]

\Do:\LpWhile \Getkey\<>31








'calcul effectifs calcules Ci the\oriques \@24
\For 1\->X \To P
\ClrText
" eff calacul\@F9\Petas"
"  th\@F9\Peta\oriques Ci"
\Locate 18,2,X
\Mat A[1,X]*\Mat A[2,P+1]\->\Mat A[3,X]
\Locate 3,4,\Mat A[3,X]
\Do:\LpWhile \Getkey\<>31
\Next 

\Do:\LpWhile \Getkey\<>31






'verification Oi = Ci \@24
\For 1\->X \To P
\Mat A[3,P+1]+\Mat A[3,X]\->\Mat A[3,P+1]
\Next 

\If \Mat A[2,P+1]\<>\Mat A[3,P+1]
\Then 
\ClrText
\Orange \Locate 2,2,"total Oi\<>Ci \!mark\!mark"
\Orange \Locate 2,4,\Mat A[3,P+1]
\Do:\LpWhile \Getkey\<>31
\IfEnd





' calcul des ecarts \@24
\For 1\->X \To P
\ClrText
" ecart"
\Locate 8,1,X
\Mat A[2,X]-\Mat A[3,X]\->\Mat A[4,X]
\Locate 3,3,\Mat A[4,X]
\Do:\LpWhile \Getkey\<>31
\Next 




'verification difference = 0 \@24
\For 1\->X \To P
\Mat A[4,P+1]+\Mat A[4,X]\->\Mat A[4,P+1]
\Next 

\If \Mat A[4,P+1]\<>0
\Then 
\ClrText
\Orange \Locate 2,2,"total diff \<>0 \!mark\!mark"
\Orange \Locate 2,4,\Mat A[4,P+1]
\Do:\LpWhile \Getkey\<>31
\IfEnd

\Do:\LpWhile \Getkey\<>31





' calcul du khi2 \@24
\ClrText
""
"\@F9V\x^2= \@F9Q((Oi-Ci)\x^2 / Ci)"

\For 1\->X \To P
\Mat A[4,P+1]+(\Mat A[4,X])\x^2/\Mat A[3,X]\->\Mat A[4,P+1]
\Next 

""
"\@F9V\x^2:"
\Blue \Locate 5,4,\Mat A[4,P+1]

\Do:\LpWhile \Getkey\<>31


\ClrText
\@F9\(-)\Mat A[4,P+1],9\EE99,X-1)\->R

\Locate 2,1,"DDL:"
\Locate 7,1,X-1
\Locate 1,3,"\->table \@F9V\x^2\@F9@:"
\Locate 2,5,"P:"

\Blue \Locate 4,5,R

\Fix 3
\Blue \Locate 13,3,S

\Fix 2
\Orange \Locate 4,7,100*R
\Orange \Locate 10,7,"\@F799"

\Do:\LpWhile \Getkey\<>31




'analyse \@24

\Fix 3

\ClrText
\If \Mat A[4,P+1]\>=S
\Then 
\Orange \Locate 2,1,"\<> significative"
\Locate 5,3,"\@F9V\x^2 \>= \@F9V\x^2\@F9@"
\Orange \Locate 2,5,\Mat A[4,P+1]
\Locate 10,5,">"
\Orange \Locate 12,5,S
\Locate 2,7,"\@F9\femto P:"
\Locate 7,7,R
\Else 
\Blue \Locate 7,2,"\<> NS"
\Locate 5,4,"\@F9V\x^2 < \@F9V\x^2\@F9@"
\Blue \Locate 2,6,\Mat A[4,P+1]
\Locate 10,6,"<"
\Blue \Locate 12,6,S
\IfEnd


\Do:\LpWhile \Getkey\<>31

\@F9\@26\Mat A[4,P+1],9\EE99,X-1\Disp
\Stop



'\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24



' choix 2: comparer 2 repartitions \@24

\Lbl 1



' creation matrice \@24
\ClrText
"     matrice"
""
"nombre variables \@F9O "?\->P
"Nombre lignes"?\->L
{L*2+1,P+2}\->\Dim \Mat A



\@F9\nPrI,(P-1)*(L-1))\->S



' entree des effectifs \@24

0\->D
\For 1\->Y \To L
\For 1\->X \To P


\ClrText
""
""
\Locate 2,2,"eff rep  ,"
\Locate 10,2,Y
\Locate 13,2,"\@F9O"
\Locate 15,2,X
""
?\->\Mat A[D+Y,X]
\Next 

D+1\->D

\Next 







' Calculs \@24

' total des effectifs de chaque lignes (chaque Y) \@24

0\->D
\For 1\->Y \To L
\For 1\->X \To P

\Mat A[D+Y,P+1]+\Mat A[D+Y,X]\->\Mat A[D+Y,P+1]
\Next 

D+1\->D

\Next 





' total des effectifs de chaque colonne (chaque pie) \@24

\For 1\->X \To P
\For 1\->Y \To L*2 \Step 2

\Mat A[L*2+1,X]+\Mat A[Y,X]\->\Mat A[L*2+1,X]

\Next 
\Next 






' total general des effectifs par la derniere ligne \@24
'= somme des effectifs de chaque pie \@24
' calcule a l'h\orizontal le total de la derniere ligne Y*2+1 \@24

\For 1\->X \To P
\Mat A[L*2+1,P+1]+\Mat A[L*2+1,X]\->\Mat A[L*2+1,P+1]
\Next 






' total general des effectifs par la derniere colonne \@24
' = somme des effectifs de chaque repartition \@24
' calcule a la verticale le total de la derniere colonne P+2 \@24

\For 1\->Y \To L*2 \Step 2
\Mat A[L*2+1,P+2]+\Mat A[Y,P+1]\->\Mat A[L*2+1,P+2]
\Next 



' verification somme colonne = somme ligne \@24
' ca sert seulement a verifier que le programme est bon \@24
' et aussi en cas de modif manuelle de la matrice (arrondis) \@24

\If \Mat A[L*2+1,P+1]\<>\Mat A[L*2+1,P+2]
\Then 
\ClrText
\Orange \Locate 1,2,"total effectif \<> \!mark\!mark"
\Orange \Locate 2,4,\Mat A[L*2+1,P+1]
\Orange \Locate 2,6,\Mat A[L*2+1,P+2]
\Do:\LpWhile \Getkey\<>31
\IfEnd






' calcul effectifs the\oriques dans chaque case \@24 
' commence en haut a G, fini en bas a D \@24

\For 1\->Y \To L*2 \Step 2
\For 1\->X \To P
(\Mat A[L*2+1,X]*\Mat A[Y,P+1])/\Mat A[L*2+1,P+1]\->\Mat A[Y+1,X]
\Next 
\Next 






' calcul de la somme des effectifs the\oriques par ligne \@24

\For 1\->Y \To L*2 \Step 2
\For 1\->X \To P
\Mat A[Y+1,P+1]+\Mat A[Y+1,X]\->\Mat A[Y+1,P+1]
\Next 
\Next 





' total genral des effectifs the\oriques \@24
' = somme par la dernierere colonne P+1 \@24

\For 1\->Y \To L*2 \Step 2
\Mat A[L*2,P+2]+\Mat A[Y+1,P+1]\->\Mat A[L*2,P+2]
\Next 







' verication general the\orique = general observe \@24
' si ok, le programme est bon \@24
\If \Mat A[L*2,P+2]\<>\Mat A[L*2+1,P+2]
\Then 
\ClrText
\Orange \Locate 1,2,"the\orique \<> obs m1\!mark\!mark"
\Orange \Locate 2,4,\Mat A[L*2,P+2]
\Orange \Locate 2,6,\Mat A[L*2+1,P+2]
\Do:\LpWhile \Getkey\<>31
\IfEnd







' affichage des resultats \@24

'affichage total des effectifs observes par ligne \@24
0\->D
\For 1\->Y \To L
\ClrText
""
"  total"
"  ligne   :"
\Locate 9,3,Y
\Blue \Locate 13,3,\Mat A[D+Y,X+1]
\Do:\LpWhile \Getkey\<>31
D+1\->D
\Next 







'affichage total des effectifs par colones \@24
\For 1\->X \To P
\ClrText
""
"  total"
"  colone   :"
\Locate 10,3,X
\Orange \Locate 14,3,\Mat A[L*2+1,X]
\Do:\LpWhile \Getkey\<>31
\Next 






'affichage total general \@24
\ClrText
""
" total"
" general:"
\@F9\@9D\Locate 11,3,\Mat A[L*2+1,P+1]
\Do:\LpWhile \Getkey\<>31







'affichage effectifs calcules Ci the\oriques \@24
' du haut a gauche vers le bas a droite \@24
0\->D
\For 1\->Y \To L
\For 1\->X \To P

\ClrText
""
" eff calacul\@F9\Petas"
" th\@F9\Peta\oriques Ci"
""
\Blue \Locate 4,4,"L"
\Orange \Locate 9,4,"C"
\Locate 6,4,Y
\Locate 11,4,X
\Blue \Locate 5,6,\Mat A[D+Y+1,X]
\Do:\LpWhile \Getkey\<>31
\Next 
D+1\->D
\Next 






' calcul du khi2 \@24

\ClrText
""
"\@F9V2= \@F9Q((Oij-Cij)\x^2/Cij)"

\For 1\->Y \To L*2 \Step 2
\For 1\->X \To P

\Mat A[L*2-1,P+2]+(\Mat A[Y,X]-\Mat A[Y+1,X])\x^2/\Mat A[Y+1,X]\->\Mat A[L*2-1,P+2]

\Next 
\Next 

""
"\@F9V\x^2:"
\Blue \Locate 5,5,\Mat A[L*2-1,P+2]

\Do:\LpWhile \Getkey\<>31






\ClrText

\Locate 2,1,"DDL:"
(L-1)*(P-1)\->D
\Locate 7,1,D

\Locate 1,3,"\->table \@F9V\x^2:"

\Norm2
\Locate 2,5,"P:"
\@F9\(-)\Mat A[L*2-1,P+2],9\EE99,(L-1)*(P-1))\->R
\Blue \Locate 4,5,R

\Fix 3
\Blue \Locate 12,3,S

\Fix 2
\Orange \Locate 4,7,100*R
\Orange \Locate 10,7,"\@F799"

\Do:\LpWhile \Getkey\<>31





'analyse \@24

\Fix 3

\ClrText
\If \Mat A[L*2-1,P+2]\>=S
\Then 
\Orange \Locate 2,1,"\<> significative"
\Locate 5,3,"\@F9V\x^2 \>= \@F9V\x^2\@F9@"
\Orange \Locate 2,5,\Mat A[L*2-1,P+2]
\Locate 10,5,">"
\Orange \Locate 12,5,S
\Locate 2,7,"\@F9\femto P:"
\Locate 7,7,R
\Else 
\Blue \Locate 7,2,"\<> NS"
\Locate 5,4,"\@F9V\x^2 < \@F9V\x^2\@F9@"
\Blue \Locate 2,6,\Mat A[L*2-1,P+2]
\Locate 10,6,"<"
\Blue \Locate 12,6,S
\IfEnd

\Do:\LpWhile \Getkey\<>31







\@F9\@26\Mat A[L*2-1,P+2],9\EE99,(L-1)*(P-1)\Disp

%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:1911
File Name:KHI2A
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Norm2

' choix de calcul \@24
"    test khi sur"
""
" 1 rep et H0 \->  [1]"
""
" \@2B\@E7R\@E7s rep obs \->  [2]"

\Do
\Getkey\->K
K=62\=>\Goto1
\LpWhile K\<>72



'verification Oi = Ci \@24

0\->\Mat A[3,P+1]

\For 1\->X \To P
\Mat A[3,P+1]+\Mat A[3,X]\->\Mat A[3,P+1]
\Next 

\If \Mat A[2,P+1]\<>\Mat A[3,P+1]
\Then 
\ClrText
\Orange \Locate 2,2,"total Oi\<>Ci \!mark\!mark"
\Orange \Locate 2,4,\Mat A[3,P+1]
\Do:\LpWhile \Getkey\<>31
\IfEnd




'verification difference = 0 \@24

0\->\Mat A[4,P+1]

\For 1\->X \To P
\Mat A[4,P+1]+\Mat A[4,X]\->\Mat A[4,P+1]
\Next 

\If \Mat A[4,P+1]\<>0
\Then 
\ClrText
\Orange \Locate 2,2,"total diff \<>0 \!mark\!mark"
\Orange \Locate 2,4,\Mat A[4,P+1]
\Do:\LpWhile \Getkey\<>31
\IfEnd





' calcul du khi2 \@24
\ClrText
""
"\@F9V2 = \@F9Q(Oi-Ci)2 / Ci"

0\->\Mat A[4,P+1]

\For 1\->X \To P
\Mat A[4,P+1]+(\Mat A[4,X])\x^2/\Mat A[3,X]\->\Mat A[4,P+1]
\Next 

""
"\@F9V\x^2:"
\Blue \Locate 5,4,\Mat A[4,P+1]

\Do:\LpWhile \Getkey\<>31


\ClrText
""
""
\Locate 2,2,"DDL:"
\Locate 7,2,X-1
""
""
\Locate 2,4,"\->table \@F9V\x^2"
""
\Locate 2,6,"P:"
\Blue \Locate 4,6,\@F9\(-)\Mat A[4,P+1],9\EE99,X-1)

\Fix 2
\Orange \Locate 4,7,100*\@F9\(-)\Mat A[4,P+1],9\EE99,X-1)
\Orange \Locate 10,7,"\@F799"

\Do:\LpWhile \Getkey\<>31

\@F9\@26\Mat A[4,P+1],9\EE99,X-1\Disp
\Stop



\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24\@24



' cas 2 comparer 2 repartitions \@24

\Lbl 1






' Calculs \@24\@24\@24\@24\@24\@24\@24\@24\@24





' calcul de la somme des effectifs the\oriques par ligne \@24


\For 1\->Y \To L*2 \Step 2
0\->\Mat A[Y+1,P+1]
\For 1\->X \To P
\Mat A[Y+1,P+1]+\Mat A[Y+1,X]\->\Mat A[Y+1,P+1]
\Next 
\Next 





' total genral des effectifs the\oriques \@24
' = somme par la dernierere colonne P+1 \@24

0\->\Mat A[L*2,P+2]
\For 1\->Y \To L*2 \Step 2
\Mat A[L*2,P+2]+\Mat A[Y+1,P+1]\->\Mat A[L*2,P+2]
\Next 







' verication general the\orique = general observe \@24
' si ok, le programme est bon \@24
\If \Mat A[L*2,P+2]\<>\Mat A[L*2+1,P+2]
\Then 
\ClrText
\Orange \Locate 1,2,"the\orique \<> obs m1\!mark\!mark"
\Orange \Locate 2,4,\Mat A[L*2,P+2]
\Orange \Locate 2,6,\Mat A[L*2+1,P+2]
\Do:\LpWhile \Getkey\<>31
\IfEnd






' calcul du khi2 \@24

\ClrText
""
"\@F9V2= \@F9Q(Oij-Cij)2 / Cij"

0\->\Mat A[L*2-1,P+2]

\For 1\->Y \To L*2 \Step 2
\For 1\->X \To P

\Mat A[L*2-1,P+2]+(\Mat A[Y,X]-\Mat A[Y+1,X])\x^2/\Mat A[Y+1,X]\->\Mat A[L*2-1,P+2]

\Next 
\Next 

""
"\@F9V\x^2:"
\Blue \Locate 5,5,\Mat A[L*2-1,P+2]

\Do:\LpWhile \Getkey\<>31


\ClrText

\Locate 2,1,"DDL:"
\Locate 7,1,(L-1)*(P-1)

\Locate 1,3,"\->table \@F9V\x^2:"

\Locate 2,5,"P:"
\Blue \Locate 4,5,\@F9\(-)\Mat A[L*2-1,P+2],9\EE99,(L-1)*(P-1))

\Fix 3
\Blue \Locate 12,3,S

\Fix 2
\Orange \Locate 4,7,100*\@F9\(-)\Mat A[L*2-1,P+2],9\EE99,(L-1)*(P-1))
\Orange \Locate 10,7,"\@F799"

\Do:\LpWhile \Getkey\<>31

\@F9\@26\Mat A[L*2-1,P+2],9\EE99,(L-1)*(P-1)\Disp

%End
