Application Center - Maplesoft

App Preview:

Analyse statistique

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


Analyse statistique 


? d?cembre 2005, Andr? L?vesque

L'application permet d'obtenir les principales caract?ristiques (statistiques descriptives et histogramme) de donn?es quantitatives et  permet d'analyser le comportement de la moyenne de la population d'o? proviennent ces donn?es (intervalle de confiance et test d'hypoth?se). Elle permet aussi de mesurer ? l'aide d'une ?quation (lin?aire, quadratique, cubique, biquadratique ou exponentielle) la d?pendance de donn?es chronologiques en fonction du temps ou la d?pendance de deux ?chantillons de donn?es quantitatives quelconques (?tude de r?gression). Pour lancer l'application, cliquez sur !!! ou choississez  Edit -> Execute -> Worksheet. ou placez votre curseur sur une ligne rouge du programme puis cliquez sur la touche retour.
 

************************************** 

> restart:
with(stats):
graph:=NULL:

A:=proc()
 global d,vd:
 d:=Maplets:-Tools:-Get('TF0'):
 vd:="A":
 clist():
 return
end:

B:=proc()
 global d,vd:
 d:=Maplets:-Tools:-Get('TF1'):
 vd:="B":
 clist():
 return:
end:

liste:=proc()
 local i:
 global d,d1,d2:
   d1:=Maplets:-Tools:-Get('TF0'):
   d2:=Maplets:-Tools:-Get('TF1'):
 d:=d1:
 clist():
 d1:=d:
 d:=d2:
 clist():
 d2:=d:
 d:=[seq([d1[i],d2[i]],i=1..min(nops(d1),nops(d2)))]
end:

clist:=proc()
 local i,dd,dlist,dnbr:
 global g, d, err:
 err:=0:
 g:=plot(0,x=1..2,1..2,axes=NONE):
   if d="" then
     return(g)
   fi:
 dlist:=[]:
 dnbr:="":
   for i from 1 to length(d) do
     if d[i]="." or d[i]="," then
       dnbr:=cat(convert(dnbr,string),convert(".",string))
     elif d[i]="-" then
       dnbr:=cat(convert(dnbr,string),convert("-",string)):
     elif whattype(traperror(parse(d[i])))=string then
       err:=1:
       return(gr)
     elif is(type(parse(d[i]),numeric))=true then
       dnbr:=cat(convert(dnbr,string),convert(d[i],string))
     elif whattype(traperror(parse(dnbr)))=string then
       err:=1:
       return(gr)
     else
       dlist:=[op(dlist),parse(dnbr)]: dnbr:=""
     fi:
   od:
 d:=[op(dlist),parse(dnbr)]:
end:

histo:= proc()
 local s1, s2, A, i, j, k, b, f, x, y, L, a, g1, g2, g3, g4, lmax, t:
 global d, g, vd, graph, u, s, inf, larg, err:
 if err=1 then
   Maplets[Examples][Alert]( cat("Erreur dans les donn?es de l'?chantillon ", convert(vd,string), ".\n")):
   return(g)
 fi:
 if d="" then
   Maplets[Examples][Alert](cat("Aucune valeur n'a ?t? assign?e ? l'?chantillon ", convert(vd,string), ".\n")):
   return(g)
 fi:
 if Maplets:-Tools:-Get('THT1')<>"" then inf:=parse(Maplets:-Tools:-Get('THT1')) else inf:="" fi:
 if Maplets:-Tools:-Get('THT2')<>"" then larg:=parse(Maplets:-Tools:-Get('THT2')) else larg:="" fi:
 if (inf="" and larg<>"") then
   Maplets[Examples][Alert]( "Quelle est la borne inf?rieure de la premi?re classe?"):
   larg:=""
 elif (inf<>"" and larg="") then
   Maplets[Examples][Alert]( "Quelle est la largeur des classes?"):
   inf:=""
 elif inf<>"" and inf>=max(op(d)) then
   Maplets[Examples][Alert]( "La fronti?re inf?rieure de la premi?re classe est\nsup?rieure ? tous les ?l?ments de votre ?chantillon"):
   return(graph)
 fi:  
   s[1]:=evalf(describe[mean](d)):
   s[2]:=evalf(describe[standarddeviation](d)):
   s[3]:=evalf(stats[describe,median](d)):
   s[4]:=evalf(stats[describe,range](d)):
   s[5]:=evalf(stats[describe,quartile[1]](d)):
   s[6]:=evalf(stats[describe,quartile[2]](d)):
   s[7]:=evalf(stats[describe,quartile[3]](d)):
   s[8]:=nops(d):
   s:=cat(`ECHANTILLON `,convert(vd,string),`\n`,`\n`,`MOYENNE = `,convert(s[1],CaractDec),`\n`,`ECART-TYPE = `,convert(s[2],CaractDec),`\n`, `MEDIANE = `,convert(s[3],CaractDec),`\n`,`ETENDUE = `,cat(`[`,convert(op(1,s[4]),CaractDec),`, `,convert(op(2,s[4]),CaractDec),`]`),`\n`,`1er QUARTILE = `, convert(s[5],CaractDec),`\n`,`2e QUARTILE = `, convert(s[6],CaractDec),`\n`, `3e QUARTILE = `, convert(s[7],CaractDec),`\n`,`TAILLE DE L'ECHANTILLON = `,convert(s[8],CaractDec)):
   Maplets:-Tools:-Set('TB1'=cat(convert(s,string))):
   if d="" then
     return(g)
   fi:
   A:=sort(d):
   a:=A[1]:
   b:=A[nops(A)]:        
   if inf="" or larg="" then
     for t from 1 to nops(A) while is(A[t],integer)=true do
     od:
     k:=0:
     for i from 1 to nops(A)-1 do
       if A[i]<>A[i+1] then k:=k+1 fi
     od:
     if t-1=nops(A) then
       if b-a<12 then
         L:=1
       else
         L:=floor((b-a)/piecewise(nops(d)<33,floor(nops(d)/3),12))+1
       fi:
       if L=0 then
         L:=L+1
       fi:
       for j while a+j*L<b do
       od:
       if j*L-b+a>0 then
         a:=a-(j*L-b+a)/2
       else
         a:=a-.5
       fi
     else
       if k<12 then
         L:=(b-a)/k
       else
         L:=(b-a)/piecewise(nops(d)<33,floor(nops(d)/3),12)*1.005:
       fi:
       for i from 0 to 12 while (L-floor(L))*10^i<1 do
       od:
       i:=i+1:
       L:=floor(L)+round((L-floor(L))*10^i)/10^i:
         for j while a+j*L<b do
         od:
       a:=a-(j*L-b+a)/2:
       if j*L-b+a<>0 then
         a:=floor(a)+floor(((a-floor(a))*10^i))/10^i
       else
         a:=a-0.5/10^(i-1)
       fi:            
     fi:
   else
     a:=inf:
     L:=larg:
       if L<=0 then
         Maplets[Examples][Alert]( "La largeur des classes doit ?tre positive."):
         return(graph)
       fi:
   fi:
       k:=0:
         for i from a to b by L do
           k:=k+1:
           f[k]:=0:
             for j to nops(A) do
               if (A[j] >= i and A[j] < i+L) then
                 f[k]:= f[k]+1
               fi
             od:
         od:
       y:=max(seq(f[i],i=1..k)):
       x:=[]:
       k:=0:          
       for i from a+L/2 to b+L/2 by L do
         k:=k+1:
         x:=[op(x), [i-L/2,0], [i-L/2,-y/100], [i-L/2,f[k]], [i+L/2,f[k]], [i+L/2,0], [i-L/2,0]]:
       od:
       if f[k]=0 then
         k:=k-1
       fi:
       Maplets:-Tools:-Set('THT1'=convert(evalf(a),CaractDec)):
       Maplets:-Tools:-Set('THT2'=convert(evalf(L),CaractDec)):
       lmax:=max(seq(length(convert(a+i*L,CaractDec)),i=1..k)):
       u:=[seq(evalf(a+(round((lmax*k/35)+1)*i*L)), i=0..k/(round(lmax*k/35)+1))]:
       g1:=plot(x,a..a+k*L, filled=true, color=grey, xtickmarks=u):
       g2:=plot(x,a..a+k*L, color=black):
       if k<=20 then
         g3:=seq(plots[textplot]([a+(i-1/2)*L,f[i]+y/30,f[i]], align=ABOVE, color=black,  font=['HELVETICA',9], tickmarks=[0,0], axes=NONE), i=1..k):
       else
         g3:=plots[textplot]([0,0,""], axes=NORMAL):
       fi:
       g4:=seq(plots[textplot]([u[i], -.02*y, convert(evalf(u[i],arrondir(u[i])),CaractDec)], align=BELOW, color=black), i=1..nops(u)):
      graph:=plots[display]([g1,g2,g3,g4],view=[a-L/2..a+k*L+L/2, -.02*y..1.1*y], font=['HELVETICA',9], xtickmarks=0):
end:

arrondir:=proc(x)
local i,j,k:
i:=0:
while abs(x)/10^i>1 do
i:=i+1:
od:
j:=0:
while frac(10^j*x)<>0 do
j:=j+1:
od:
k:=i+j+(-sign(x)+1)/2:
if k=0 then k:=1 fi:
k:
end:

`convert/CaractDec`:= proc(x)
local X, i, j:
X:= sprintf(cat("%", 2*Digits+2, ".", Digits, "f"), x):
for i while X[i] = " " do od:
for j from length(X) by -1 while X[j] = "0" do od:
if X[j] = "." then j:= j-1 fi:
X[i..j]
end:

corr:= proc()
 local i:
 global d,d1,d2,d3:
   use Maplets[Tools] in
     d1:=Maplets:-Tools:-Get('TF0'):
       if d1="" then
         Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon A."):
         return
       fi:  
     d2:=Maplets:-Tools:-Get('TF1'):
       if d2="" then
         Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon B."):
         return
       fi:
     d:=d1:
     clist():
     d1:=d:
     d:=d2:
     clist():
     d2:=d:
   end use:
   if nops(d1)<>nops(d2) then
     Maplets[Examples][Alert]( "Les deux ?chantillons doivent ?tre de m?me grandeur."):
     return
   fi:
   if d1="" then
     return
   elif d2="" then
     return    
   fi:
   Maplets:-Tools:-Set('TF9'=convert(evalf(stats[describe, linearcorrelation](d1,d2),9), CaractDec)):
end:

regr1:=proc()
  local i,a,c,dt,dt1,dt2,Tx,Ty,Y,t,p1,p2,p3,p4,dti,xc,courbe,choix,f,residus,sol:
  global d,g,vd,vi,graph,y:
   use Maplets[Tools] in
     if Get('RB1')=true then
       d:=Maplets:-Tools:-Get('TF0'):
         if d="" then
           Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon A."):
           Maplets:-Tools:-Set('TB1'=""):
           return(g)
         fi:
       vd:="A":
       vi:="t":
       clist()
     else
       d:=Maplets:-Tools:-Get('TF1'):
         if d="" then
           Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon B."):
           Maplets:-Tools:-Set('TB1'=""):
           return(g)
         fi:  
       vd:="B":
       vi:="t":
       clist()
     fi:
   end use:
   if d="" then
     return(g)
   fi:   
    choix:=Maplets:-Tools:-Get('DB1'):
      if choix="lineaire" and nops(d)>=2 then courbe:=a[1]*t+a[2] elif
         choix="quadratique" and nops(d)>=3 then courbe:=a[1]*t^2+a[2]*t+a[3] elif
         choix="cubique"  and nops(d)>=4 then courbe:=a[1]*t^3+a[2]*t^2+a[3]*t+a[4] elif
         choix="biquadratique" and nops(d)>=5 then courbe:=a[1]*t^4+a[2]*t^3+a[3]*t^2+a[4]*t+a[5] elif
         choix="exponentielle" and nops(d)>=2 then courbe:=a[1]*t+a[2] else
         Maplets[Examples][Alert]("Le nombre de donn?es est insuffisant\npour ce type de r?gression."):
         return(g)
      fi:
      if min(op(d))<=0 and (choix="exponentielle") then
        Maplets[Examples][Alert](cat("Ce type de r?gression exige que les valeurs\nde l'?chantillon ", convert(vd,string), " soient sup?rieures ? z?ro.")):
        Maplets:-Tools:-Set('TB1'=""):
        return(g)
      fi:
       dt:=[seq([i,evalf(d[i])],i=1..nops(d))]:
       if choix="exponentielle" then
         [seq([i,log(d[i])],i=1..nops(d))]:
         exp(evalf(CurveFitting[LeastSquares](%,t,curve=courbe))):
         if nops(op(1,%))=2 then
           if is(op(1,op(1,%))<infinity) then
             y:=exp(op(1,op(1,%)))*exp(op(1,op(2,op(1,%))))^t
           elif is(op(2,op(1,%))<infinity) then
             y:=exp(op(2,op(1,%)))*exp(op(1,op(1,op(1,%))))^t
           fi
         else
           y:=%
         fi
       else
         y:=CurveFitting[LeastSquares](dt,t,curve=courbe):
       fi:
       dt1:=sort([seq(dt[i,1],i=1..nops(dt))]):
       dt2:=sort([seq(dt[i,2],i=1..nops(dt))]):
       p1:=plots[pointplot](dt, color=black):
       p2:=plot(y, t=stats[describe,range]([seq(dt[i,1],i=1..nops(dt))]), thickness=2, color=green):
         Tx:=dt1[1]+(dt1[nops(dt1)]-dt1[1])/40:
         Ty:=dt2[nops(dt2)]-(dt2[nops(dt2)]-dt2[1])/40:
       p3:= plots[textplot]([Tx,Ty,vd]):
         Tx:=dt1[nops(dt1)]-(dt1[nops(dt1)]-dt1[1])/40:
         Ty:=dt2[1]+(dt2[nops(dt2)]-dt2[1])/40:
       p4:= plots[textplot]([Tx,Ty,vi]):
       Maplets:-Tools:-Set('TB1'=cat("\n",convert(vd,string),"=",convert(evalf(sort(y,t,descending),10),string))):
       xc:=parse(Maplets:-Tools:-Get('TF2')):
         if xc=NULL then
           Maplets:-Tools:-Set('TF3'=""):
         elif is(xc,numeric)=false then
           Maplets:-Tools:-Set('TF3'=""):
         else
           Maplets:-Tools:-Set('TF3'=convert(evalf(eval(y,t=xc),9),CaractDec)):
         fi:  
       graph:=plots[display]([p1,p2,p3,p4], axesfont=['HELVETICA',9], font=['HELVETICA',9]);
end:

regr2:=proc()
 local i, j, a, c, x, y, Y, dt, dt1, dt2, Tx, Ty, dti, t, p1, p2, p3, p4, courbe, sol, xq, choix:
 global d, d1, d2, d3, g, vd, vi, graph:
   use Maplets[Tools] in
     d1:=Maplets:-Tools:-Get('TF0'):
       if d1="" then
         Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon A."):
         Maplets:-Tools:-Set('TB1'=""):
         return(g)
       fi:  
     d2:=Maplets:-Tools:-Get('TF1'):
       if d2="" then
         Maplets[Examples][Alert]( "Aucune valeur n'a ?t? assign?e ? l'?chantillon B."):
         Maplets:-Tools:-Set('TB1'=""):
         return(g)
       fi:
     d3:=Get('RT1'):
     vd:="B":
     vi:="A":
     d:=d1:
     clist():
     d1:=d:
     d:=d2:
     clist():
     d2:=d:
       if d3=false then
         i:=d1:
         d1:=d2:
         d2:=i:vd:="A":vi:="B":
       fi
   end use:
     if nops(d1)<>nops(d2) then
       Maplets[Examples][Alert]( "Les deux ?chantillons doivent ?tre de m?me grandeur."):
       Maplets:-Tools:-Set('TB1'=""):
       return(g)
     fi:
   if d1="" or d2="" then
     Maplets:-Tools:-Set('TB1'=""):       
     return(g)
   fi:
   choix:=Maplets:-Tools:-Get('DB2'):
      if choix="lineaire" and nops(d1)>=2 and nops(d2)>=2 then courbe:=a[1]*x+a[2] elif
         choix="quadratique" and nops(d1)>=3 and nops(d2)>=3 then courbe:=a[1]*x^2+a[2]*x+a[3] elif
         choix="cubique"  and nops(d1)>=4 and nops(d2)>=4 then courbe:=a[1]*x^3+a[2]*x^2+a[3]*x+a[4] elif
         choix="biquadratique" and nops(d1)>=5 and nops(d2)>=5 then courbe:=a[1]*x^4+a[2]*x^3+a[3]*x^2+a[4]*x+a[5]        elif
         choix="exponentielle" and nops(d1)>=2 and nops(d2)>=2 then courbe:=a[1]*x+a[2] else
         Maplets[Examples][Alert]("Le nombre de donn?es est insuffisant\npour ce type de r?gression."):
         return(g)
      fi:
      if min(op(d2))<=0 and choix="exponentielle" then
        Maplets[Examples][Alert](cat("Ce type de r?gression exige que les valeurs\nde l'?chantillon ", convert(vd,string), " soient sup?rieures ? z?ro.")):
        Maplets:-Tools:-Set('TB1'=""):
        return(g)
      fi:  
       dt:=evalf([seq([d1[i],d2[i]],i=1..min(nops(d1),nops(d2)))]):
       if choix="exponentielle" then
         [seq([d1[i],log(d2[i])],i=1..nops(dt))]:
         exp(evalf(CurveFitting[LeastSquares](%,x,curve=courbe))):
         if nops(op(1,%))=2 then
           if is(op(1,op(1,%))<infinity) then
             y:=exp(op(1,op(1,%)))*exp(op(1,op(2,op(1,%))))^x
           elif is(op(2,op(1,%))<infinity) then
             y:=exp(op(2,op(1,%)))*exp(op(1,op(1,op(1,%))))^x
           fi
         else
           y:=%
         fi
       else
         y:=CurveFitting[LeastSquares](dt,x,curve=courbe):
       fi:
       dt1:=sort([seq(dt[i,1],i=1..nops(dt))]):
       dt2:=sort([seq(dt[i,2],i=1..nops(dt))]):
       p1:=plots[pointplot](dt, color=black):
       p2:=plot(y, x=stats[describe,range]([seq(dt[i,1],i=1..nops(dt))]), thickness=2, color=green):
         Tx:=dt1[1]+(dt1[nops(dt1)]-dt1[1])/40:
         Ty:=dt2[nops(dt2)]-(dt2[nops(dt2)]-dt2[1])/40:
       p3:= plots[textplot]([Tx,Ty,vd]):
         Tx:=dt1[nops(dt1)]-(dt1[nops(dt1)]-dt1[1])/40:
         Ty:=dt2[1]+(dt2[nops(dt2)]-dt2[1])/40:
       p4:= plots[textplot]([Tx,Ty,vi]):   
       Maplets:-Tools:-Set('TB1'= cat("\n",convert(vd,string), "=", convert(evalf(subs(x=parse(vi),sort(y,x,descending)),10),string))):
     if d3=true then
       xq:=parse(Maplets:-Tools:-Get('TF5')):
         if xq=NULL then
           Maplets:-Tools:-Set('TF6'=""):            
         elif is(xq,numeric)=false then
           Maplets:-Tools:-Set('TF6'=""):
         else
           Maplets:-Tools:-Set('TF6'=convert(evalf(eval(y,x=xq),9),CaractDec)):
         fi:  
     else
       xq:=parse(Maplets:-Tools:-Get('TF5')):
         if xq=NULL then
           Maplets:-Tools:-Set('TF6'=""):
         elif is(xq,numeric)=false then
           Maplets:-Tools:-Set('TF6'=""):
         else
           Maplets:-Tools:-Set('TF6'=convert(evalf(eval(y,x=xq),9),CaractDec)):
         fi:  
     fi:   
     graph:=plots[display]([p1,p2,p3,p4], axesfont=['HELVETICA',9], font=['HELVETICA',9])
end:

init1:=proc()
global d, graph:
 graph:=plot(0,x=1..2,1..2,axes=NONE):
use Maplets[Tools] in
 if d<>"" and nops(d)>1 then
   Set('THM'=convert(evalf(describe[mean](d)),CaractDec)):
   Set('THE'=convert(evalf(sqrt(add((i-add(i,i=d)/nops(d))^2,i=d)/(nops(d)-1))),CaractDec)):
   Set('THN'=nops(d))
 else
   Set('THM'=""):
   Set('THE'=""):
   Set('THN'="")
 fi:
end use
end:

init2:=proc()
global d, graph:
 graph:=plot(0,x=1..2,1..2,axes=NONE):
use Maplets[Tools] in
 if d<>"" then
   Set('THM1'=convert(evalf(describe[mean](d)),CaractDec)):
   Set('THE1'=convert(evalf(sqrt(add((i-add(i,i=d)/nops(d))^2,i=d)/(nops(d)-1))),CaractDec)):
   Set('THN1'=nops(d))
 else
   Set('THM1'=""):
   Set('THE1'=""):
   Set('THN1'="")
 fi:
end use
end:


choix:=proc()
global seuil, moy, ecart_type, n, sigma, N, moy1, ecart_type1, n1, sigma1, N1, z, var, p:
use Maplets[Tools] in
 sigma:="":
 sigma1:="":
 N:="":
 N1:="":
 p:=0:
   if Get('RI1')=false then
     if Get('THI1')<>"" then
       Set('THI2'=Get('THI1')):
     elif Get('THS1')<>"" then
       Set('THS2'=Get('THS1')):
     elif Get('THD1')<>"" then
        Set('THD2'=Get('THD1')):
     fi:
   fi:
   if Get('CBI1')=true and Get('RI1')=true and (Get('TH1')="" or Get('THM')="" or Get('THN')="" or (Get('THE')="" and Get('THEP')="")) then
     Maplets[Examples][Alert]( "Il vous manque des donn?es. V?rifiez si vous avez indiqu?\nle seuil du test, la moyenne de l'?chantillon, l'?cart-type de\nl'?chantillon ou de la population et la taille de l'?chantillon." ):
     p:=1
   elif Get('CBI1')=true and Get('RI1')=false and (Get('TH1')="" or Get('THM')="" or Get('THN')="" or (Get('RH1')=true and Get('THI1')="") or (Get('RH2')=true and Get('THS1')="") or (Get('RH3')=true and Get('THD1')="") or (Get('THE')="" and Get('THEP')="")) then
     Maplets[Examples][Alert]( "Il vous manque des donn?es. V?rifiez si vous avez indiqu?\nle seuil du test, la moyenne de l'?chantillon, l'?cart-type de\nl'?chantillon ou de la population, la taille de l'?chantillon et\nla valeur de mu du test choisi." ):
     p:=1
   elif Get('CBI2')=true and Get('RI1')=true and (Get('TH1')="" or Get('THM')="" or Get('THM1')="" or Get('THN')="" or Get('THN1')="" or (Get('THE')="" and Get('THEP')="") or (Get('THE1')="" and Get('THEP1')="")) then
     Maplets[Examples][Alert]( "Il vous manque des donn?es. V?rifiez si vous avez indiqu?\nle seuil du test, les moyennes des ?chantillons, les ?cart-type des\n?chantillons ou des populations, les tailles des ?chantillons." ):
     p:=1
   elif Get('CBI2')=true and Get('RI1')=false and (Get('TH1')="" or Get('THM')="" or Get('THM1')="" or Get('THN')="" or Get('THN1')="" or (Get('THE')="" and Get('THEP')="") or (Get('THE1')="" and Get('THEP1')="") or (Get('RH1')=true and Get('THI1')="") or (Get('RH2')=true and Get('THS1')="") or (Get('RH3')=true and Get('THD1')="")) then
     Maplets[Examples][Alert]( "Il vous manque des donn?es. V?rifiez si vous avez indiqu?\nle seuil du test, les moyennes des ?chantillons, les ?cart-type des\n?chantillons ou des populations, les tailles des ?chantillons et\nla valeur de mu1-mu2 du test choisi." ):
     p:=1:
   else
     if Get('TH1'::positive)<1 and Get('TH1'::positive)>0 then
       seuil:=evalf(Get('TH1'::positive)):
     else
     Maplets[Examples][Alert]( "Le seuil doit ?tre un nombre entre 0 et 1." ):
     p:=1
     fi:
     moy:=evalf(Get('THM'::constant)):
       if Get('THE')<>"" then
         ecart_type:=evalf(Get('THE'::positive))
       else
         ecart_type:=""
       fi:
     n:=Get('THN'::posint):
       if Get('THEP')<>"" then
         sigma:=evalf(Get('THEP'::positive))
       fi:
       if Get('THTP')<>"" then
         N:=Get('THTP'::posint):
         if N<=n then
           Maplets[Examples][Alert]( "La taille de la population doit ?tre sup?rieure ? celle de l'?chantillon." ):
           p:=1:
         fi:   
       fi:     
       if Get('CBI2')=true then
         moy1:=evalf(Get('THM1'::constant)):
           if Get('THE1')<>"" then
             ecart_type1:=evalf(Get('THE1'::positive))
           else
             ecart_type1:=""
           fi:
         n1:=Get('THN1'::posint):
           if Get('THEP1')<>"" then
             sigma1:=evalf(Get('THEP1'::positive))
           fi:
           if Get('THTP1')<>"" then
             N1:=Get('THTP1'::posint):
             if N1<=n1 then
               Maplets[Examples][Alert]( "La taille de la population doit ?tre sup?rieure ? celle de l'?chantillon." ):
               p:=1:
             fi:        
           fi:
       fi:     
   fi:
     if p=0 then
       if whattype(sigma)<>string then
         ecart_type:=sigma
       fi:
       if whattype(sigma1)<>string then
         ecart_type1:=sigma1
       fi:
       if whattype(N)<>string then
         ecart_type:=ecart_type*sqrt((N-n)/(N-1))
       fi:
       if whattype(N1)<>string then
         ecart_type1:=ecart_type1*sqrt((N1-n1)/(N1-1))
       fi:
       if Get('CBI1')=true then
           if Get('RI1')=true then
             Int_Mu()
           else
             Test_Mu()
           fi
       elif Get('CBI2')=true then
         if Get('RI1')=true then
           Int_Mu1Mu2()
         else
           Test_Mu1Mu2()
         fi
       fi:
     else
       graph
   fi:
 end use
end:

Int_Mu := proc()
local i, inf, sup, ecart, rep, courbe, g1, g2, g3, g4:
global seuil, moy, ecart_type, n, sigma, N, z, graph, var:
ecart:=ecart_type/sqrt(n):
 if n>=30 then
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):      
 elif n<30 and sigma<>"" then
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):
 else
   var:="t":
   z:=statevalf[icdf,studentst[n-1]]((1+seuil)/2):
 fi:
 inf:=evalf(moy-z*ecart):
 sup:=evalf(moy+z*ecart):
 rep:=cat("\n", "Intervalle de confiance sur la moyenne de la population en utilisant un seuil de confiance de ",  convert(seuil,CaractDec)," :","\n","\n", cat("[", convert(inf,CaractDec), ", ", convert(sup,CaractDec), "]"), "\n\n(Calcul fait en utilisant ",convert(var,string), " = ",convert(z,CaractDec),")"):
 Maplets:-Tools:-Set('TB2'= rep):
 courbe:=exp(-(((x-moy)/(ecart_type/sqrt(n)))^2)/2)/(sqrt(2*Pi)*(ecart_type/sqrt(n))):
 g1:= plot(courbe,x=moy-3.5*ecart_type/sqrt(n)..moy+3.5*ecart_type/sqrt(n)
, color=black):
 g2:= plot(courbe, x = inf..sup
, xtickmarks=[2*abs(sup)], color = grey, filled = true):
 g3:= plots[textplot]([[inf,-subs(x=moy,courbe)/50,convert(evalf(inf),CaractDec)], [sup,-subs(x=moy,courbe)/50,convert(evalf(sup),CaractDec)]], align=BELOW):
 g4:= plot([[moy-3.5*ecart_type/sqrt(n),0], [moy+3.5*ecart_type/sqrt(n),0]], x=moy-3.5*ecart_type/sqrt(n)..moy+3.5*ecart_type/sqrt(n)
, color=black):
 graph:=plots[display]([g2,g1,g3,g4]
, labels=["",""], font=['HELVETICA',9], labelfont=['HELVETICA',9], axes=NONE, view=[moy-3.5*ecart_type/sqrt(n)..moy+3.5*ecart_type/sqrt(n), -subs(x=moy,courbe)/50..subs(x=moy,courbe)]):
end:

Int_Mu1Mu2 := proc()
local i, ecart, inf, sup, rep, courbe, g1, g2, g3, g4:
global seuil, moy, ecart_type, n, sigma, N, moy1, ecart_type1, n1, sigma1, N1, z, graph, var:
 if n>=30 and n1>=30 then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):      
 elif (n<30 or n1<30) and sigma<>"" then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):
 else
   ecart:=sqrt(((n-1)*ecart_type^2+(n1-1)*ecart_type1^2)/(n+n1-2))*sqrt(1/n+1/n1):
   var:="t":
   z:=statevalf[icdf,studentst[n+n1-2]]((1+seuil)/2):
 fi:
 inf:=evalf((moy-moy1)-z*ecart):
 sup:=evalf((moy-moy1)+z*ecart):
 rep:=cat("\n", "Intervalle de confiance sur la difference des moyennes des populations en utilisant un seuil de confiance de ",  convert(seuil,CaractDec)," :","\n","\n", cat("[", convert(inf,CaractDec), ", ", convert(sup,CaractDec), "]"), "\n\n(Calcul fait en utilisant ",convert(var,string), " = ",convert(z,CaractDec),")"):
 Maplets:-Tools:-Set('TB2'= rep):
 courbe:=exp(-(((x-(moy-moy1))/ecart)^2)/2)/(sqrt(2*Pi)*ecart):
 g1:= plot(courbe,x=(moy-moy1)-3.5*ecart..(moy-moy1)+3.5*ecart
, color=black):
 g2:= plot(courbe, x = inf..sup
, xtickmarks=[2*abs(sup)], color = grey, filled = true):
 g3:= plots[textplot]([[inf,-subs(x=moy-moy1,courbe)/50,convert(evalf(inf),CaractDec)], [sup,-subs(x=moy-moy1,courbe)/50,convert(evalf(sup),CaractDec)]], align=BELOW):
 g4:=plot([[moy-moy1-3.5*ecart,0], [moy-moy1+3.5*ecart,0]], x=(moy-moy1)-3.5*ecart..(moy-moy1)+ 3.5*ecart
, color=black):
 graph:=plots[display]([g2,g1,g3,g4]
, labels=["",""], font=['HELVETICA',9], labelfont=['HELVETICA',9], axes=NONE, view=[moy-moy1-3.5*ecart..moy-moy1+3.5*ecart, -subs(x=moy-moy1,courbe)/50..subs(x=moy-moy1,courbe)]):
end:

Test_Mu := proc()
local i, ecart, f, m1, m2, m3, t, g1, g2, g3, g4, g5, g6, g7:
global seuil, moy, ecart_type, n, sigma, N, z, var, graph:
use Maplets[Tools] in
f := x -> exp(-(x^2)/2)/sqrt(2*Pi):
ecart:=ecart_type/sqrt(n):
 if Get('RH1')=true then
   if n>=30 then
     var:="z":
     z:=statevalf[icdf,normald[0,1]](seuil):      
   elif n<30 and sigma<>"" then
     var:="z":
     z:=statevalf[icdf,normald[0,1]](seuil):
   else
     var:="t":
     z:=statevalf[icdf,studentst[n-1]](seuil):
   fi:
     if Get('THI1')<>"" then
       m1:=Get('THI1'::constant)
     fi:
   t:=evalf((moy-m1)/ecart):
     if t>z then
       Set('TB2'=cat("Zone de rejet : \n",var,"c > ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n",var,"c > ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     fi:
   g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
   g2 := plot( f(x), x = z..max(t,3.5), color=grey, filled=true):
   g3 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
   g4 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
   g5 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
   graph:=plots[display]([g3,g2,g1,g4,g5], xtickmarks=[2*abs(max(t,3.5))], ytickmarks=[10],axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
 elif Get('RH2')=true then
   if n>=30 then
     var:="z":
     z:=-statevalf[icdf,normald[0,1]](seuil):      
   elif n<30 and sigma<>"" then
     var:="z":
     z:=-statevalf[icdf,normald[0,1]](seuil):
   else
     var:="t":
     z:=-statevalf[icdf,studentst[n-1]](seuil):
   fi:
   if Get('THS1')<>"" then
     m2:=Get('THS1'::constant)
   fi:
   t:=evalf((moy-m2)/ecart):
     if t<z then
       Set('TB2'=cat("Zone de rejet : \n",var,"c < ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n",var,"c < ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     fi:
     g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
     g2 := plot( f(x), x = min(t,-3.5)..z, color=grey,filled=true):
     g3 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
     g4 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
     g5 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
     graph:=plots[display]([g3,g2,g1,g4,g5], xtickmarks=[10], ytickmarks=[10],axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
   elif Get('RH3')=true then
     if n>=30 then
       var:="z":
       z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):      
     elif n<30 and sigma<>"" then
       var:="z":
       z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):
     else
       var:="t":
       z:=statevalf[icdf,studentst[n-1]]((1+seuil)/2):
     fi:
     if Get('THD1')<>"" then
       m3:=Get('THD1'::constant)
     fi:
     t:=evalf((moy-m3)/ecart):
     if t>z or t<-z then
       Set('TB2'=cat("Zone de rejet : \n", var, "c < ", convert(-z,CaractDec), "  et  ", var, "c > ", convert(z,CaractDec), "\n", "\nValeur obtenue : \n", var, " = ", convert(t,CaractDec), "\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n", var, " < ", convert(-z,CaractDec), "  et  ", var, "c > ", convert(z,CaractDec), "\n", "\nValeur obtenue : \n", var, " = ", convert(t,CaractDec), "\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,string)))
     fi:  
     g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
     g2 := plot( f(x), x = min(t,-3.5)..-z,  color = grey, filled = true):
     g3 := plot( f(x), x = z..max(t,3.5),  color = grey, filled = true):
     g4 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
     g5 := plots[textplot]([-z,-.03,cat(var,"c = ",convert(evalf(-z,3),CaractDec))], align=ABOVE):
     g6 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
     g7 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
     graph:=plots[display]([g4,g1,g2,g3,g5,g6,g7], xtickmarks=[2*abs(max(t,3.5))], ytickmarks=[10], axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
  fi:
end use:
end:

Test_Mu1Mu2 := proc()
local i, ecart, f, m1, m2, m3, t, g1, g2, g3, g4, g5, g6, g7:
global seuil, moy, ecart_type, n, sigma, N, moy1, ecart_type1, n1, sigma1, N1, z, var, graph:
use Maplets[Tools] in
f := x -> exp(-(x^2)/2)/sqrt(2*Pi):
 if Get('RH1')=true then
 if n>=30 and n1>=30 then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]](seuil):      
 elif (n<30 or n1<30) and sigma<>"" then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]](seuil):
 else
   ecart:=sqrt(((n-1)*ecart_type^2+(n1-1)*ecart_type1^2)/(n+n1-2))*sqrt(1/n+1/n1):
   var:="t":
   z:=statevalf[icdf,studentst[n+n1-2]](seuil):
 fi:
     if Get('THI1')<>"" then
       m1:=Get('THI1'::constant)
     else
       return
     fi:
   t:=evalf(((moy-moy1)-m1)/ecart):
     if t>z then
       Set('TB2'=cat("Zone de rejet : \n",var,"c > ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n",var,"c > ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     fi:
   g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
   g2 := plot( f(x), x = z..max(t,3.5), color=grey, filled=true):
   g3 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
   g4 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
   g5 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
   graph:=plots[display]([g3,g2,g1,g4,g5], xtickmarks=[2*abs(max(t,3.5))], ytickmarks=[10],axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
 elif Get('RH2')=true then
 if n>=30 and n1>=30 then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=-statevalf[icdf,normald[0,1]](seuil):      
 elif (n<30 or n1<30) and sigma<>"" then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=-statevalf[icdf,normald[0,1]](seuil):
 else
   ecart:=sqrt(((n-1)*ecart_type^2+(n1-1)*ecart_type1^2)/(n+n1-2))*sqrt(1/n+1/n1):
   var:="t":
   z:=-statevalf[icdf,studentst[n+n1-2]](seuil):
 fi:
   if Get('THS1')<>"" then
     m2:=Get('THS1'::constant)
   else
     return  
   fi:
   t:=evalf(((moy-moy1)-m2)/ecart):
     if t<z then
       Set('TB2'=cat("Zone de rejet : \n",var,"c < ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n",var,"c < ",convert(z,CaractDec),"\n","\nValeur obtenue : \n", var, " = ", convert(t,CaractDec),"\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     fi:
     g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
     g2 := plot( f(x), x = min(t,-3.5)..z, color=grey,filled=true):
     g3 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
     g4 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
     g5 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
     graph:=plots[display]([g3,g2,g1,g4,g5], xtickmarks=[10], ytickmarks=[10],axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
   elif Get('RH3')=true then
 if n>=30 and n1>=30 then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):      
 elif (n<30 or n1<30) and sigma<>"" then
   ecart:=sqrt(ecart_type^2/n+ecart_type1^2/n1):
   var:="z":
   z:=statevalf[icdf,normald[0,1]]((1+seuil)/2):
 else
   ecart:=sqrt(((n-1)*ecart_type^2+(n1-1)*ecart_type1^2)/(n+n1-2))*sqrt(1/n+1/n1):
   var:="t":
   z:=statevalf[icdf,studentst[n+n1-2]]((1+seuil)/2):
 fi:
     if Get('THD1')<>"" then
       m3:=Get('THD1'::constant)
     else
       return
     fi:
     t:=evalf(((moy-moy1)-m3)/ecart):
     if t>z or t<-z then
       Set('TB2'=cat("Zone de rejet : \n", var, "c < ", convert(-z,CaractDec), "  et  ", var, "c > ", convert(z,CaractDec), "\n", "\nValeur obtenue : \n", var, " = ", convert(t,CaractDec), "\n\nOn rejette donc H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     else
       Set('TB2'=cat("Zone de rejet : \n", var, "c < ", convert(-z,CaractDec), "  et  ", var, "c > ", convert(z,CaractDec), "\n", "\nValeur obtenue : \n", var, " = ", convert(t,CaractDec), "\n\nOn ne peut donc pas rejeter H0 avec un seuil de confiance de ", convert(seuil,CaractDec)))
     fi:  
     g1 := plot( f(x), x = min(t,-3.5)..max(t,3.5),color=black):
     g2 := plot( f(x), x = min(t,-3.5)..-z,  color = grey, filled = true):
     g3 := plot( f(x), x = z..max(t,3.5),  color = grey, filled = true):
     g4 := plot( [[t,-.03],[t,.4]],linestyle = 3, color=blue):
     g5 := plots[textplot]([-z,-.03,cat(var,"c = ",convert(evalf(-z,3),CaractDec))], align=ABOVE):
     g6 := plots[textplot]([z,-.03,cat(var,"c = ",convert(evalf(z,3),CaractDec))], align=ABOVE):
     g7 := plots[textplot]([t,-.05,cat(var," = ",convert(evalf(t,3),CaractDec))], align=ABOVE, color=blue):
     graph:=plots[display]([g4,g1,g2,g3,g5,g6,g7], xtickmarks=[2*abs(max(t,3.5))], ytickmarks=[10],axesfont=['HELVETICA',9], font=['HELVETICA',9], labelfont=['HELVETICA',9]):
  fi:
end use:
end:

with(Maplets[Elements]):
Stat:=Maplet('onstartup'=RunWindow('W0'),
Window['W1']('title' = "", 'layout' = 'BL1', resizable = false),
 BoxLayout['BL1'](
   BoxRow('inset'=0, 'spacing'=5,
   BoxColumn('inset'=0, 'spacing'=0,
     Label(" ", font=Font('HELVETICA', 1)),
     Label("Inf?rence statistique", font=Font('HELVETICA', bold, 16)),
     Label(" ", font=Font('HELVETICA', 6)),
     Label['LDA']("Si la taille de l'?chantillon est inf?rieure ? 30 et l'?cart-type de la population", font=Font('HELVETICA', 10)),
     Label['LDB']("est inconnu, on supposera que l'?chantillon provient d'une population normale", font=Font('HELVETICA', 10)),
     Label(" ", font=Font('HELVETICA', 9)),
     BoxRow('inset'=0, 'spacing'=0,
     CheckBox['CBI1'](caption="sur mu", value=true, onchange=Action(SetOption('LDA'(caption)="Si la taille de l'?chantillon est < 30 et l'?cart-type de la population est"), SetOption('LDB'(caption)="inconnu, on supposera que l'?chantillon provient d'une population normale"), SetOption('CBI1'=true),SetOption('CBI2'=false), SetOption('LIC'(caption)="Intervalle de confiance sur mu                                                                    "), SetOption('LTH'(caption)="Test d'hypoth?se sur mu                                                                    "), SetOption('THM1'(visible)=false), SetOption('THE1'(visible)=false), SetOption('THN1'(visible)=false), SetOption('THEP1'(visible)=false), SetOption('THTP1'(visible)=false), SetOption('LS1'(caption)="H0: mu = "), SetOption('LS2'(caption)="H1: mu > "), SetOption('LI1'(caption)="H0: mu = "), SetOption('LI2'(caption)="H1: mu < "), SetOption('LD1'(caption)="H0: mu = "), SetOption('LD2'(caption)="H1: mu<> "), SetOption('LE'(caption)="?chantillon"))),
     CheckBox['CBI2'](caption="sur (mu1-mu2)", onchange=Action(SetOption('LDA'(caption)="Si au moins une des tailles d'?chantillon est < 30 et les ?cart-type des populations sont"), SetOption('LDB'(caption)="inconnus, on supposera qu'ils proviennent de populations normales de variances ?gales"), SetOption('CBI1'=false), SetOption('CBI2'=true), SetOption('LIC'(caption)="Intervalle de confiance sur mu1-mu2                                                                "), SetOption('LTH'(caption)="Test d'hypoth?se sur mu1-mu2                                                                "), SetOption('THM1'(visible)=true), SetOption('THE1'(visible)=true), SetOption('THN1'(visible)=true), SetOption('THEP1'(visible)=true), SetOption('THTP1'(visible)=true), SetOption('LS1'(caption)="H0:mu1-mu2="), SetOption('LS2'(caption)="H1:mu1-mu2>"), SetOption('LI1'(caption)="H0:mu1-mu2="), SetOption('LI2'(caption)="H1:mu1-mu2<"), SetOption('LD1'(caption)="H0:mu1-mu2="), SetOption('LD2'(caption)="H1:mu1-mu2<>"), SetOption('LE'(caption)="?chantillons ind?pendants")))
     ),
Label(" ", font=Font('HELVETICA', 6)),
BoxColumn('inset'=0, 'spacing'=0,
 Label(" ", font=Font('HELVETICA', 4)),
 Label['LE']("?chantillon", font=Font('HELVETICA',bold, 12)),
 Label(" ", font=Font('HELVETICA', 4)),
   BoxRow('inset'=3, 'spacing'=3,
     "? Moyenne : ", TextField['THM'](halign=center, width=20),
   TextField['THM1'](halign=center, width=20, visible=false)
  ),
  BoxRow('inset'=3, 'spacing'=3,
    Label("?cart-type : "),
    TextField['THE'](halign=center, width=20, tooltip="Cette valeur doit ?tre un estimateur non\nbiais? de l'?cart-type de la population."),
    TextField['THE1'](halign=center, width=20, visible=false, tooltip="Cette valeur doit ?tre un estimateur non\nbiais? de l'?cart-type de la population.")
  ),
  BoxRow('inset'=3, 'spacing'=3,
    "??????? ?Taille : ", TextField['THN'](halign=center, width=20),
    TextField['THN1'](halign=center, width=20, visible=false)
  ),
  BoxRow('inset'=3, 'spacing'=3,
    "?cart-type de la population (si connu) : ",
    TextField['THEP'](halign=center, width=10),
    TextField['THEP1'](halign=center, width=10, visible=false)
  ),
  BoxRow('inset'=3, 'spacing'=3,
    "????? ?Taille de la population (si connue) : ",
    TextField['THTP'](halign=center, width=10),
    TextField['THTP1'](halign=center, width=10, visible=false)
  )
),
Label(" ", font=Font('HELVETICA', 12)),
 BoxRow(border=true, 'inset'=0, 'spacing'=0,  
   RadioButton['RI1']('value'=true, 'group'='BH1'),
   Label['LIC']("Intervalle de confiance sur mu                                                                    ",     font=Font('HELVETICA',bold, 12),halign=left)
 ),
 Label(" ", font=Font('HELVETICA', 12)),
   BoxColumn(border=true, 'inset'=0, 'spacing'=0,
     Label(" ",font=Font('HELVETICA',3), width=420),
     Label['LTH']("Test d'hypoth?se sur mu                                                                    ", font= Font('HELVETICA', bold, 12), halign=left, tooltip= "Donnez une valeur ? H0, la valeur de H1 s'ajustera automatiquement."),
     Label(" ",font=Font('HELVETICA',6)),
     BoxRow('inset'=0, 'spacing'=0,
       BoxColumn('inset'=0, 'spacing'=0,
         RadioButton['RH1']('value'=false, 'group'='BH1'),
         BoxColumn('inset'=0, 'spacing'=0,
         BoxRow('inset'=2, 'spacing'=0,  
         Label['LS1']("?H0:   mu = ", font=Font('HELVETICA',10), width = 75),
         TextField['THI1']('value' = "",halign=center, width=6, onchange=Action(SetOption('RI1'(value)='false'), SetOption('RH1'(value)='true'), SetOption('RH2'(value)='false'), SetOption('RH3'(value)='false'), Evaluate('THS1'=""), Evaluate('THD1'=""), Evaluate('THS2'=""), Evaluate('THD2'="")))
         ),
         BoxRow('inset'=0, 'spacing'=0,  
         Label['LS2']("?H1:   mu > ", font=Font('HELVETICA',10), width = 75),
         TextField['THI2']('value' = "",halign=center, width=6, editable=false)
         )
       )
     ),
     BoxColumn( 'inset'=0, 'spacing'=0,
       RadioButton['RH2']('value'=false, 'group'='BH1'),
       BoxColumn('inset'=0, 'spacing'=0,
         BoxRow('inset'=2, 'spacing'=0,  
         Label['LI1']("?H0:   mu = ", font=Font('HELVETICA',10), width = 75),
         TextField['THS1']('value' = "",halign=center, width=6, onchange=Action(SetOption('RI1'(value)='false'), SetOption('RH1'(value)='false'), SetOption('RH2'(value)='true'), SetOption('RH3'(value)='false'), Evaluate('THI1'=""), Evaluate('THD1'=""), Evaluate('THI2'=""), Evaluate('THD2'="")))
         ),
         BoxRow('inset'=0, 'spacing'=0,  
         Label['LI2']("?H1:   mu < ", font=Font('HELVETICA',10), width = 75),
         TextField['THS2']('value' = "",halign=center, width=6, editable=false)
         )
       )
     ),
     BoxColumn('inset'=0, 'spacing'=0,
     RadioButton['RH3']('value'=false, 'group'='BH1'),
     BoxColumn('inset'=0, 'spacing'=0,
       BoxRow('inset'=2, 'spacing'=0,  
       Label['LD1']("?H0:   mu = ", font=Font('HELVETICA',10), width = 75),
       TextField['THD1']('value' = "",halign=center, width=6, onchange=Action(SetOption('RI1'(value)='false'), SetOption('RH1'(value)='false'), SetOption('RH2'(value)='false'), SetOption('RH3'(value)='true'), Evaluate('THI1'=""), Evaluate('THS1'=""), Evaluate('THI2'=""), Evaluate('THS2'="")))
       ),
       BoxRow('inset'=0, 'spacing'=0,  
       Label['LD2']("?H1:   mu <> ", font=Font('HELVETICA',10), width = 75),
       TextField['THD2']('value' = "",halign=center, width=6, editable=false)
       )
     )
   )
 )
),
Button("", onclick=Evaluate('TB1'=""), visible=false, enabled=false),
Label(" ", font=Font('HELVETICA', 10)),
 BoxRow(border=true, 'inset'=10, 'spacing'=0,
   Label("       Seuil de confiance : ", font=Font('HELVETICA', bold, 12)),
   TextField['TH1']('value'=".95",'width'=6, halign=center),
   Label("                                              ")
 ),
 BoxRow('inset'=10, 'spacing'=0,
   Button("Calculer",font=Font('HELVETICA',12), onclick = Evaluate('PL2' = 'choix()')),
   Label("                ", font=Font('HELVETICA', 12)),
   Button("Effacer",font=Font('HELVETICA',12), onclick = Action(Evaluate('THM' = ""), Evaluate('THM1' = ""), Evaluate('THE' = ""), Evaluate('THE1' = ""), Evaluate('THN' = ""), Evaluate('THN1' = ""), Evaluate('THEP' = ""), Evaluate('THEP1' = ""), Evaluate('THTP' = ""), Evaluate('THTP1' = "")))
 )
),
BoxColumn('inset'=0, 'spacing'=0,
 BoxRow(border=true, 'inset'=0, 'spacing'=0,
   Plotter['PL2'](width=325,height=338)
 ),
 TextBox['TB2'](width=28, height=9, font=Font('HELVETICA',12)),
 TextField['TB2X'](visible=false),
 Button("Fermer",font=Font('HELVETICA',12), onclick = Action(CloseWindow('W1'), Evaluate('PL2'='plot(0,x=1..10,1..10,axes=NONE)'), Evaluate('TB2'=""), Evaluate('THI1'=""), Evaluate('THS1'=""), Evaluate('THD1'=""), Evaluate('THI2'=""), Evaluate('THS2'=""), Evaluate('THD2'=""), SetOption('RI1'=true), SetOption('RH1'=false), SetOption('RH2'=false), SetOption('RH3'=false), SetOption('CBI1'=true), SetOption('CBI2'=false), Evaluate('THT1'=""), Evaluate('THT2'=""),  SetOption('BH'(enabled)=false)))
)
)
),
ButtonGroup['BH1'](onchange=Action(Evaluate('THI1'=""), Evaluate('THS1'=""), Evaluate('THD1'=""), Evaluate('THI2'=""), Evaluate('THS2'=""), Evaluate('THD2'=""))),

Window['W0']('title' = "Analyse statistique", 'layout' = 'BL0', 'menubar'='MB1', resizable = false),
BoxLayout['BL0'](
 BoxRow('inset'=0, 'spacing'=0, caption= "",
   BoxColumn('inset'=10, 'spacing'=5,
     TextField['X'](visible=false),
     Label("?chantillon A", font=Font('HELVETICA', bold, 12)),      TextBox['TF0'](value=".745879\n.750469\n.754489\n.754091\n.757805\n.759648\n.757174\n.758265\n.754205\n.756144\n.755287\n.763825\n.764409\n.763417\n.755173\n.761267\n.756487\n.750751\n.748895\n.751371\n.754205\n.752106\n.751089\n.758438\n.760341\n.75884\n.763359\n.75959\n.761093\n.755287\n.750582\n.763825\n.76476\n.764526\n.764877\n.771367\n.770416\n.765404\n.766401\n.76646\n.762021\n.763126\n.759071\n.759532\n.765052\n.769527\n.768935\n.776277\n.774893\n.776518\n.776398\n.769231\n.773994\n.770001\n.774353\n.769112\n.772559\n.776036\n.780275\n.78235\n.783515\n.785053\n.784068\n.785546\n.790639\n.791828\n.785793\n.792079\n.794155\n.795102\n.799233\n.795229\n.791139\n.798212\n.798722\n.796813\n.797321\n.804376\n.804764\n.80782\n.817528\n.816593\n.816127\n.820075\n.819068\n.817728\n.815461\n.825014\n.829669\n.834655\n.838574\n.83682\n.834934\n.838997\n.831117\n.838082\n.838574\n.8285\n.838364\n.842815\n.846525\n.849257\n.844167\n.840195\n.843455\n.840407\n.835003\n.832501\n.827267\n.81646\n.816127\n.814797\n.813935\n.80795\n.817728\n.808865\n.81586\n.813206\n.81493\n.806387", width = 10, height=6, wrapped=false, tooltip="Taper ou copier et coller des donn?es"),
     Button("", visible=false, enabled=false, Evaluate('TF1' = "")),
     Button("Statistique\ndescriptive", width=100, font=Font('HELVETICA',12), Action(SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), Evaluate('TB1'='A()'), Evaluate('PL1'='histo()'), SetOption('THT1'(visible)=true), SetOption('THT2'(visible)=true), SetOption('LHT1'(visible)=true), SetOption('LHT2'(visible)=true), SetOption('BH'(visible)=true), SetOption('BH'(enabled)=true))),
     Button("Inf?rence", width=100, height=30,font=Font('HELVETICA',12), Action(Evaluate('TH1'=.95),SetOption('LDA'(caption)="Si la taille de l'?chantillon est < 30 et l'?cart-type de la population est"), SetOption('LDB'(caption)="inconnu, on supposera que l'?chantillon provient d'une population normale"), Evaluate('CBI1'=true),Evaluate('CBI2'=false), SetOption('LIC'(caption)="Intervalle de confiance sur mu                                                                    "), SetOption('LTH'(caption)="Test d'hypoth?se sur mu                                                                    "), SetOption('THM1'(visible)=false), SetOption('THE1'(visible)=false), SetOption('THN1'(visible)=false), SetOption('THEP1'(visible)=false), SetOption('THTP1'(visible)=false), SetOption('LS1'(caption)="?H0:   mu = "), SetOption('LS2'(caption)="?H1:   mu > "), SetOption('LI1'(caption)="?H0:   mu = "), SetOption('LI2'(caption)="?H1:   mu < "), SetOption('LD1'(caption)="?H0:   mu = "), SetOption('LD2'(caption)="?H1:   mu <>"), SetOption('LE'(caption)="?chantillon"), Evaluate('TB2'='A()'), Evaluate('TB2'='init1()'), Evaluate('TB2'='B()'), Evaluate('TB2'='init2()'), Evaluate('THEP'=""), Evaluate('THEP1'=""), Evaluate('THTP'=""), Evaluate('THTP1'=""), RunWindow('W1'))),
     Button("Effacer", width=100, font=Font('HELVETICA',12), Action(SetOption('TF0' = ""))),
     Label(" ", font=Font('HELVETICA',4)),
     Label("?chantillon B", font=Font('HELVETICA',bold, 12)),
TextBox['TF1'](value=".61243\n.617264\n.613057\n.613581\n.611923\n.613114\n.611216\n.611061\n.613075\n.610532\n.610431\n.614155\n.614922\n.616803\n.617779\n.620278\n.624061\n.618666\n.621181\n.623752\n.624859\n.625088\n.624139\n.629357\n.630622\n.629744\n.622033\n.619517\n.618473\n.617974\n.614023\n.618281\n.620093\n.620104\n.621901\n.623679\n.625135\n.627586\n.633442\n.633962\n.630604\n.634616\n.629986\n.623436\n.628173\n.632626\n.638015\n.641923\n.637038\n.637065\n.632143\n.627892\n.630905\n.634059\n.637118\n.631767\n.634702\n.632776\n.636387\n.63616\n.639291\n.637891\n.637143\n.63824\n.636739\n.638572\n.640209\n.64313\n.645759\n.647161\n.643609\n.645478\n.644723\n.644083\n.640104\n.636432\n.637092\n.637029\n.637588\n.639149\n.639543\n.640064\n.641357\n.642742\n.642608\n.641809\n.641944\n.645198\n.644003\n.645119\n.648248\n.647192\n.645983\n.646725\n.642087\n.645722\n.643523\n.638191\n.641981\n.643862\n.643158\n.639116\n.635381\n.633679\n.633796\n.633409\n.623602\n.619835\n.615663\n.616103\n.614831\n.61615\n.611567\n.608396\n.608927\n.608764\n.613659\n.607051\n.609202\n.60223", width = 10, height=6, wrapped=false, tooltip="Taper ou copier et coller des donn?es"),
     Button("Statistique\ndescriptive", width=100, font=Font('HELVETICA',12), Action(SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), Evaluate('TB1'='B()'), Evaluate('PL1'='histo()'), SetOption('THT1'(visible)=true), SetOption('THT2'(visible)=true), SetOption('LHT1'(visible)=true), SetOption('LHT2'(visible)=true), SetOption('BH'(visible)=true), SetOption('BH'(enabled)=true))),
     Button("Inf?rence", width=100, height=30, font=Font('HELVETICA',12), Action(Evaluate('TH1'=.95),SetOption('LDA'(caption)="Si la taille de l'?chantillon est < 30 et l'?cart-type de la population est"), SetOption('LDB'(caption)="inconnu, on supposera que l'?chantillon provient d'une population normale"), Evaluate('CBI1'=true),Evaluate('CBI2'=false), SetOption('LIC'(caption)="Intervalle de confiance sur mu                                                                    "), SetOption('LTH'(caption)="Test d'hypoth?se sur mu                                                                    "), SetOption('THM1'(visible)=false), SetOption('THE1'(visible)=false), SetOption('THN1'(visible)=false), SetOption('THEP1'(visible)=false), SetOption('THTP1'(visible)=false), SetOption('LS1'(caption)="?H0:   mu = "), SetOption('LS2'(caption)="?H1:   mu > "), SetOption('LI1'(caption)="?H0:   mu = "), SetOption('LI2'(caption)="?H1:   mu < "), SetOption('LD1'(caption)="?H0:   mu = "), SetOption('LD2'(caption)="?H1:   mu <>"), SetOption('LE'(caption)="?chantillon"), Evaluate('TB2'='B()'), Evaluate('TB2'='init1()'), Evaluate('TB2'='A()'), Evaluate('TB2'='init2()'), Evaluate('THEP'=""), Evaluate('THEP1'=""), Evaluate('THTP'=""), Evaluate('THTP1'=""), RunWindow('W1'))),
     Button("Effacer", width=100, font=Font('HELVETICA',12), Action(SetOption('TF1' = "")))
   ),
   BoxColumn('inset'=5, 'spacing'=0,
     Label(" ", font=Font('HELVETICA',2)),
     Label("Corr?lation et r?gression", font=Font('HELVETICA',bold,14)),
     Label("  ", font=Font('HELVETICA',6)),
     BoxColumn(border=true,
       Label("Donn?es chronologiques", font=Font('HELVETICA', bold, 12)),
       Label("?tude de la d?pendance d'un ?chantillon\nen fonction du temps.", font=Font('HELVETICA',10)),
       BoxRow(
         CheckBox['RB1'](caption="?chantillon A", font=Font('HELVETICA',12), 'value'=true,  onchange=Action(SetOption('LRY'(caption)=" = A"), SetOption('RB1'(value)=true), SetOption('RB2'(value)=false), SetOption('TF2' = ""), SetOption('TF3' = ""), SetOption('TF5' = ""), SetOption('TF6' = ""), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false))),
         CheckBox['RB2'](caption="?chantillon B", font=Font('HELVETICA',12), 'value'=false, onchange=Action(SetOption('LRY'(caption)=" = B"), SetOption('RB1'(value)=false), SetOption('RB2'(value)=true), SetOption('TF2' = ""), SetOption('TF3' = ""), SetOption('TF5' = ""), SetOption('TF6' = ""), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false)))
       ),
       BoxRow('inset'=0, 'spacing'=0,
         Label("          R?gression", font=Font('HELVETICA',12)),
         DropDownBox['DB1'](["lineaire", "quadratique", "cubique", "biquadratique", "exponentielle"], value="lineaire", font=Font('HELVETICA',12), onchange=Action(SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false))),
         Label("      ", font=Font('HELVETICA',12))
       ),
       Label(" ", font=Font('HELVETICA',4)),
       BoxRow('inset'=0, 'spacing'=0,
         Label['LRT'](" t = ", font=Font('HELVETICA',12)),
         TextField['TF2'](value="", halign=center, width=8),
         Label(" ", font=Font('HELVETICA',4)),
         Button['BR1']("Calculer", Action(Evaluate('PL1'='regr1()'), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false)), font=Font('HELVETICA',12)),
         Label(" ", font=Font('HELVETICA',4)),
         TextField['TF3'](halign=center, editable=false, width=8),
         Label['LRY'](" = A", font=Font('HELVETICA',12))
       )
     ),
   Label(" ", font=Font('HELVETICA',6)),
   BoxColumn(border=true,'inset'=0, 'spacing'=0,
   Label("Donn?es quelconques", font=Font('HELVETICA', bold,12)),
   Label("?tude de la d?pendance d'un ?chantillon\nen fonction de l'autre ?chantillon.", font=Font('HELVETICA',10)),
     BoxColumn(
       BoxRow(
       CheckBox['RT1'](caption="B=f(A)", font=Font('HELVETICA',12), 'value'=true,  onchange=Action(SetOption('LRA'(caption)="A = "), SetOption('LRB'(caption)=" = B"), SetOption('RT1'=true), SetOption('RT2'=false), SetOption('TF2' = ""), SetOption('TF3' = ""), SetOption('TF5' = ""), SetOption('TF6' = ""), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false))),
       CheckBox['RT2'](caption="A=f(B)", font=Font('HELVETICA',12), 'value'=false, onchange=Action(SetOption('LRA'(caption)="B = "), SetOption('LRB'(caption)=" = A"), SetOption('RT1'=false), SetOption('RT2'=true), SetOption('TF2' = ""), SetOption('TF3' = ""), SetOption('TF5' = ""), SetOption('TF6' = ""), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false)))
       ),
       BoxRow('inset'=0, 'spacing'=0,
       Label("          R?gression", font=Font('HELVETICA',12)),
       DropDownBox['DB2'](["lineaire", "quadratique", "cubique", "biquadratique", "exponentielle"], value="lineaire", font=Font('HELVETICA',12), onchange=Action(SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false))),
       Label("      ", font=Font('HELVETICA',12))
       ),
       Label(" ", font=Font('HELVETICA',4)),
       BoxRow('inset'=0, 'spacing'=0,
       Label['LRA']("A = ", font=Font('HELVETICA',12)),
       TextField['TF5'](value="",halign=center, width=8),
       Label(" ", font=Font('HELVETICA',4)),
       Button['BR2']("Calculer", Action(Evaluate('PL1'='regr2()'), SetOption('THT1'(value)=""), SetOption('THT2'(value)=""), SetOption('THT1'(visible)=false), SetOption('THT2'(visible)=false), SetOption('LHT1'(visible)=false), SetOption('LHT2'(visible)=false), SetOption('BH'(visible)=false)), font=Font('HELVETICA',12)),
       Label(" ", font=Font('HELVETICA',4)),
       TextField['TF6'](halign=center, width=8, editable=false),
       Label['LRB'](" = B", font=Font('HELVETICA',12))
       )
     )
   ),
     Label(" ", font=Font('HELVETICA',4)),
     BoxRow('inset'=0, 'spacing'=0,
     Label(" ", font=Font('HELVETICA',4)),
     Button("Coefficient de corr?lation", Action(Evaluate('X'='corr()')), font=Font('HELVETICA',12)),
     TextField['TF9'](halign=center, editable=false, width=8),
     Label(" ", font=Font('HELVETICA',4))
     ),
     Label(" ", font=Font('HELVETICA',italic,4)),
     Label("? Andr? L?vesque", font=Font('HELVETICA',italic,10))
     ),
     BoxColumn(
     BoxRow(border=true, 'inset'=0, 'spacing'=0,
     Plotter['PL1'](width=330, height=280)
     ),
     BoxRow(border=true,'inset'=0, 'spacing'=0,
       Label['LHT1']("Fronti?re\ninf?rieure", tooltip="Lorsqu'un ?l?ment se trouve sur une fronti?re,\nil est comptabilis? dans la classe sup?rieure.", visible=false, font=Font('HELVETICA',9)),
       TextField['THT1'](halign=center, tooltip="Fixez la fronti?re inf?rieure\nde la premi?re classe.", visible=false, width=6),
       Button['BH']("TRACER", visible=false, onclick= Evaluate('PL1'='histo()')),
       TextField['THT2'](halign=center, tooltip="Fixez la largeur des classes.", visible=false, width=6),
       Label['LHT2']("Largeur\nclasses", visible=false, font=Font('HELVETICA',9))
     ),
     TextBox['TB1'](height=10, font=Font('HELVETICA',12))
     )
   )
 ),
 MenuBar['MB1'](
   Menu("Fichier",
       MenuItem("Fermer", Shutdown())
   )
 )
):

Maplets[Display](Stat):
if graph<>plot(0,x=1..2,1..2,axes=NONE) then graph fi;