Estadística en Microcomputadores/Archivos BASIC/ESTAD4
10 ' ESTAD4 - Revision 30/ 5/89
15 ' -------------------------
20 GOSUB 1000
25 CHAIN "ESTAD"
200 ' EST91 Definicion de Variables
205 ' ---------------------------
210 GOSUB 500
215 IF NV=0 THEN 265
220 PRINT
225 GOSUB 730
255 INPUT " Definicion de Nuevas Variables ? (N) = ",A$
260 IF A$<>"S" AND A$<>"s" THEN RETURN
265 PRINT
270 K=0
273 IF KNV=0 THEN KNV=NC
275 WHILE K<=KNV-1
280 K=K+1 : NV=K
290 PRINT " Variable Nro.";K; : INPUT "= ",A$
295 IF LEN(A$)=0 AND K=1 THEN NV=0 : RETURN
300 IF LEN(A$)=0 THEN NV=K-1 : K=KNV : GOTO 320
305 J=VAL(A$)
310 IF J<1 OR J>NC THEN KE=4 : GOSUB 900 : GOTO 290
311 IF K=1 THEN 318
312 FOR M=1 TO K-1
313 IF J=JX(M) THEN PRINT CHR$(7) : PRINT :
INPUT "** VARIABLE REPETIDA",A$ : PRINT : GOTO 290
315 NEXT M
318 JX(K)=J
320 WEND
324 IF KDA=1 THEN JF=0 : KDA=0 : NX=NF : RETURN
325 PRINT
330 INPUT " Variable para Observaciones Agrupadas (No) = ",A$
335 IF LEN(A$)=0 THEN JF=0 : GOTO 350
340 JF=VAL(A$)
345 IF JF<1 OR JF>NC THEN KE=4 : GOSUB 900 : GOTO 330
347 IF JF=0 THEN NX=NF : RETURN
350 KE=0 : NX=0
355 FOR I=1 TO NF
370 ND=1 : IF JF>0 THEN ND=A(I,JF)
372 IF ND=XVF THEN 380
373 IF ND<0 THEN KE=1
375 NX=NX+ND
380 NEXT I
383 IF KE=1 THEN PRINT : PRINT CHR$(7) : PRINT "** VALOR <0 EN VARIABLE";JF; :
INPUT "",A$ : GOTO 325
385 RETURN
390 ' EST92 - Seleccion de Variable
395 ' ----------------------------
400 J=0
405 IF NC=0 OR KVA=1 THEN KVA=0 : GOTO 412
410 GOSUB 500
412 PRINT
415 INPUT " Posicion de Variable a utilizar = ",A$
420 IF LEN(A$)=0 THEN RETURN
425 X=VAL(A$)
430 IF X<1 OR X>NCM THEN KE=4 : GOSUB 900 : GOTO 415
435 IF LEN(TC$(X))=0 OR LEFT$(TC$(X),2)=" " THEN 455
440 PRINT : PRINT " Variable";X;" actual = ",TC$(X)
445 INPUT " Se utiliza ? (N) = ",A$
450 IF A$<>"S" AND A$<>"s" THEN 415
451 PRINT : INPUT " Borrado de Datos existentes ? (N) = ",A$
452 IF A$="S" OR A$="s" THEN FOR I=1 TO NFM : A(I,X)=0 : NEXT I
455 PRINT : PRINT " Nombre de la Variable";X; : INPUT " = ",A$
460 IF LEN(A$)=0 AND TC$(X)<>" " THEN 485
465 IF LEN(A$)=0 OR LEFT$(A$,8)=" " THEN 415
470 TC$(X)=LEFT$(A$,8)
485 IF NC<X THEN NC=X
490 J=X
495 RETURN
500 ' EST93 - Variables en memoria
505 ' ----------------------------
510 PRINT : PRINT " Variables en Memoria" : PRINT
515 I=1
520 FOR L=1 TO NC
525 IF LEFT$(TC$(L),2)=" " THEN 540
530 PRINT TAB(15*I-11);L;"-";TC$(L);
535 I=I+1 : IF I>5 THEN I=1 : PRINT
540 NEXT L
545 PRINT
550 RETURN
555 ' EST94 Encabezamiento Pantallas y Resultados
560 ' -------------------------------------------
565 IF DS$="SCRN:" THEN PRINT CHR$(12);
570 PRINT#3,"Proceso : ";TP$;TAB(70);DATE$
575 IF TSP$>"" THEN PRINT#3,TAB(11);TSP$ ELSE PRINT
577 A$=NA$ : IF NF=0 THEN A$="No hay Datos en Memoria"
580 PRINT#3,"Datos : ";A$;" - ";N$
583 IF JF>0 THEN PRINT#3,TAB(11);"Variable para Observaciones Agrupadas = ";
JF;"-";TC$(JF)
585 IF CD$>"" THEN PRINT#3,TAB(11);"Condicion de Seleccion = ";CD$
590 IF NX>0 THEN PRINT#3,TAB(11);"Numero de Observac.: ";
595 IF NX>0 THEN PRINT#3,"Totales =";NX;
597 IF NXX>0 THEN PRINT#3," / Consideradas =";NXX ELSE PRINT#3,
600 KA=1 : KB=79 : GOSUB 695
605 PRINT#3,
610 RETURN
650 ' EST95 Seleccion de Dispositivo de Salida
655 ' ----------------------------------------
660 CLOSE#3 : KS=0 : DS$="SCRN:"
665 PRINT : INPUT "Salida por Impresora/I/ o a un Archivo/Nombre/ (No) = ",A$
670 IF LEN(A$)=0 THEN OPEN DS$ FOR OUTPUT AS #3 : RETURN
673 KS=1 : DS$="LPT1:"
675 IF A$="i" OR A$="I" THEN OPEN DS$ FOR OUTPUT AS#3 : RETURN
680 DS$=A$
685 OPEN DS$+".TXT" FOR APPEND AS #3
690 RETURN
695 ' EST96 Subrayado
700 ' ---------------
705 PRINT#3,TAB(KA);
710 FOR S=KA TO KB : PRINT#3,TAB(S);"-"; : NEXT S : PRINT#3,
715 RETURN
730 ' EST97 - Variables definidas
735 ' ---------------------------
740 I=1
743 IF KX=0 THEN PRINT#3," Variables ya Definidas" : PRINT#3,
745 IF KX=1 THEN PRINT#3," Variables Consideradas" : PRINT#3,
750 FOR K=1 TO NV
755 J=JX(K)
760 PRINT#3,TAB(15*I-11);J;"-";TC$(J);
765 I=I+1 : IF I>5 THEN I=1 : PRINT#3,
770 NEXT K
773 PRINT#3, : PRINT#3, : KX=0
775 RETURN
900 ' EST99 - SUBRUTINA DE MENSAJES
905 ' -----------------------------
910 PRINT CHR$(7) : PRINT
911 IF KE=1 THEN INPUT "** NO HAY DATOS EN MEMORIA ",A$ : KE=0 : RETURN
912 IF KE=2 THEN INPUT "** NUMERO DE VARIABLES NO ADECUADO PARA EL PROCESO ",A$
- KE=0 : RETURN
915 IF KE=3 THEN INPUT "** NUMERO DE OBSERVAC.INSUFICIENTE PARA EL PROCESO ",A$
- KE=0 : RETURN
928 IF KE=9 THEN INPUT "** PROCESO NO ADECUADO A LOS DATOS CONSIDERADOS ",A$ :
KE=0 : RETURN
929 IF KE=4 THEN INPUT "** VARIABLE NO EXISTENTE O SIN DATOS ",A$ :
KE=0 : RETURN
930 IF KE=5 THEN PRINT "** VALOR ERRONEO - Debe ser ";B$ : INPUT " ",A$ :
KE=0 : RETURN
931 IF KE=6 THEN INPUT "** CAPACIDAD INSUFICIENTE DE MEMORIA DE TRABAJO",A$ :
KE=0 : RETURN
934 INPUT "Valor Erroneo ",A$
935 RETURN
936 IF ERR<>53 THEN PRINT CHR$(7) : PRINT
937 IF ERR<>53 THEN KE=KE+1 : IF KE>1 THEN RESUME 948
938 IF ERR=25 OR ERR=57 OR ERR=68 OR ERR=70 OR ERR=71 THEN PRINT "** DISPOSITIVO ";XDDA$;
" NO DISPONIBLE O ERROR E/S"; : INPUT " ",A$ : RESUME NEXT
939 IF ERR=61 THEN PRINT "** DISCO ";XDDA$;" LLENO" : INPUT " ",A$ : RESUME
940 IF ERR=53 THEN KAR=1 : RESUME NEXT
941 IF ERR=62 THEN PRINT "** FIN DE GRABACION O LECTURA EN DISP. ";XDDA$; : INPUT "
",A$ : RESUME NEXT
942 IF ERR=2 OR ERR=22 THEN PRINT "** ERROR DE SINTAXIS EN FUNCION "; : INPUT "O
CONDICION",A$ : RESUME NEXT
943 IF ERR=24 OR ERR=27 THEN INPUT "** PROBLEMA EN IMPRESORA",A$ : RESUME NEXT
944 IF ERR=64 OR ERR=75 OR ERR=76 THEN INPUT "** NOMBRE INCORRECTO ARCHIVO",A$ : RESUME
947 PRINT "Error";ERR;"en linea";ERL :STOP
948 CHAIN"ESTAD"
950 ' EST98 - Descripcion Archivo
952 ' ---------------------------
954 LD=0
956 IF MID$(A$,2,1)<>":" THEN XDDA$=DDA$+":" : GOTO 964
958 B$=LEFT$(A$,1)
960 'IF INSTR("ABCabc",B$)=0 THEN GOSUB 900 : RETURN
962 XDDA$="" : LD=2
964 B$=RIGHT$(A$,4)
966 IF LEFT$(B$,1)<>"." THEN EXT$=XA$ ELSE EXT$="" : LD=LD+4
968 'IF LEN(A$)-LD>8 THEN GOSUB 900
970 KAR=0 : KE=0
972 OPEN XDDA$+A$+EXT$ FOR INPUT AS#1
974 CLOSE#1
978 RETURN
980 ' EST9. - Presentacion Menu
982 ' -------------------------
983 PRINT : ISP=0 : A$=""
984 FOR K=1 TO KL
986 PRINT " ";K;"- ";TF$(K)
988 NEXT K
990 PRINT : PRINT "Opcion Elegida = ";
991 B$=INKEY$ : PRINT B$;
992 IF B$=CHR$(13) THEN 996
993 IF B$=CHR$(27) THEN A$="" : GOTO 996
994 A$=A$+B$ : GOTO 991
996 IF LEN(A$)=0 THEN RETURN
997 ISP=INT(VAL(A$))
998 IF ISP<1 OR ISP>KL THEN PRINT CHR$(7) : GOTO 983
999 RETURN
1000 ' EST4 - Pruebas Estadisticas
1005 ' ---------------------------
1010 DEFINT I-N
1015 COMMON ITE,NFM,NCM,A(),TC$(),NC,NF,NX,DDA$,NDE,NV,JX(),P(),DA$,NA$,CD$,
PAR1,PAR2,XVF
1020 ON ERROR GOTO 936
1025 DIM TF$(15),VX(2*NFM),NVC(2),VC(PAR1,2),TI(PAR1,2),VY(NFM)
1030 DIM NXV(2),PM(2),DE(2),NP(15),TG$(5),TP(5),KF(5)
1035 DEF FNR(X,DE)=INT(10^DE*X+.5)/10^DE
1040 CLOSE : DS$="SCRN:" : OPEN DS$ FOR OUTPUT AS#3
1045 WHILE KW=0
1050 TP$="PRUEBAS ESTADISTICAS" : TSP$=""
1055 NXX=0
1060 GOSUB 555
1065 PRINT TAB(70);FRE(0)
1070 PRINT "PROCESOS"
1075 TF$(1)="Pruebas Parametricas"
1080 TF$(2)="Pruebas no Parametricas"
1083 TF$(3)="Calculo de Tamano de Muestras"
1085 TF$(4)="Manejo de Datos"
1090 KL=4 : GOSUB 980
1095 IF ISP=0 THEN RETURN
1100 IKP=ISP
1105 IF ISP=4 THEN CHAIN "ESTAD1"
1110 ON ISP GOSUB 1125,3135,4700
1115 WEND
1120 '
1125 ' EST41 - Pruebas Parametricas
1130 ' ----------------------------
1135 TSP$="Pruebas Parametricas (Poblaciones Normales)"
1140 WHILE KW=0
1145 GOSUB 555
1150 TF$(1)="Mu" : TF$(2)="Sigma"
1155 TF$(3)="Mu1-Mu2 (Indep.)" : TF$(4)="Sigma1/Sigma2"
1160 TF$(5)="Mu1-Mu2 (Relac.)" : TF$(6)="Coef. Correlacion Ro"
1165 PRINT : PRINT "TIPO DE PRUEBA"
1170 PRINT : PRINT " Una Variable"
1175 PRINT " 1 - ";TF$(1)
1180 PRINT " 2 - ";TF$(2)
1185 PRINT : PRINT " Dos Variables Independientes"
1190 PRINT " 3 - ";TF$(3)
1195 PRINT " 4 - ";TF$(4)
1200 PRINT : PRINT " Dos Variables Relacionadas"
1205 PRINT " 5 - ";TF$(5)
1210 PRINT " 6 - ";TF$(6)
1215 PRINT : INPUT "Opcion elegida = ",A$
1220 IF LEN(A$)=0 THEN RETURN
1225 ISP=VAL(A$)
1230 IF ISP<1 OR ISP>6 THEN PRINT CHR$(7) : GOTO 1215
1235 IF ISP<=2 THEN KNV=1 ELSE KNV=2
1240 KTV=1 : IF ISP=3 OR ISP=4 THEN KTV=2
1245 C$=TF$(ISP) : ITP=ISP : GOSUB 555
1250 PRINT : PRINT "PRUEBA SOBRE ";C$
1255 IF MB=0 THEN 1275
1260 GOSUB 2340
1265 PRINT : INPUT "Definicion de nuevas Variables/Estadisticas ? (N) = ",A$
1270 IF A$<>"S" AND A$<>"s" THEN 1305
1275 MB=1
1280 PRINT : INPUT "Ingreso Directo Estadisticas Muestras ? (N) = ",A$
1285 IF A$="S" OR A$="s" THEN MB=2
1290 IF MB=1 AND NF=0 THEN KE=1 : GOSUB 900 : RETURN
1295 GOSUB 1815
1300 IF NXV(1)<2 OR (KNV=2 AND NXV(2)<2) THEN KE=3 : GOSUB 900 : RETURN
1305 IF ITP<>3 THEN 1320
1310 PRINT : INPUT "Variancias Iguales ? (N) = ",A$
1315 MV=0 : IF A$="S" OR A$="s" THEN MV=1
1320 PRINT : INPUT "Calculo de Intervalo de Confianza ? (N) = ",A$
1325 JP=1 : IF A$="S" OR A$="s" THEN JP=3
1330 '
1335 WHILE JP<3
1340 GOSUB 2340
1343 PRINT : PRINT "HIPOTESIS NULA" : PRINT
1345 PRINT " ";C$;
1350 IF ITP=6 THEN XKP=0 : PRINT XKP : GOTO 1415
1355 INPUT " = ",A$
1360 IF LEN(A$)=0 THEN RETURN
1365 XKP=VAL(A$)
1370 IF (ITP=2 OR ITP=4) AND XKP<=0 THEN KE=5 : B$=">0" : GOSUB 900 :
GOTO 1343
1415 ON ITP GOSUB 2415,2525,2640,2815,2935,3045
1420 IP=1 : GOSUB 8060
1425 IF FP>=.5 THEN FPS=1-FP : KH=1
1430 IF FP<.5 THEN FPS=FP : KH=2
1435 FPD=2*FPS
1440 KS=1
1445 WHILE KS=1
1450 GOSUB 555
1455 GOSUB 2340
1460 PRINT#3,
1465 PRINT#3,"PRUEBA SOBRE ";C$
1470 IF ITP=3 AND MV=1 THEN PRINT#3," Variancias Iguales"
1475 IF ITP=3 AND MV=0 THEN PRINT#3," Variancias Desiguales"
1480 PRINT#3,
1485 PRINT#3," Hipotesis Nula"
1490 PRINT#3," ";C$;" = ";XKP
1495 B$=" >" : IF KH=2 THEN B$=" <"
1515 PRINT#3,
1520 PRINT#3," Valor Estadistica de Prueba = ";FNR(X,NDE)
1523 PRINT#3,
1525 PRINT#3," Nivel de Significacion Alfa"
1526 PRINT#3," Hipotesis Alternativa ";C$;B$;XKP;" = ";
FNR(FPS*100,NDE-1);" %"
1527 PRINT#3," Hipotesis Alternativa ";C$;"<>";XKP;" = ";
FNR(FPD*100,NDE-1);" %"
1530 GOSUB 650
1535 WEND
1540 IF ITP=6 THEN 1710
1545 PRINT : PRINT "CALCULO DE RIESGOS BETA"
1550 NVB=0
1555 PRINT : PRINT " Hipotesis Alternativa"
1560 PRINT TAB(6);C$; : INPUT" = ",A$
1565 IF LEN(A$)=0 THEN 1585
1570 NVB=NVB+1
1575 VX(NVB)=VAL(A$)
1580 GOTO 1560
1585 IF NVB=0 THEN 1710
1590 KS=1
1595 WHILE KS=1
1600 PRINT#3, : PRINT#3,"CALCULO DE RIESGOS BETA" : PRINT#3,
1605 PRINT#3,TAB(3);C$;TAB(25);"Beta (%)"
1607 PRINT#3,TAB(20);C$;B$;XKP;TAB(38);C$;"<>";XKP
1610 KA=3 : KB=50 : GOSUB 695
1615 FOR M=1 TO NVB
1620 XKA=VX(M)
1630 IF KH=1 THEN XS=-1E+10 : XT=X
1635 IF KH=2 THEN XS=X : XT=1E+10
1637 JP=2 : ON ITP GOSUB 2415,2525,2640,2815,2935,3045
1638 X=XC : GOSUB 8060 : FPS=FP
1640 X=XD : GOSUB 8060 : FPS=FP-FPS
1641 PRINT#3,TAB(3);XKA,FNR(FPS*100,NDE-1);
1643 IF M>1 THEN 1665
1645 IF ITP=1 OR ITP=3 OR ITP>=5 THEN XT=ABS(X) : XS=-XT : GOTO 1665
1650 FPX=1-FP : XX=X : GOSUB 7710
1655 IF FPX<.5 THEN XS=X : XT=XX
1660 IF FPX>=.5 THEN XS=XX : XT=X
1665 JP=2 : ON ITP GOSUB 2415,2525,2640,2815,2935,3045
1670 X=XC : GOSUB 8060 : FPD=FP
1680 X=XD : GOSUB 8060 : FPD=FP-FPD
1690 PRINT#3,TAB(26);FNR(FPD*100,NDE-1)
1695 NEXT M
1700 GOSUB 650
1705 WEND
1710 PRINT : INPUT "Calculo de Intervalo de Confianza ? (N) = ",A$
1715 JP=4 : IF A$="S" OR A$="s" THEN JP=3
1720 WEND
1725 '
1730 WHILE JP=3
1735 PRINT : INPUT " Nivel de Significacion Alfa en % = ",A$
1740 IF LEN(A$)=0 THEN JP=0 : GOTO 1800
1745 AL=VAL(A$)/100
1750 IF AL<=0 OR AL>=1 THEN KE=5 : B$=">0 y <100" : GOSUB 900 : GOTO 1735
1755 ON ITP GOSUB 2415,2525,2640,2815,2935,3045
1760 KS=1
1765 WHILE KS=1
1770 PRINT#3, : PRINT#3,"Intervalo de Confianza para Alfa = ";100*AL;" %"
1775 PRINT#3,
1780 PRINT#3," ";FNR(XC,NDE);" <= ";C$;" <= ";FNR(XD,NDE)
1785 PRINT#3,
1790 GOSUB 650
1795 WEND
1800 WEND
1805 WEND
1810 '
1815 ' EST400 - Ingreso datos muestras
1820 ' ------------------------------
1825 XX=MB : YY=KTV : KVI=0
1830 NXV(1)=0 : NXV(2)=0 : PM(1)=0 : PM(2)=0 : DE(1)=0 : DE(2)=0
1835 WHILE MB=2
1840 FOR K=1 TO KNV
1845 PRINT : PRINT "Datos Variable";K
1850 IF K=2 AND KTV=1 THEN NXV(2)=NXV(1) : GOTO 1875
1855 INPUT " Numero de Observaciones = ",A$
1860 IF LEN(A$)=0 THEN RETURN
1865 NXV(K)=VAL(A$)
1870 IF NXV(K)<2 THEN KE=5 : B$=">=2" : GOSUB 900 : GOTO 1855
1875 INPUT " Promedio = ",A$
1880 PM(K)=VAL(A$)
1885 INPUT " Desvio Estandar = ",A$
1890 DE(K)=VAL(A$)
1895 IF DE(K)<=0 THEN KE=5 : B$=">0" : GOSUB 900 : GOTO 1885
1900 NEXT K
1905 IF KTV=2 OR KNV=1 THEN 1930
1910 PRINT : INPUT " Coeficiente de Correlacion 1-2 = ",A$
1915 R=VAL(A$)
1920 IF R<=-1 OR R>=1 THEN KE=5 : B$=">-1 y <1" : GOSUB 900 : GOTO 1910
1930 MB=0
1935 WEND
1940 WHILE MB=1
1945 PRINT : PRINT "DEFINICION DE VARIABLES (";KNV;")"
1950 IF KTV<2 THEN 1980
1955 PRINT : INPUT "Muestras en Variables distintas ? (N) = ",A$
1960 KVI=1 : IF A$="S" OR A$="s" THEN KVI=2
1965 IF KVI=1 THEN PRINT
1970 IF KVI=1 THEN PRINT " La primera Variable define las dos muestras"
1975 IF KVI=1 THEN PRINT " y la segunda contiene los valores a considerar"
1980 PRINT : IF IKP=2 OR KVI=2 THEN KDA=1
1985 GOSUB 200
1990 IF IKP=2 THEN JF=0
1995 IF NV=0 THEN RETURN
2000 IF NV<>KNV THEN KE=2 : GOSUB 900 : GOTO 1985
2005 PRINT : PRINT TAB(25);"EN PROCESO"
2010 WHILE KTV=1
2015 GOSUB 5825
2020 IF NXX<2 THEN RETURN
2025 IF KNV=2 THEN R=TI(2,1)/(DE(1)*DE(2))
2030 NXV(1)=NXX : NXV(2)=NXX
2035 KTV=0
2040 WEND
2045 ZZ=KVI
2050 WHILE KTV=2
2055 WHILE KVI=1
2060 JE=JX(2)
2065 J=JX(1)
2070 GOSUB 5480
2075 PRINT : PRINT
2080 PRINT " (Valores Minimo y Maximo Variable";J;" - ";TC$(J);
" = ";XMI;"-";XMA
2085 FOR M=1 TO 2
2090 PRINT : PRINT "Muestra Nro.";M
2095 PRINT " Definida por los siguientes valores"
2100 PRINT " de la Variable ";JX(1);" - ";TC$(JX(1))
2105 INPUT " >= ",A$
2110 IF LEN(A$)=0 THEN RETURN
2115 VC(1,M)=VAL(A$)
2120 INPUT " < ",A$
2125 X=VAL(A$)
2130 IF X<=VC(1,M) THEN KE=5 : B$=">"+STR$(VC(1,M)) :
GOSUB 900 : GOTO 2120
2135 VC(2,M)=X
2140 PM(M)=0 : DE(M)=0
2145 NEXT M
2147 PRINT : PRINT TAB(25);"EN PROCESO"
2150 FOR I=1 TO NF
2155 IF A(I,0)=1 THEN 2195
2160 ND=1 : IF JF>0 THEN ND=A(I,JF)
2165 IF ND=XVF THEN 2195
2170 X=A(I,JE)
2175 Y=A(I,J)
2177 IF X=XVF OR Y=XVF THEN 2195
2180 FOR M=1 TO 2
2185 IF Y>=VC(1,M) AND Y<VC(2,M) THEN NXV(M)=NXV(M)+ND:PM(M)=PM(M)+ND*X :
DE(M)=DE(M)+ND*X*X
2190 NEXT M
2195 NEXT I
2200 KVI=0
2205 WEND
2210 WHILE KVI=2
2215 FOR I=1 TO NF
2220 IF A(I,0)=1 THEN 2195
2225 X=A(I,JX(1)) : IF X=XVF THEN 2245
2230 NXV(1)=NXV(1)+1
2235 PM(1)=PM(1)+X
2240 DE(1)=DE(1)+X*X
2245 X=A(I,JX(2)) : IF X=XVF THEN 2265
2250 NXV(2)=NXV(2)+1
2255 PM(2)=PM(2)+X
2260 DE(2)=DE(2)+X*X
2265 NEXT I
2270 KVI=0
2275 WEND
2285 FOR M=1 TO 2
2290 IF NXV(M)<2 THEN 2305
2295 PM(M)=PM(M)/NXV(M)
2300 DE(M)=SQR((DE(M)-NXV(M)*PM(M)^2)/(NXV(M)-1))
2305 NEXT M
2307 KTV=0
2310 WEND
2315 MB=0
2320 WEND
2325 MB=XX : KTV=YY : KVI=ZZ
2330 RETURN
2335 '
2340 ' EST401 - Presentacion Estadisticas muestras
2345 ' -------------------------------------------
2350 PRINT#3, : PRINT#3,"Estadisticas Muestras" : PRINT#3,
2355 PRINT#3," Variable Nro.Obs. Promedio Desvio Est."
2360 PRINT#3,
2365 FOR K=1 TO KNV
2370 IF MB=1 THEN A$=TC$(JX(K))
2375 IF MB=1 AND KTV=2 AND KVI=1 THEN A$=TC$(JE)
2380 IF MB=2 THEN A$=""
2385 PRINT#3,TAB(3);K;"- ";A$;TAB(19);NXV(K);TAB(27);FNR(PM(K),NDE+1);
TAB(39);FNR(DE(K),NDE+1);
2390 IF KTV=2 AND MB=1 AND KVI=1 THEN PRINT#3,TAB(50);" (";JX(1);"-";
TC$(JX(1));" >=";VC(1,K);" y <";VC(2,K);")" ELSE PRINT#3,
2395 NEXT K
2400 IF KTV=1 AND KNV=2 THEN PRINT#3,TAB(27);"Coefic. Correlac.= ";FNR(R,NDE+1)
2405 RETURN
2410 '
2415 ' EST411 - Prueba sobre Mu
2420 '
2425 P(1)=NXV(1)-1 : TF=8
2430 ZA=SQR(NXV(1))/DE(1)
2440 WHILE JP=1
2445 X=(PM(1)-XKP)*ZA
2450 RETURN
2455 WEND
2460 WHILE JP=2
2465 XL=(XKA-XKP)*ZA
2470 XC=XS-XL : XD=XT-XL
2480 RETURN
2485 WEND
2490 WHILE JP=3
2495 FPX=1-AL/2 : GOSUB 7710
2500 XC=PM(1)-X/ZA
2505 XD=PM(1)+X/ZA
2510 RETURN
2515 WEND
2520 '
2525 ' EST412 - Prueba sobre Sigma
2530 '
2535 P(1)=NXV(1)-1 : TF=7
2540 ZA=(NXV(1)-1)*DE(1)^2
2550 WHILE JP=1
2555 X=ZA/XKP^2
2560 RETURN
2565 WEND
2570 WHILE JP=2
2575 XL=(XKA/XKP)^2
2580 XC=XS/XL : XD=XT/XL
2590 RETURN
2595 WEND
2600 WHILE JP=3
2605 FPX=1-AL/2 : GOSUB 7710
2610 XC=SQR(ZA/X)
2615 FPX=AL/2 : GOSUB 7710
2620 XD=SQR(ZA/X)
2625 RETURN
2630 WEND
2635 '
2640 ' EST413 - Prueba sobre Mu1-Mu2 (Var.Indep.)
2645 '
2650 XX=MV : TF=8
2655 WHILE MV=1
2660 P(1)=NXV(1)+NXV(2)-2
2665 XA=SQR(((NXV(1)-1)*DE(1)^2+(NXV(2)-1)*DE(2)^2)/P(1))
2670 XB=XA*SQR((1/NXV(1))+1/NXV(2))
2675 MV=-1
2680 WEND
2685 WHILE MV=0
2690 XA=DE(1)^2/NXV(1)+DE(2)^2/NXV(2)
2695 P(1)=XA^2/(DE(1)^4/(NXV(1)^2*(NXV(1)-1)+DE(2)^4/(NXV(2)^2*(NXV(2)-1))))
2700 P(1)=INT(P(1)+.5)
2705 XB=SQR(XA)
2710 MV=-1
2715 WEND
2720 MV=XX
2730 WHILE JP=1
2735 X=(PM(1)-PM(2)-XKP)/XB
2740 RETURN
2745 WEND
2750 WHILE JP=2
2755 XL=(XKA-XKP)/XB
2760 XC=XS-XL : XD=XT-XL
2770 RETURN
2775 WEND
2780 WHILE JP=3
2785 FPX=1-AL/2 : GOSUB 7710
2790 XC=PM(1)-PM(2)-X*XB
2795 XD=PM(1)-PM(2)+X*XB
2800 RETURN
2805 WEND
2810 '
2815 ' EST414 - Prueba sobre Sig1/Sig2
2820 '
2825 P(1)=NXV(1)-1
2830 P(2)=NXV(2)-1
2835 TF=9
2840 ZA=(DE(1)/DE(2))^2
2845 WHILE JP=1
2850 X=ZA/XKP^2
2855 RETURN
2860 WEND
2865 WHILE JP=2
2870 XL=(XKA/XKP)^2
2875 XC=XS/XL : XD=XT/XL
2885 RETURN
2890 WEND
2895 WHILE JP=3
2900 FPX=1-AL/2 : GOSUB 7710
2905 XC=ZA/X
2910 FPX=AL/2 : GOSUB 7710
2915 XD=ZA/X
2920 RETURN
2925 WEND
2930 '
2935 ' EST415 - Prueba sobre Mu1-Mu2 (Var.Relac.)
2940 '
2945 P(1)=NXV(1)-1 : TF=8
2950 S=SQR(DE(1)^2+DE(2)^2-2*R*DE(1)*DE(2))
2955 ZA=SQR(NXV(1))/S
2965 WHILE JP=1
2970 X=(PM(1)-PM(2)-XKP)*ZA
2975 RETURN
2980 WEND
2985 WHILE JP=2
2990 XL=(XKA-XKP)/ZA
2995 XC=XS-XL : XD=XT-XL
3005 RETURN
3010 WEND
3015 WHILE JP=3
3020 FPX=1-AL/2 : GOSUB 7710
3025 XC=PM(1)-PM(2)-X/ZA
3030 XD=PM(1)-PM(2)+X/ZA
3035 RETURN
3040 WEND
3043 '
3045 ' EST416 - PRUEBA SOBRE RO
3050 '
3055 P(1)=NXV(1)-2 : TF=8
3060 WHILE JP=1
3065 X=R*SQR((NXV(1)-2)/(1-R*R))
3070 RETURN
3075 WEND
3080 WHILE JP=2
3085 XC=0 : XD=0
3090 RETURN
3095 WEND
3100 WHILE JP=3
3105 FPX=1-AL/2 : GOSUB 7710
3110 XD=SQR(1/((NXV(1)-2)/X^2+1))
3115 XC=-XD
3120 RETURN
3125 WEND
3130 '
3135 ' EST42 - Pruebas no Parametricas
3140 ' -------------------------------
3145 TSP$="Pruebas no Parametricas"
3150 WHILE KW=0
3155 GOSUB 555
3160 TF$(1)="Chi^2" : TF$(2)="Wilcoxon (1)" : TF$(3)="Kolmogorov-Smirnov (1)"
3165 TF$(4)="Mann-Whitney" : TF$(5)="Kolmogorov-Smirnov (2)"
3170 TF$(6)="Wilcoxon (2)" : TF$(7)="Correlacion de Spearman"
3175 PRINT : PRINT "TIPO DE PRUEBA"
3180 PRINT : PRINT " Una Variable"
3185 PRINT " 1 - ";TF$(1)
3190 PRINT " 2 - ";TF$(2)
3195 PRINT " 3 - ";TF$(3)
3200 PRINT : PRINT " Dos Variables Independientes"
3205 PRINT " 4 - ";TF$(4)
3210 PRINT " 5 - ";TF$(5)
3215 PRINT : PRINT " Dos Variables Relacionadas"
3220 PRINT " 6 - ";TF$(6)
3225 PRINT " 7 - ";TF$(7)
3230 PRINT : INPUT "Prueba elegida = ",A$
3235 IF LEN(A$)=0 THEN RETURN
3240 ISP=VAL(A$)
3245 IF ISP<1 OR ISP>7 THEN PRINT CHR$(7) : GOTO 3230
3250 KNV=1 : IF ISP>=4 THEN KNV=2
3255 KTV=1 : IF ISP=4 OR ISP=5 THEN KTV=2
3260 MB=1
3265 C$=TF$(ISP) : GOSUB 555
3270 PRINT : PRINT "PRUEBA : ";C$
3280 IF ISP=1 THEN PRINT : INPUT "Ingreso Directo Datos ? (N) = ",A$
3285 IF ISP=1 THEN IF A$="S" OR A$="s" THEN MB=2 : GOTO 3313
3290 IF NF=0 THEN KE=1 : GOSUB 900 : RETURN
3295 GOSUB 1815
3300 IF NV=0 THEN RETURN
3305 IF NXV(1)<2 OR (KNV=2 AND NXV(2)<2) THEN KE=3 : GOSUB 900 : RETURN
3313 B$=""
3315 ON ISP GOSUB 3385,3570,3745,3940,4095,3570,4315
3320 KS=1
3325 WHILE KS=1
3330 GOSUB 555
3335 GOSUB 2340
3340 PRINT#3,
3345 PRINT#3,"PRUEBA : ";C$ : PRINT#3,
3346 PRINT#3,
3347 PRINT#3," Hipotesis Nula"
3348 PRINT#3,TAB(6);D$ : PRINT#3,
3350 PRINT#3," Valor Estadistica de Prueba = ";FNR(X,NDE)
3355 PRINT#3," Nivel de Significacion = ";FNR(FP*100,2);" %"
3360 IF B$>"" THEN PRINT#3,TAB(6);B$
3365 GOSUB 650
3370 WEND
3375 WEND
3380 '
3385 ' EST421 - Prueba de Chi^2
3390 '
3395 NVC(1)=0
3400 PRINT : PRINT "INGRESO FRECUENCIAS DE CLASIFICACION" : PRINT
3405 FOR M=1 TO PAR1
3410 PRINT : INPUT " X>= ",A$
3415 IF LEN(A$)=0 THEN M=PAR1 : GOTO 3495
3420 X=VAL(A$)
3425 IF M>1 AND X<=VC(M-1,1) THEN KE=5 : B$=">"+STR$(VC(M-1,1)) :
GOSUB 900 : GOTO 3525
3430 VC(M,1)=X
3435 IF MB=1 THEN 3465
3440 PRINT " Frecuencia Experimental para X>=";VC(M,1);
3443 INPUT " = ",A$
3445 IF LEN(A$)=0 THEN M=PAR1 : GOTO 3495
3450 X=VAL(A$)
3455 IF X<0 THEN KE=5 : B$=">=0" : GOSUB 900 : PRINT : GOTO 3440
3460 TI(M,1)=X
3465 PRINT " Frecuencia Esperada para X>=";VC(M,1);
3467 INPUT " = ",A$
3470 IF LEN(A$)=0 THEN M=PAR1 : GOTO 3495
3475 X=VAL(A$)
3480 IF X<0 THEN KE=5 : B$=">=0" : GOSUB 900 : PRINT : GOTO 3465
3485 TI(M,0)=X
3490 NVC(1)=NVC(1)+1
3495 NEXT M
3500 IF NVC(1)=0 THEN RETURN
3505 IF MB=1 THEN NVI=1 : KA=0 : GOSUB 6140
3515 IF MB=1 THEN IF NXX<2 THEN KE=3 : GOSUB 900 : RETURN
3520 CHI=0 : IGL=-1
3525 FOR M=1 TO NVC(1)
3530 X=TI(M,0)
3535 IF X>0 THEN CHI=CHI+(TI(M,1)-X)^2/X : IGL=IGL+1
3540 NEXT M
3545 IF IGL<1 THEN X=0 : GOTO 3555
3547 X=CHI : P(1)=IGL
3550 IP=1 : GOSUB 8704 : FP=1-FP
3555 B$="Grados de Libertad ="+STR$(IGL)
3556 IF IGL<1 THEN B$=B$+" ( <1 )"
3557 D$="Distribucion Experimental = Distribucion Definida"
3560 RETURN
3565 '
3570 ' EST422 - Prueba de Wilcoxon
3575 '
3580 IF NV=1 THEN PRINT: PRINT " Hipotesis Nula": INPUT " Mediana = ",A$
3585 IF NV=1 THEN XKP=VAL(A$)
3590 N=0
3595 FOR I=1 TO NF
3600 IF A(I,0)=1 THEN 3630
3605 X=A(I,JX(1)) : IF X=XVF THEN 3630
3610 IF NV=1 THEN X=X-XKP
3615 IF NV=2 THEN Y=A(I,JX(2)) : IF Y=XVF THEN 3630
3620 IF NV=2 THEN X=X-Y
3625 IF X<>0 THEN N=N+1 : VX(N)=X
3630 NEXT I
3635 FOR I=1 TO N
3640 X=VX(I)
3645 IF X>0 THEN VY(I)=1
3650 IF X<0 THEN VY(I)=-1 : VX(I)=-X
3655 NEXT I
3660 GOSUB 4460
3665 SP=0 : SN=0
3670 FOR I=1 TO N
3675 XA=VY(I)
3680 IF XA>0 THEN SP=SP+VX(I+N)
3685 IF XA<0 THEN SN=SN+VX(I+N)
3690 NEXT I
3695 IF SP>0 THEN X=SP
3700 IF SN>0 AND SN<X THEN X=SN
3705 P(1)=N*(N+1)/4
3710 P(2)=SQR(N*(N+1)*(2*N+1)/24)
3715 IP=1 : GOSUB 8140
3720 IF X>P(1) THEN FP=1-FP
3730 IF N<=25 THEN B$="(Valor Aproximado - Nro.de Diferencias no nulas <=25)"
3733 IF NV=1 THEN D$="Mediana Poblacion = "+STR$(XKP)
3734 IF NV=2 THEN D$="Distribucion Variable 1 = Distribucion Variable 2"
3735 RETURN
3740 '
3745 ' EST423 - Prueba de Kolm-Sm. (1 var)
3750 '
3755 IKP=1 : GOSUB 7250
3757 IF TF=0 THEN RETURN
3758 PRINT : PRINT TAB(25);"EN PROCESO"
3760 J=JX(1) : N=0
3770 FOR I=1 TO NF
3775 IF A(I,0)=1 THEN 3795
3780 X=A(I,J) : IF X=XVF THEN 3795
3785 VX(N)=X : VY(I)=I
3790 N=N+1
3795 NEXT I
3800 GOSUB 5730
3805 D=0 : FPA=0
3810 FOR I=1 TO N
3815 FPX=I/N
3820 X=VX(I)
3825 IP=1 : GOSUB 8060
3830 XD=ABS(FP-FPX)
3835 IF XD>D THEN D=XD
3836 XD=ABS(FP-FPA)
3837 IF XD>D THEN D=XD
3838 FPA=FPX
3840 NEXT I
3845 X=D : XX=D*SQR(N)
3850 GOSUB 3870
3855 B$=""
3860 IF N<20 OR KDI=1 THEN B$="(Valor Aprox. - Nro. Obs.<20 o Distrib.Discr.)"
3863 D$="Distrib. Poblacion = Distrib. "+TF$(TF)
3864 FOR M=1 TO NP(TF)
3865 D$=D$+" - Par."+STR$(M)+"="+STR$(P(M))
3866 NEXT M
3868 RETURN
3870 ' Dist KS
3875 CA=-2*XX^2 : CB=2 : FP=0
3890 FOR M=1 TO 100
3895 CC=CB*EXP(CA*M^2)
3900 FP=FP+CC
3905 IF ABS(CC)<.001*FP THEN RETURN
3910 CB=-CB
3920 NEXT M
3925 FP=1
3930 RETURN
3935 '
3940 ' EST424 - Prueba de Mann-Whitney
3945 '
3950 NA=0 : NB=NXV(1)
3955 FOR I=1 TO NF
3960 IF A(I,0)=1 THEN 4015
3965 IF KVI=2 THEN 3995
3970 X=A(I,JE) : Y=A(I,JX(1))
3975 IF X=XVF OR Y=XVF THEN 4015
3980 IF Y>=VC(1,1) AND Y<VC(2,1) THEN NA=NA+1 : VX(NA)=X
3985 IF Y>=VC(1,2) AND Y<VC(2,2) THEN NB=NB+1 : VX(NB)=X
3990 GOTO 4015
3995 X=A(I,JX(1)) : IF X=XVF THEN 4005
4000 NA=NA+1 : VX(NA)=X
4005 X=A(I,JX(2)) : IF X=XVF THEN 4015
4010 NB=NB+1 : VX(NB)=X
4015 NEXT I
4020 N=NB : NB=NB-NA
4025 GOSUB 4460
4030 S=0
4035 FOR I=1 TO NA
4040 S=S+VX(I+N)
4045 NEXT I
4050 X=NA*NB+NA*(NA+1)/2-S
4055 Y=NA*NB-X
4060 IF Y<X THEN X=Y
4065 P(1)=NA*NB/2
4070 P(2)=SQR(NA*NB*(NA+NB+1)/12)
4075 IP=1 : GOSUB 8140
4080 IF NA<=10 OR NB<=10 THEN B$="(Valor Aproximado - Nro.Obs.<=10)"
4083 D$="Distribucion Variable X = Distribucion Variable Y"
4085 RETURN
4090 '
4095 ' EST425 - Prueba de Kolm-Sm. (2 var)
4100 '
4105 NB=0
4110 FOR I=1 TO NF
4115 IF A(I,0)=1 THEN 4145
4120 IF KVI=2 THEN X=A(I,JX(2)) : IF X=XVF THEN 4145
4125 IF KVI=2 THEN NB=NB+1 : VX(NB)=X : GOTO 4145
4130 X=A(I,JE) : Y=A(I,JX(1))
4135 IF X=XVF OR Y=XVF THEN 4145
4140 IF Y>=VC(1,2) AND Y<VC(2,2) THEN NB=NB+1 : VX(NB)=X
4145 NEXT I
4150 N=NB : GOSUB 5730
4155 FOR I=1 TO NB : VX(I+NF)=VX(I) : NEXT I
4160 NA=0
4165 FOR I=1 TO NF
4170 IF A(I,0)=1 THEN 4200
4175 IF KVI=2 THEN X=A(I,JX(2)) : IF X=XVF THEN 4200
4180 IF KVI=2 THEN NA=NA+1 : VX(NA)=X : GOTO 4200
4185 X=A(I,JE) : Y=A(I,JX(1))
4190 IF X=XVF OR Y=XVF THEN 4200
4195 IF Y>=VC(1,1) AND Y<VC(2,1) THEN NA=NA+1 : VX(NA)=X
4200 NEXT I
4205 N=NA : GOSUB 5730
4210 D=0 : NXA=1 : NXB=1
4215 FPA=0 : FPB=0 : FPM=0 : FPN=0
4225 WHILE NXA<=NA AND NXB<=NB
4230 IF VX(NXA)>=VX(NXB+NF) THEN 4260
4235 FPA=NXA/NA
4240 XD=ABS(FPA-FPN)
4245 IF XD>D THEN D=XD
4246 XD=ABS(FPM-FPN)
4247 IF XD>D THEN D=XD
4250 NXA=NXA+1 : FPM=FPA
4255 GOTO 4280
4260 FPB=NXB/NB
4265 XD=ABS(FPB-FPM)
4270 IF XD>D THEN D=XD
4271 XD=ABS(FPN-FPM)
4272 IF XD>D THEN D=XD
4275 NXB=NXB+1 : FPN=FPB
4280 WEND
4285 X=D : XX=SQR(NA*NB/(NA+NB))*D
4290 GOSUB 3870
4300 IF NA<20 OR NB<20 THEN B$="(Valor Aproximado - Nro. Obs.<20)"
4303 D$="Distribucion Variable X = Distribucion Variable Y"
4305 RETURN
4310 '
4315 ' EST427 - Prueba de Correlacion de Spearman
4320 '
4325 FOR K=1 TO 2
4330 N=0
4335 J=JX(K)
4340 FOR I=1 TO NF
4345 IF A(I,0)=1 THEN 4360
4350 X=A(I,JX(1)) : Y=A(I,JX(2)) : IF X=XVF OR Y=XVF THEN 4360
4355 N=N+1 : IF K=1 THEN VX(N)=X ELSE VX(N)=Y
4360 NEXT I
4365 GOSUB 4460
4370 IF K=2 THEN 4390
4375 FOR I=1 TO N
4380 VY(I)=VX(I+N)
4385 NEXT I
4390 NEXT K
4395 S=0
4400 FOR I=1 TO N
4405 S=S+(VY(I)-VX(I+N))^2
4410 NEXT I
4415 R=1-6*S/(N*(N^2-1))
4420 X=R*SQR((N-2)/(1-R*R))
4425 P(1)=N-2
4430 IP=1 : GOSUB 8800
4435 IF FP>=.5 THEN FP=2*(1-FP)
4440 IF FP<.5 THEN FP=2*FP
4445 IF N<=10 THEN B$="( Valor Aproximado - Nro.Observaciones <=10 )"
4447 D$="Coeficiente de Correlacion de Spearman = 0"
4450 RETURN
4455 '
4460 ' EST429 - Determinacion de Rangos de un vector de valores
4465 '
4470 FOR I=1 TO N : VX(I+N)=0 : NEXT I
4475 FOR I=1 TO N
4480 IF VX(I+N)>0 THEN 4540
4485 SM=0 : EQ=0
4490 X=VX(I)
4495 FOR J=1 TO N
4500 IF VX(J)<X THEN SM=SM+1
4505 IF VX(J)=X THEN EQ=EQ+1 : VX(J+N)=-1
4510 NEXT J
4515 IF EQ<=1 THEN VX(I+N)=SM+1 : GOTO 4540
4520 P=SM+(EQ+1)*.5
4525 FOR J=1 TO N
4530 IF VX(J+N)=-1 THEN VX(J+N)=P
4535 NEXT J
4540 NEXT I
4545 RETURN
4550 '
4700 ' EST43 - Tamano de Muestras
4705 ' --------------------------
4710 WHILE KW=0
4715 TSP$="Tamano de Muestra"
4720 GOSUB 555
4723 PRINT "ESTIMACION DE"
4725 TF$(1)="Valor Esperado de una Variable"
4730 TF$(2)="Fraccion respecto al Total"
4735 KL=2 : GOSUB 980
4740 IF ISP=0 THEN RETURN
4745 PRINT : INPUT " Nivel de Significacion Alfa en % (5) = ",A$
4750 IF LEN(A$)=0 THEN AL=.05 ELSE AL=VAL(A$)/100
4760 IF AL<=0 OR AL>=1 THEN KE=5 : B$=">0 y <100" : GOSUB 900 : GOTO
4765 PRINT : INPUT " Tamano de la Poblacion (Infinita) = ",A$
4770 IF LEN(A$)=0 THEN XNP=1E+10 ELSE XNP=VAL(A$)
4775 IF XNP<=0 THEN KE=5 : B$=">0" : GOSUB 900 : GOTO 4765
4780 IF ISP=1 THEN C$="Desvio Estandar" : D$="Valor Esperado"
4783 IF ISP=2 THEN C$="Fraccion" : D$=C$
4785 PRINT : PRINT TAB(4);C$; : INPUT " = ",A$
4790 IF LEN(A$)=0 THEN RETURN
4795 XK=VAL(A$)
4800 IF XK<=0 THEN KE=5 : B$=">0" : GOSUB 900: GOTO 4785
4802 IF ISP=2 AND XK>=1 THEN KE=5 : B$="<1" : GOSUB 900: GOTO 4785
4935 PRINT : PRINT " Tolerancia Admisible en +- sobre ";D$;
4937 INPUT " (A Calcular) = ",A$
4940 KT=0 : IF LEN(A$)=0 THEN KT=1 : GOTO 4960
4945 TOL=VAL(A$)
4950 IF TOL<=0 THEN KE=5 : B$=">0" : GOSUB 900 : GOTO 4935
4955 GOTO 4977
4960 PRINT : INPUT " Tamano de Muestra = ",A$
4965 IF LEN(A$)=0 THEN RETURN
4970 XNM=VAL(A$)
4975 IF XNM<=0 OR XNM>=XNP THEN KE=5 : B$=">0 y <"+STR$(XNP) :
GOSUB 900 : GOTO 4960
4977 TF=8
4978 P(1)=250 : IF KT=1 THEN P(1)=XNM-1
4980 FPX=1-AL/2 : GOSUB 7710
4985 WHILE ISP=1
4987 IF KT=0 THEN XX=(X*XK/TOL)^2 : XNM=INT(XX/(1+XX/XNP)+.5)
4990 IF KT=1 THEN TOL=X*XK*SQR((1-XNM/XNP)/XNM)
5005 ISP=0
5010 WEND
5015 WHILE ISP=2
5017 PQ=XK*(1-XK)
5020 IF KT=0 THEN XX=(X/TOL)^2*PQ : XNM=INT(XX/(1+(XX-1)/XNP)+.5)
5025 IF KT=1 THEN TOL=100*X*SQR((XNM-XNP)*PQ/((XNP-1)*XNM))
5035 ISP=0
5040 WEND
5050 KS=1
5055 WHILE KS=1
5060 GOSUB 555
5061 PRINT#3,"CALCULO TAMANO MUESTRA PARA ESTIMAR ";D$ : PRINT#3,
5062 PRINT#3," Nivel de Significacion Alfa";TAB(43);" = ";100*AL;" %"
5063 A$=STR$(XNP) : IF XNP>=1E+10 THEN A$="Infinita"
5064 PRINT#3," Tamano de la Poblacion";TAB(43);" = ";A$
5066 PRINT#3," ";C$;TAB(43);" = ";XK : PRINT#3,
5068 PRINT#3," Tolerancia Admisible sobre ";D$;TAB(43);" = ";FNR(TOL,NDE+1)
5070 PRINT#3," Tamano de Muestra";TAB(43);" = ";XNM
5080 GOSUB 650
5083 WEND
5095 WEND
5477 '
5480 ' EST211 - Calculo de Valor medio, Desv.Std.,Max.,Min.
5485 ' ----------------------------------------------------
5490 SX=0 : SCX=0 : NXX=0
5495 XMI=1E+10 : XMA=-1E+10
5500 FOR I=1 TO NF
5505 IF A(I,0)=1 THEN 5550
5510 X= A(I,J)
5515 IF X=XVF THEN 5550
5520 IF X<XMI THEN XMI=X
5525 IF X>XMA THEN XMA=X
5530 ND=1 : IF JF>0 THEN ND=A(I,JF)
5535 IF ND=XVF THEN 5550
5540 SX=SX+ND*X : SCX=SCX+ND*X^2
5545 NXX=NXX+ND
5550 NEXT I
5555 IF NXX<2 THEN RETURN
5560 PX=SX/NXX
5565 DEM=SQR((SCX-NXX*PX^2)/NXX)
5570 DEX=SQR((SCX-NXX*PX^2)/(NXX-1))
5575 RETURN
5580 '
5727 '
5730 ' EST213 - Ordenamiento de un vector de valores
5735 ' ---------------------------------------------
5740 LOG2=INT(LOG(N)*(1!/.69314728#)+.00001)
5745 MM=N
5750 FOR NN=1 TO LOG2
5755 MM=INT(MM/2)
5760 K=N-MM
5765 FOR JJ=1 TO K
5770 I=JJ
5775 L=I+MM
5780 IF VX(L)>=VX(I) THEN 5805
5785 X=VX(I) : VX(I)=VX(L) : VX(L)=X
5790 X=VY(I) : VY(I)=VY(L) : VY(L)=X
5795 I=I-MM
5800 IF I>=1 THEN 5775
5805 NEXT JJ
5810 NEXT NN
5815 RETURN
5820 '
5825 ' EST214 - Calculo de Matriz de Covariancias
5830 ' ------------------------------------------
5835 FOR K=1 TO NV
5840 PM(K)=0
5845 FOR L=1 TO K : TI(K,L)=0 :NEXT L
5850 NEXT K
5855 NXX=0
5860 FOR I=1 TO NF
5865 IF A(I,0)=1 THEN 5945
5870 ND=1 : IF JF>0 THEN ND=A(I,JF)
5875 IF ND=XVF THEN 5945
5880 KE=0
5885 FOR K=1 TO NV
5890 XP(K)=A(I,JX(K))
5895 IF XP(K)=XVF THEN KE=1 : K=NV
5900 NEXT K
5905 IF KE=1 THEN 5945
5910 FOR K=1 TO NV
5915 PM(K)=PM(K)+XP(K)*ND
5920 FOR L=1 TO K
5925 TI(K,L)=TI(K,L)+XP(K)*XP(L)*ND
5930 NEXT L
5935 NEXT K
5940 NXX=NXX+ND
5945 NEXT I
5950 IF NXX<2 THEN RETURN
5955 FOR K=1 TO NV
5960 VX(K)=PM(K)
5965 PM(K)=PM(K)/NXX
5970 DE(K)=SQR((TI(K,K)-NXX*PM(K)^2)/(NXX-1))
5975 FOR L=1 TO K
5980 TI(K,L)=(TI(K,L)-NXX*PM(K)*PM(L))/(NXX-1)
5985 TI(L,K)=TI(K,L)
5990 NEXT L,K
5995 RETURN
6000 '
6140 ' EST222 - Clasificacion
6145 ' ----------------------
6150 IF NVI=1 THEN NVC(2)=0 : IJ(2)=0
6155 FOR M=0 TO NVC(1)+1
6160 FOR N=0 TO NVC(2)+1
6165 TI(M,N)=0
6170 IF KA>0 THEN TJ(M,N)=0 : TK(M,N)=0
6175 NEXT N,M
6180 NXX=0
6185 FOR I=1 TO NF
6190 IF A(I,0)=1 THEN 6300
6195 ND=1 : IF JF>0 THEN ND=A(I,JF)
6200 IF ND=XVF THEN 6300
6205 KE=0
6210 FOR K=1 TO NVI
6215 XP(K)=A(I,JX(K))
6220 IF XP(K)=XVF THEN KE=1 : K=NV
6225 NEXT K
6230 IF KE=1 THEN 6300
6235 FOR K=1 TO NVI
6240 IJ(K)=NVC(K)
6245 FOR M=1 TO NVC(K)
6250 IF XP(K)<VC(M,K) THEN IJ(K)=M-1 : MX(K)=0 : M=NVC(K)
6255 IF XP(K)=VC(M,K) THEN IJ(K)=M : M=NVC(K)
6260 NEXT M
6265 NEXT K
6270 IF KA=1 THEN X=A(I,JE) : IF X=XVF THEN 6300
6275 TI(IJ(1),IJ(2))=TI(IJ(1),IJ(2))+ND
6280 IF KA=0 THEN 6295
6285 TJ(IJ(1),IJ(2))=TJ(IJ(1),IJ(2))+ND*X
6290 TK(IJ(1),IJ(2))=TK(IJ(1),IJ(2))+ND*X*X
6295 NXX=NXX+ND
6300 NEXT I
6305 MA=NVC(1)+1 : NA=NVC(2)+1
6310 FOR M=0 TO NVC(1)
6315 FOR N=0 TO NVC(2)
6320 TI(M,NA)=TI(M,NA)+TI(M,N)
6325 TI(MA,N)=TI(MA,N)+TI(M,N)
6330 TI(MA,NA)=TI(MA,NA)+TI(M,N)
6335 NEXT N,M
6340 RETURN
6345 '
7250 ' EST30 - Seleccion de Distribucion
7255 ' ---------------------------------
7260 TG$(1)=">0": TG$(2)="Entero": TG$(3)="<1": TG$(4)=">Par1": TG$(5)=">-1 <1"
7270 TF$(1)="Uniforme (a,b)" : NP(1)=2 : VX(1)=0 :VY(1)=4
7275 TF$(2)="Normal (Mu,Sig)" : NP(2)=2 : VX(2)=0 : VY(2)=1
7280 TF$(3)="Exponencial (Mu)" : NP(3)=1 : VX(3)=1
7285 TF$(4)="Gamma (Alfa,Beta)" : NP(4)=2 : VX(4)=1 : VY(4)=1
7290 TF$(5)="Beta (Alfa,Beta)" : NP(5)=2 : VX(5)=1 : VY(5)=1
7295 TF$(6)="Lognormal (Mu',Sig')" : NP(6)=2 : VX(6)=1 : VY(6)=1
7300 TF$(7)="Chi^2 (k)" : NP(7)=1 : VX(7)=12
7305 TF$(8)="t (k)" : NP(8)=1 : VX(8)=12
7310 TF$(9)="F (k1,k2)" : NP(9)=2 : VX(9)=12 : VY(9)=12
7315 TF$(10)="Normal Autocorrelac.(Mu,Sig,Ro)"
- NP(10)=3 : VX(10)=0 : VY(10)=1
7320 TF$(11)="Normal Bidimens.(Mu1,Sig1,Mu2,Sig2,Ro)"
- NP(11)=5 : VX(11)=0 : VY(11)=1
7325 TF$(12)="Uniforme Discr.(a,b)" : NP(12)=2 : VX(12)=2 : VY(12)=24
7330 TF$(13)="Binomial (n,p)" : NP(13)=2 : VX(13)=12 : VY(13)=13
7335 TF$(14)="Binomial Negat.(r,p)" : NP(14)=2 : VX(14)=12 : VY(14)=13
7340 TF$(15)="Poisson (Mu)" : NP(15)=1 : VX(15)=1
7345 PRINT : PRINT "DISTRIBUCIONES CONTINUAS" : PRINT
7350 FOR K=1 TO 6
7355 PRINT TAB(3);K;"- ";TF$(K);
7360 IF K<6 THEN PRINT TAB(33);K+6;" - ";TF$(K+6) ELSE PRINT
7365 NEXT K
7370 PRINT : PRINT "DISTRIBUCIONES DISCRETAS" : PRINT
7375 FOR K=12 TO 13
7380 PRINT TAB(3);K;"- ";TF$(K);
7385 PRINT TAB(33);K+2;" - ";TF$(K+2) ELSE PRINT
7390 NEXT K
7395 PRINT : PRINT "Distribucion Elegida";
7397 IF TF>0 THEN PRINT " (";TF;")";
7398 INPUT " = ",A$
7399 IF LEN(A$)=0 AND TF=0 THEN RETURN
7400 IF LEN(A$)>0 THEN TF=INT(VAL(A$))
7410 IF TF<1 OR TF>15 THEN PRINT CHR$(7) : GOTO 7395
7415 TFX$=TF$(TF)
7420 KNV=1 : IF TF=11 THEN KNV=2
7425 KDI=0 : IF TF>11 THEN KDI=1
7430 KP=NP(TF) : TP(1)=VX(TF) : TP(2)=VY(TF)
7435 IF TF=10 THEN TP(3)=13 : FOR I=1 TO 20 : VY(I)=0 : NEXT I
7440 IF TF=11 THEN TP(3)=0 : TP(4)=1 : TP(5)=15
7445 '
7450 GOSUB 555
7455 PRINT "Distribucion = ";TF$(TF)
7460 FOR K=1 TO KP
7465 PRINT : PRINT " Parametro";K;
7470 IF TP(K)=0 THEN PRINT : GOTO 7515
7475 PRINT " (";
7480 A$=STR$(TP(K)) : N=LEN(A$)
7485 FOR M=1 TO N
7490 KM=VAL(MID$(A$,M,1))
7495 IF KM=0 THEN 7505
7500 PRINT " ";TG$(KM);
7505 NEXT M
7510 PRINT " )"
7515 KF(K)=0
7520 B$=STR$(FNR(P(K),NDF)) : IF IKP=2 THEN B$="A Estimar"
7525 PRINT " Valor (";B$;")";TAB(25); : INPUT " = ",A$
7530 IF LEN(A$)=0 AND IKP=2 THEN KF(K)=1 : GOTO 7610
7535 IF LEN(A$)=0 AND IKP<>2 THEN X=P(K)
7540 IF LEN(A$)>0 THEN X=VAL(A$)
7545 IF TP(K)=0 THEN 7605
7550 A$=STR$(TP(K))
7555 N=LEN(A$) : KE=0
7560 FOR M=1 TO N
7565 KM=VAL(MID$(A$,M,1))
7570 IF KM=1 AND X<=0 THEN KE=1
7575 IF KM=2 AND X<>INT(X) THEN KE=1
7580 IF KM=3 AND X>=1 THEN KE=1
7585 IF KM=4 AND X<=P(1) THEN KE=1
7590 IF KM=5 AND (X<=-1 OR X>=1) THEN KE=1
7595 NEXT M
7600 IF KE=1 THEN KE=5 : B$=TG$(KM) : GOSUB 900 : GOTO 7520
7605 P(K)=X
7610 NEXT K
7705 '
7710 ' EST320 - Calculo del valor x para F(x)
7715 '
7725 IP=1 : GOSUB 8060
7730 IF KDI=0 THEN X=XMU : DI=SIG
7732 IF KDI=1 THEN X=INT(XMU) : DI=INT(SIG+1)
7735 GOSUB 8060 : FP=FP-FPX
7740 IF ABS(FP)<=.0001 THEN RETURN
7745 IF FP>0 THEN DI=-DI
7750 MX=0
7755 WHILE MX=0
7760 XY=X : FPY=FP : X=X+DI
7765 GOSUB 8060 : FP=FP-FPX
7770 IF ABS(FP)<=.0001 THEN RETURN
7775 IF DI<0 AND FP<0 THEN XD=X : XE=XY : FPD=FP : FPE=FPY : MX=1
7780 IF DI>0 AND FP>0 THEN XD=XY : XE=X : FPD=FPY : FPE=FP : MX=1
7785 WEND
7787 WHILE KDI=0
7790 WHILE ABS(FPY)>.0001
7795 X=XD-FPD*(XE-XD)/(FPE-FPD)
7805 GOSUB 8060 : FPY=FP-FPX
7810 IF FPY>0 THEN XE=X : FPE=FPY
7815 IF FPY<0 THEN XD=X : FPD=FPY
7820 WEND
7825 RETURN
7830 WEND
7835 WHILE KDI=1
7895 FOR M=XD+1 TO XE
7900 X=M : GOSUB 8060 : FPD=FPD+FD
7905 IF FPD>=0 THEN M=XE
7910 NEXT M
7915 RETURN
7920 WEND
7925 '
8060 ' EST300 - Llamada a Rutinas Distribuciones
8064 '
8068 ON TF GOSUB 8080,8140,8220,8280,8464,8636,8704,8800,8932,9068,9152,
9252,9360,9568,9680
8072 RETURN
8076 '
8080 ' EST301 - Dist.Uniforme Continua
8084 '
8088 A=P(1) : B=P(2)
8096 XMU=(A+B)/2 : SIG=(B-A)/3.464102
8100 IF X<A THEN FD=0 : FP=0
8104 IF X>=A AND X<=B THEN FD=1/(B-A) : FP=(X-A)/(B-A)
8108 IF X>B THEN FD=0 : FP=1
8112 RETURN
8136 '
8140 ' EST302 - Dist.Normal
8144 '
8148 XMU=P(1) : SIG=P(2)
8156 U=(X-XMU)/SIG
8160 MXA=0 : IF U<0 THEN U=-U : MXA=1
8164 FD=.39894228#*EXP(-U*U/2)
8168 C=1/(1+.2316419*U)
8172 FP=FD*C*(.3193815+C*(-.3565638+C*(1.781478+C*(-1.821256+1.330274*C))))
8176 IF MXA=0 THEN FP=1-FP
8180 IF FP>1 THEN FP=1
8184 IF FP<0 THEN FP=0
8188 FD=FD/SIG
8192 RETURN
8216 '
8220 ' EST303 - Dist.Exponencial
8224 '
8228 XMU=P(1)
8236 SIG=XMU
8240 IF X<0 THEN FD=0 : FP=0 : RETURN
8244 FD=EXP(-X/XMU)/XMU
8248 FP=1-EXP(-X/XMU)
8252 RETURN
8276 '
8280 ' EST304 - Dist.Gamma
8284 '
8288 AL=P(1) : BE=P(2)
8296 XMU=AL*BE : SIG=SQR(AL)*BE
8297 IF X=0 AND AL<1 THEN FD=1E+10 : FP=0 : RETURN
8298 IF X=0 AND AL=1 THEN FD=.5 : FP=0 : RETURN
8300 IF X<=0 THEN FD=0 : FP=0 : RETURN
8304 XGA=X : X=X/BE
8308 XN=AL-1 : GOSUB 9860
8312 FD=EXP((AL-1)*LOG(X)-X-FA)/BE
8316 CA=AL : SUM=1/AL : CB=SUM
8320 FOR N=1 TO 100
8324 CA=CA+1 : CB=CB*X/CA : SUM=SUM+CB
8328 IF ABS(CB)<ABS(SUM)*.0001 THEN N=100
8332 NEXT N
8336 FP=SUM*EXP(-X+AL*LOG(X)-FA)
8340 X=XGA
8344 RETURN
8460 '
8464 ' EST305 - Dist.Beta
8468 '
8472 AL=P(1) : BE=P(2)
8480 XMU=AL/(AL+BE) : SIG=SQR(AL*BE/((AL+BE)^2*(AL+BE+1)))
8484 IF X<0 THEN FD=0 : FP=0 : RETURN
8488 IF X>1 THEN FD=0 : FP=1 : RETURN
8492 XN=(AL-1) : GOSUB 9868 : CA=FA
8496 XN=(BE-1) : GOSUB 9868 : CB=FA
8500 XN=(AL+BE-1) : GOSUB 9868
8504 BT=EXP(CA+CB-FA)
8508 FD=X^(AL-1)*(1-X)^(BE-1)/BT
8512 KA=0
8516 IF X>=(AL+1)/(AL+BE+2) THEN KA=1 : XX=X : X=1-X : Y=BE : BE=AL : AL=Y
8520 CA=1 : CB=1 : CC=1
8524 CD=1-(AL+BE)*X/(AL+1)
8528 FOR L=1 TO 100
8530 LL=2*L
8532 CE=L*(BE-L)*X/((AL-1+LL)*(AL+LL))
8536 CF=CC+CE*CA : CG=CD+CE*CB
8540 CE=-(AL+L)*(AL+BE+L)*X/((AL+LL)*(AL+1+LL))
8544 CH=CF+CE*CC : CI=CG+CE*CD
8548 CA=CF/CI : CB=CG/CI
8552 CJ=CC : CC=CH/CI : CD=1
8556 IF ABS(CC-CJ)<.0001*ABS(CC) THEN L=100
8560 NEXT L
8564 FP=FD*X*(1-X)*CC/AL
8568 IF KA=1 THEN FP=1-FP : X=XX
8572 IF FP<0 THEN FP=0
8576 IF FP>1 THEN FP=1
8580 RETURN
8632 '
8636 ' EST306 - Dist.Log-normal
8640 '
8648 XMUX=EXP(P(1)+P(2)^2/2)
8652 SIGX=XMUX*SQR(EXP(P(2)^2)-1)
8656 IF X<=0 THEN FD=0 : FP=0 : XMU=XMUX : SIG=SIGX : RETURN
8660 XLN=X : X=LOG(X) : GOSUB 8140
8664 X=XLN : FD=FD/X
8668 XMU=XMUX : SIG=SIGX
8672 RETURN
8700 '
8704 ' EST307 - Dist.Chi^2
8708 '
8712 K=P(1)
8720 XMU=K : SIG=SQR(2*K)
8724 IF X=0 AND K=1 THEN FD=1E+10 : FP=0 : RETURN
8728 IF X=0 AND K=2 THEN FD=.5 : FP=0 : RETURN
8732 IF X<=0 THEN FD=0 : FP=0 : RETURN
8740 P(1)=K/2 : P(2)=2
8744 GOSUB 8280
8748 P(1)=K
8752 XN=(K/2-1) : GOSUB 9860
8756 FD=EXP((K/2-1)*LOG(X)-X/2-.3465735*K-FA)
8760 XMU=K : SIG=SQR(2*K)
8764 RETURN
8796 '
8800 ' EST308 - Distribucion t
8804 K=P(1)
8812 WHILE K>0 AND K<250
8816 XN=(K-1)/2 : GOSUB 9860 : FD=FA
8820 XN=(K-2)/2 : GOSUB 9860 : FD=FD-FA
8824 FDZ=EXP(FD-.5*LOG(3.14159265#*K)-.5*(K+1)*LOG(1+X*X/K))
8832 XTE=X : X=K/(K+X*X)
8836 P(1)=K/2 : P(2)=.5
8840 GOSUB 8464
8842 FP=FP/2
8844 IF XTE>0 THEN FP=1-FP
8856 X=XTE : P(1)=K : P(2)=0
8860 FD=FDZ : K=0
8864 WEND
8868 WHILE K>=250
8872 P(1)=0 : P(2)=1 : GOSUB 8140
8876 P(1)=K : K=0
8880 WEND
8884 K=P(1) : XMU=0
8888 SIG=0 : IF K>2 THEN SIG=SQR(K/(K-2))
8892 RETURN
8928 '
8932 ' EST309 - Dist. F
8936 '
8940 KM=P(1) : KN=P(2)
8948 XMUX=0 : SIGX=0
8952 IF KN>2 THEN XMUX=KN/(KN-2)
8956 IF KN>4 THEN SIGX=KN*SQR(2*(KM+KN-2)/(KM*(KN-2)^2*(KN-4)))
8960 IF X<=0 THEN FD=0 : FP=0 : XMU=XMUX : SIG=SIGX : RETURN
8964 XN=(KM+KN-2)/2 : GOSUB 9860 : FDZ=FA
8968 XN=(KM-2)/2 : GOSUB 9860 : FDZ=FDZ-FA
8972 XN=(KN-2)/2 : GOSUB 9860 : FDZ=FDZ-FA
8976 FDZ=FDZ+(KM/2)*LOG(KM/KN)+.5*(KM-2)*LOG(X)-.5*(KM+KN)*LOG(1+KM*X/KN)
8980 FDZ=EXP(FDZ)
8984 XFE=X : X=KN/(KN+KM*X)
8988 P(1)=KN/2 : P(2)=KM/2
8992 GOSUB 8464
8994 FP=1-FP
8996 X=XFE : P(1)=KM : P(2)=KN
9000 FD=FDZ : XMU=XMUX : SIG=SIGX
9004 RETURN
9064 '
9252 ' EST312 - Dist.Uniforme Discreta
9256 '
9260 A=P(1) : B=P(2)
9268 XMU=(A+B)/2 : SIG=SQR((B-A)*(B-A+2)/12)
9272 XX=INT(X)
9276 IF XX<A THEN FD=0 : FP=0
9280 IF XX>=A AND XX<=B THEN FD=1/(B-A+1) : FP=(XX-A+1)/(B-A+1)
9284 IF XX>B THEN FD=0 : FP=1
9288 IF X-XX>0 THEN FD=0
9292 RETURN
9356 '
9360 ' EST313 - Dist.Binomial
9364 '
9368 N=P(1) : PR=P(2)
9376 XMU=N*PR : SIG=SQR(N*PR*(1-PR))
9384 IF X<0 THEN FD=0 : FP=0 : RETURN
9388 IF X>N THEN FD=0 : FP=1 : RETURN
9392 XX=INT(X) : MK=0
9396 IF (PR<=.5 AND XMU>5) OR (PR>.5 AND N*(1-PR)>5) OR N>30 OR X>30 THEN MK=1
9400 WHILE MK=0
9404 XN=N : GOSUB 9860 : CA=FA
9408 FP=0 : CB=1
9412 FOR IX=0 TO XX
9416 IF IX>0 THEN CB=CB*IX
9418 XN=N-IX : GOSUB 9860
9420 FD=CA-LOG(CB)-FA+IX*LOG(PR)+(N-IX)*LOG(1-PR)
9422 FD=EXP(FD)
9424 FP=FP+FD
9428 NEXT IX
9432 IF X-XX>0 THEN FD=0
9436 RETURN
9440 WEND
9444 WHILE MK=1
9448 P(1)=XMU : P(2)=SIG : XA=X : X=XX-.5
9452 GOSUB 8140
9456 XB=FP : X=XX+.5
9460 GOSUB 8140
9464 FD=FP-XB
9468 IF X>XX THEN FD=0
9472 XMU=P(1) : SIG=P(2) : X=XA : P(1)=N : P(2)=PR
9476 RETURN
9480 WEND
9564 '
9568 ' EST314 - Dist.Binomial negativa
9572 '
9576 R=P(1) : PR=P(2)
9584 XMU=R*(1-PR)/PR
9588 SIG=SQR(R*(1-PR))/PR
9592 IF X<0 THEN FD=0 : FP=0 : RETURN
9596 XX=INT(X)
9600 FP=0 : CA=1
9604 FOR IX=0 TO XX
9608 IF IX>0 THEN CA=CA*(IX+R-1)/IX
9612 FD=CA*PR^R*(1-PR)^IX
9616 FP=FP+FD
9620 NEXT IX
9624 IF X-XX>0 THEN FD=0
9628 RETURN
9676 '
9680 ' EST315 - Dist.Poisson
9684 '
9688 XMU=P(1)
9696 '
9700 SIG=SQR(XMU)
9704 IF X<0 THEN FD=0 : FP=0 : RETURN
9708 XX=INT(X)
9712 MK=0 : IF XMU>10 OR X>30 THEN MK=1
9716 WHILE MK=0
9720 CA=EXP(-XMU) : FP=0 : CB=1
9724 FOR IX=0 TO XX
9728 IF IX>0 THEN CB=CB*IX
9732 FD=CA*P(1)^IX/CB : FP=FP+FD
9736 NEXT IX
9740 IF X-XX>0 THEN FD=0
9744 RETURN
9748 WEND
9752 WHILE MK=1
9756 P(2)=SIG : XA=X : X=XX-.5
9760 GOSUB 8140
9764 XB=FP : X=XX+.5
9768 GOSUB 8140
9772 FD=FP-XB : X=XA
9776 IF X>XX THEN FD=0
9780 RETURN
9784 WEND
9856 '
9860 ' EST320 - Calculo de Log(Factorial)
9864 '
9868 WHILE XN>=-.5 AND XN<=4 AND INT(2*XN)=2*XN
9872 IF XN=-.5 THEN FA=.57236494#
9876 IF XN=0 THEN FA=0
9880 IF XN=.5 THEN FA=-.12078224#
9884 IF XN=1 THEN FA=0
9888 IF XN=1.5 THEN FA=.28468287#
9892 IF XN=2 THEN FA=.693147181#
9896 IF XN=2.5 THEN FA=1.2009736#
9900 IF XN=3 THEN FA=1.79175947#
9904 IF XN=3.5 THEN FA=2.45373657#
9908 IF XN=4 THEN FA=3.17805383#
9912 RETURN
9916 WEND
9920 Y=1/(XN*XN)
9922 YY=1/360-Y*(1/1260-Y/1680)
9924 Y=(XN+.5)*LOG(XN)-XN*(1-Y*(1/12-Y*YY))
9928 FA=Y+.91893853#
9932 RETURN