Estadística en Microcomputadores/Archivos BASIC/ESTAD3
10 ' ESTAD3 - Revision 8/11/88
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 ' EST3 - Distribuciones de Probabilidad
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 NVC(2),VC(PAR1+1,1),TI(PAR1+1,PAR2+1)
1027 K=NFM : IF K<20 THEN K=20
1030 DIM VX(15),VY(K),NP(15),TF$(15),TP(5),TG$(5),KF(5)
1035 DIM XMN(2),XMX(2),DEL(2),KB(2),MX(2),JJ(5),JY(2),XP(2),PM(2),DE(2)
1040 DEF FNR(X,K)=INT(10^K*X+.5)/10^K
1041 NDD=NDE-1 : NDF=NDE+1
1042 AD$="." : FOR M=1 TO NDD : AD$=AD$+"#" : NEXT M
1043 AE$="." : FOR M=1 TO NDE : AE$=AE$+"#" : NEXT M
1044 AF$="." : FOR M=1 TO NDF : AF$=AF$+"#" : NEXT M
1045 CLOSE : DS$="SCRN:" : OPEN DS$ FOR OUTPUT AS#3
1050 WHILE KW=0
1055 TP$="DISTRIBUCIONES DE PROBABILIDAD" : TSP$=""
1060 NXX=0
1065 GOSUB 555
1070 PRINT TAB(70);FRE(0)
1075 PRINT "PROCESOS"
1080 TF$(1)="Calculos con Funciones de Probabilidad"
1085 TF$(2)="Ajuste de Distribuciones"
1090 TF$(3)="Generacion de Valores Aleatorios"
1095 TF$(4)="Manejo de Datos"
1100 KL=4 : GOSUB 980
1105 IF ISP=0 THEN RETURN
1110 IF ISP=4 THEN CHAIN "ESTAD1"
1115 IF ISP=2 AND NF=0 THEN KE=1 : GOSUB 900 : GOTO 1130
1125 ON ISP GOSUB 1140,1780,2445
1130 WEND
1135 '
1140 ' EST31 - Calculo de Funciones de Probabiblidad
1145 ' ---------------------------------------------
1150 WHILE KW=0
1155 TSP$="Calculos con Funciones de Probabilidad"
1160 GOSUB 555
1165 PRINT "PROCESOS"
1170 TF$(1)="Calculo de f(x) y F(x)"
1175 TF$(2)="Calculo de x para Valores de F(x)"
1180 KL=2 : GOSUB 980
1185 IF ISP=0 THEN RETURN
1190 KTP=1 : GOSUB 7250
1195 IF TF=0 THEN RETURN
1200 B$="x" : C$="F(x)" : IF ISP=2 THEN B$="F(x)" : C$="x"
1205 PRINT: PRINT "Valores de ";B$;: INPUT " en Memoria de Trabajo ? (N) = ",A$
1210 KMT=0 : IF A$="S" OR A$="s" THEN KMT=1
1213 IF KMT=1 AND NF=0 THEN KE=1 : GOSUB 900 : RETURN
1215 IF KMT=0 THEN 1255
1220 GOSUB 500
1222 PRINT : PRINT " Variable con valores de ";B$; : INPUT " = ",A$
1225 IF LEN(A$)=0 THEN RETURN
1230 JZ=VAL(A$)
1235 IF JZ<1 OR JZ>NC OR TC$(JZ)=" " THEN KE=4 : GOSUB 900 : GOTO
1237 PRINT
1240 PRINT " Almacenamiento de Valores de ";C$;" en Memoria de Trabajo"
1245 KVA=1 : GOSUB 390
1250 JJ(1)=J
1255 ON ISP GOSUB 1270,1590
1260 WEND
1265 '
1270 ' EST311 - Calculo de f(x) y F(x)
1275 '
1276 'CLS : INPUT "Integracion de f(x) ? (N) = ",A$
1277 'IF A$="S" OR A$="s" THEN GOSUB 9936 : GOTO 1276
1280 IF KMT=1 THEN NPG=NF : GOTO 1310
1285 GOSUB 555 : GOSUB 1555
1290 PRINT : PRINT "INGRESO DE VALORES x"
1295 K=1 : KX=1 : GOSUB 6010
1300 IF NVC(1)=0 THEN RETURN
1305 NPG=NVC(1)
1310 KS=1
1315 WHILE KS=1
1320 GOSUB 555
1325 X=0 : IP=1 : GOSUB 8060
1330 GOSUB 1555
1345 FPA=0 : XMI=1E+10 : XMA=-1E+10 : KX=0
1350 FOR I=1 TO NPG
1351 WHILE KX=0
1352 PRINT#3, : PRINT#3,TAB(3);" x"," f(x)"," p(x)"," F(x)","1-F(x)"
1353 KA=3 : KB=68 : GOSUB 695
1354 IL=4 : KX=1
1355 WEND
1356 IF KMT=0 THEN X=VC(I,1) : GOTO 1365
1360 IF A(I,0)=1 OR A(I,JZ)=XVF THEN FP=XVF : GOTO 1395 ELSE X=A(I,JZ)
1365 IF X<XMI THEN XMI=X
1370 IF X>XMA THEN XMA=X
1375 GOSUB 8060
1380 PRINT#3,TAB(3);X,FNR(FD,NDF),FNR(FP-FPA,NDF),FNR(FP,NDF),FNR(1-FP,NDF)
1385 FPA=FP
1390 IF KMT=0 THEN TI(I,0)=X : TI(I,1)=FD : TI(I,2)=FP
1395 IF KMT=1 AND JJ(1)>0 THEN A(I,JJ(1))=FP
1397 IL=IL+1 : IF IL>22 AND DS$="SCRN:" THEN INPUT "",A$ : KX=0
1400 NEXT I
1405 PRINT#3,
1410 PRINT#3," Probabilidad de Valores > ";XMA;" = ";FNR(1-FP,NDF)
1415 PRINT : GOSUB 650
1420 WEND
1425 '
1430 WHILE KMT=0
1435 GOSUB 555
1440 PRINT : PRINT "PROCESOS COMPLEMENTARIOS"
1445 TF$(1)="Graficacion de f(x) o p(x)"
1450 TF$(2)="Graficacion de F(x)"
1455 TF$(3)="Creacion de Archivo con Resultados"
1460 KL=3 : GOSUB 980
1465 IF ISP=0 THEN RETURN
1475 WHILE ISP=1 OR ISP=2
1477 XX=XMI : KM=0 : GOSUB 1579 : XMN(1)=XX
1478 XX=XMA : KM=1 : GOSUB 1579 : XMX(1)=XX
1480 DEL(1)=(XMX(1)-XMN(1))/5
1485 TG$(0)="x" : NG=1 : KA=1 : KX=1
1490 IF ISP=2 THEN 1525
1495 XMN(2)=0 : XX=0 : KB(1)=1
1500 FOR I=1 TO NPG
1505 IF TI(I,1)>XX THEN XX=TI(I,1)
1510 NEXT I
1515 KM=1 : GOSUB 1579 : XMX(2)=XX: DEL(2)=XMX(2)/5: JY(1)=1: TG$(1)="f(x)"
1520 GOTO 1530
1525 XMN(2)=0 : XMX(2)=1 : DEL(2)=.2 : JY(1)=2 : TG$(1)="F(x)" : KB(1)=0
1530 KTG=1 : GOSUB 6745 : NXX=0 : ISP=0
1535 WEND
1540 IF ISP=3 THEN KXX=0 : GOSUB 7930
1545 WEND
1547 RETURN
1550 '
1555 ' Presentacion Distribucion
1556 '
1557 PRINT#3,
1559 PRINT#3,"DISTRIBUCION = ";TFX$ : PRINT#3,
1560 FOR I=1 TO KP : PRINT#3," Parametro";I;"= ";P(I) : NEXT I
1561 PRINT#3,
1562 PRINT#3," Mu = ";FNR(XMU,NDF),"Sigma = ";FNR(SIG,NDF)
1564 IF KNV=1 THEN RETURN
1565 PRINT#3," Muy = ";FNR(XMUY,NDF),"Sigmay = ";FNR(SIGY,NDF), "Ro =
";FNR(RO,NDF)
1570 PRINT#3, : PRINT#3," Distribucion Condicional de x/y para y = ";Y
1575 PRINT#3," Mu Condic.= ";FNR(XMUC,NDF),"Sig Condic.= ";FNR(SIC,NDF)
1577 RETURN
1578 '
1579 IF XX=0 THEN RETURN
1580 XY=0 : KN=1
1581 IF XX<0 THEN XY=XX : XX=-XX : IF KM=0 THEN KM=1 ELSE KM=0
1582 WHILE XX<5
1583 KN=KN*5 : XX=XX*5
1584 WEND
1585 IF XX-5*INT(XX/5)=0 THEN XX=XX/KN : GOTO 1587
1586 XX=INT(XX/5+KM)*5/KN
1587 IF XY<0 THEN XX=-XX
1588 RETURN
1589 '
1590 ' EST312 - Calculo de x para F(x)
1595 '
1600 IF KMT=1 THEN NPG=NF : GOTO 1630
1605 GOSUB 555 : GOSUB 1555
1610 PRINT : PRINT "INGRESO VALORES DE F(x) (>0 y <1)"
1615 K=1 : KX=1 : GOSUB 6010
1620 IF NVC(1)=0 THEN RETURN
1625 NPG=NVC(1)
1630 KS=1
1635 WHILE KS=1
1640 GOSUB 555
1645 X=0 : IP=1 : GOSUB 8060
1650 GOSUB 1555
1655 KX=0
1665 FOR I=1 TO NPG
1666 WHILE KX=0
1667 PRINT#3, : PRINT#3,TAB(3);" F(x)"," x"
1668 KA=3 : KB=30 : GOSUB 695
1670 IL=4 : KX=1
1671 WEND
1672 IF KMT=0 THEN FPX=VC(I,1) : GOTO 1680
1675 IF A(I,0)=1 OR A(I,JZ)=XVF THEN X=XVF : GOTO 1705 ELSE FPX=A(I,JZ)
1680 PRINT#3,TAB(3);FNR(FPX,NDF),
1685 IF FPX<=0 OR FPX>=1 THEN KE=5: B$=">0 y <1": GOSUB 900 : KE=1 :
GOTO 1710
1690 GOSUB 7710
1695 PRINT#3,FNR(X,NDF)
1700 IF KMT=0 THEN TI(I,0)=FPX : TI(I,1)=X
1705 IF KMT=1 AND JJ(1)>0 THEN A(I,JJ(1))=X
1707 IL=IL+1 : IF IL>22 AND DS$="SCRN:" THEN INPUT "",A$ : KX=0
1710 NEXT I
1712 IF KE=1 THEN PRINT : INPUT "Proceso Interrumpido - Enter",A$ : RETURN
1715 PRINT : GOSUB 650
1720 WEND
1725 WHILE KMT=0
1730 PRINT : PRINT : INPUT "Creacion de Archivo de Resultados ? (N) = ",A$
1735 IF A$="S" OR A$="s" THEN KXX=1 : GOSUB 7930
1740 RETURN
1745 WEND
1750 '
1780 ' EST32 - Ajuste de Distribuciones
1785 ' --------------------------------
1790 WHILE KW=0
1795 TSP$="Ajuste de Distribuciones"
1800 GOSUB 555
1802 KTP=2 : GOSUB 7250
1805 IF TF=0 THEN RETURN
1810 PRINT : PRINT "DEFINICION DE VARIABLES PARA EL PROCESO (";KNV;")"
1815 GOSUB 200
1820 IF NV=0 THEN RETURN
1825 IF NV<>KNV THEN KE=2 : GOSUB 900 : GOTO 1810
1830 PRINT : PRINT "INGRESO VALORES DE CLASIFICACION"
1835 PRINT : PRINT " VARIABLE =";J;" - ";TC$(J)
1840 K=1 : KX=0 : GOSUB 6010
1845 IF NVC(1)=0 THEN RETURN
1847 IF NVC(1)<2 THEN KE=5 : B$="Nro.Valores Clasificacion >=2" : GOSUB 900 :
GOTO 1830
1850 PRINT: PRINT TAB(25);"EN PROCESO"
1855 '
1860 J=JX(1) : MX(1)=1 : NXX=0
1865 FOR M=0 TO NVC(1) : TI(M,1)=0 : NEXT M
1870 FOR I=1 TO NF
1875 IF A(I,0)=1 THEN 1925
1880 ND=1 : IF JF>0 THEN ND=A(I,JF) : IF ND=XVF THEN 1925
1885 X=A(I,J) : IF X=XVF THEN 1925
1890 L=NVC(1)
1895 FOR M=1 TO NVC(1)
1900 IF X<VC(M,1) THEN L=M-1 : MX(1)=0 : M=NVC(1)
1905 IF X=VC(M,1) THEN L=M : M=NVC(1)
1910 NEXT M
1915 TI(L,1)=TI(L,1)+ND
1920 NXX=NXX+ND
1925 NEXT I
1930 IF NXX<3 THEN KE=3 : KNM=3 : GOSUB 900 : RETURN
1935 IF KNV=1 THEN GOSUB 5480
1945 IF TF<>10 THEN 1985
1950 SXY=0 : NSX=0
1955 FOR I=1 TO NF-1
1960 IF A(I,0)=1 THEN 1975
1965 X=A(I,J) : Y=A(I+1,J) : IF X=XVF OR Y=XVF THEN 1975
1970 SXY=SXY+(X-PX)*(Y-PX) : NSX=NSX+1
1975 NEXT I
1980 IF DEX>0 THEN R=SXY/((NSX-1)*DEX*DEX) ELSE R=0
1985 IF KNV<>2 THEN 2005
1990 GOSUB 5825
1995 IF NXX<3 THEN KE=3 : KNM=3 : GOSUB 900 : RETURN
2000 IF DE(1)>0 AND DE(2)>0 THEN R=TI(1,2)/(DE(1)*DE(2)) ELSE R=0
2005 IP=2 : GOSUB 8060
2010 '
2015 KS=1
2020 WHILE KS=1
2025 GOSUB 555 : PRINT#3,
2030 PRINT#3," VARIABLE = ";J;" - ";TC$(J)
2035 PRINT#3," Valor Medio = ";FNR(PX,NDF)
2040 PRINT#3," Desvio Estandar = ";FNR(DEX,NDF)
2045 PRINT#3, : PRINT#3,"Distribucion = ";TF$(TF)
2050 FOR I=1 TO KP
2055 IF KF(I)=1 THEN B$=" (Estimado)" ELSE B$=" (Ingresado)"
2060 IF KF(I)=1 THEN P(I)=FNR(P(I),NDF)
2065 PRINT#3," Parametro";I;" = ";P(I);TAB(30);B$
2070 NEXT I
2075 IF DS$="SCRN:" THEN PRINT : INPUT "Enter ",A$
2080 '
2085 PRINT#3, : PRINT#3,"VERIFICACION BONDAD AJUSTE" : PRINT#3,
2090 CHI=0 : FPA=0 : IGL=-1 : IP=1
2095 PRINT#3,TAB(3);"Intervalo","Frec.Datos(A)","Frec.Teor.(B)","(A-B)^2/B"
2100 KA=3 : KB=58 : GOSUB 695
2103 IL=12 : KG=0
2105 FOR M=1 TO NVC(1)+1
2107 IF M=1 AND MX(1)=1 AND TI(0,1)=0 THEN 2160
2110 IF M<NVC(1)+1 THEN X=VC(M,1)-.00001 : GOSUB 8060 ELSE FP=1
2120 TIT=(FP-FPA)*NXX
2123 IF TIT<5 THEN KG=1
2125 TI(M-1,2)=TIT
2130 FPA=FP
2135 B$=">= " : IF M=1 THEN B$="< "
2140 IF MX(1)=1 THEN B$=" "
2145 IF TIT>0 THEN XA=(TI(M-1,1)-TIT)^2/TIT : IGL=IGL+1 ELSE XA=0
2150 CHI=CHI+XA
2155 PRINT#3,TAB(3);B$;VC(M-1,1),TI(M-1,1),FNR(TIT,NDD),FNR(XA,NDE)
2157 IL=IL+1 : IF IL=23 AND DS$="SCRN:" THEN IL=2 : INPUT "",A$
2160 NEXT M
2165 FOR I=1 TO KP : IGL=IGL-KF(I) : NEXT I
2170 PRINT#3, : PRINT#3," Estadistica Chi^2 = ";FNR(CHI,NDE)
2175 PRINT#3," Grados de Libertad de Chi^2 = ";IGL
2180 IF IGL<1 THEN PRINT#3," Grados de Libertad < 1" : GOTO 2210
2183 IF KG=1 THEN PRINT#3," ( Hay Frecuencias Teoricas < 5 )"
2185 XW=P(1) : XZ=P(2) : P(1)=IGL
2190 X=CHI : GOSUB 8704
2195 P(1)=XW : P(2)=XZ
2200 PRINT#3,
2205 PRINT#3," Nivel de Significacion de Chi^2 = ";FNR((1-FP)*100,2);" %"
2210 PRINT : GOSUB 650
2215 WEND
2220 '
2225 KZ=0 : KST=0
2230 WHILE KZ=0
2235 GOSUB 555
2240 PRINT : PRINT "PROCESOS COMPLEMENTARIOS"
2245 TF$(1)="Graficacion de Ajuste"
2250 TF$(2)="Creacion de Archivo con Resultados"
2255 KL=2 : GOSUB 980
2260 IF ISP=0 THEN KZ=1 : GOTO 2430
2263 IF KST=1 THEN 2325
2264 KST=1
2265 IF MX(1)=1 THEN FOR M=0 TO NVC(1) : TI(M,0)=VC(M,1) : NEXT M : NPG=NVC(1) : GOTO
2270 NPG=NVC(1)-1
2275 FOR M=1 TO NPG
2280 TI(M,0)=(VC(M,1)+VC(M+1,1))/2
2285 NEXT M
2290 IF TI(NVC(1),1)=0 THEN 2305
2295 NPG=NPG+1
2300 TI(NPG,0)=VC(NPG,1)+(VC(NPG-1,1)-VC(NPG-2,1))/2
2305 IF TI(0,1)=0 THEN 2325
2306 FOR M=NPG TO 1 STEP-1
2307 FOR K=0 TO 2
2308 TI(M+1,K)=TI(M,K)
2309 NEXT K,M
2313 NPG=NPG+1
2315 TI(1,0)=VC(1,1)-(VC(2,1)-VC(1,1))/2
2320 TI(1,1)=TI(0,1) : TI(1,2)=TI(0,2)
2325 WHILE ISP=1
2330 NG=2 : KX=1
2335 XMI=1E+10 : XMA=-1E+10
2340 XMN(2)=0 : XX=0
2345 FOR M=1 TO NPG
2350 IF TI(M,0)<XMI THEN XMI=TI(M,0)
2355 IF TI(M,0)>XMA THEN XMA=TI(M,0)
2360 IF TI(M,1)>XX THEN XX=TI(M,1)
2365 IF TI(M,2)>XX THEN XX=TI(M,2)
2370 NEXT M
2375 KM=1 : GOSUB 1579 : XMX(2)=XX
2380 XX=XMI : KM=0 : GOSUB 1579 : XMN(1)=XX
2381 XX=XMA : KM=1 : GOSUB 1579 : XMX(1)=XX
2385 FOR M=1 TO 2
2390 DEL(M)=(XMX(M)-XMN(M))/5
2395 NEXT M
2400 KA=1 : KB(1)=1 : KB(2)=0 : XXX=JX(1) :JY(1)=1 : JY(2)=2
2405 TG$(0)="x" : TG$(1)="Frec.Datos":TG$(2)="Frec.Distrib"
2410 KTG=1 : GOSUB 6745
2415 JX(1)=XXX : NXX=0 : ISP=0
2420 WEND
2425 IF ISP=2 THEN KXX=2 : GOSUB 7930
2430 WEND
2435 WEND
2440 '
2445 ' EST33 - Generacion de Valores Aleatorios
2450 ' ----------------------------------------
2452 WHILE KW=0
2455 TSP$="Generacion de Valores Aleatorios"
2460 GOSUB 555
2465 PRINT : PRINT "OBTENCION DE"
2470 TF$(1)="Valores Aleatorios de una Distribucion"
2475 TF$(2)="Estadisticas Descriptivas de Muestras de una Distrib."
2480 KL=2 : GOSUB 980
2485 IF ISP=0 THEN RETURN
2490 GOSUB 555
2491 KTP=3 : GOSUB 7250
2493 IF TF=0 THEN RETURN
2494 IP=1 : X=0 : GOSUB 8060
2495 PRINT : PRINT : GOSUB 1555
2500 IF ISP=1 THEN NM=1 : GOTO 2530
2505 PRINT : INPUT " Numero de Muestras a Generar = ",A$
2510 IF LEN(A$)=0 THEN RETURN
2515 NM=VAL(A$)
2520 IF NM<1 OR NM>NFM THEN KE=5 : B$=">=1 y <="+STR$(NFM) :
GOSUB 900 : GOTO 2505
2530 PRINT : PRINT "Nro. de Valores a Generar";
2535 IF NM>1 THEN PRINT " en cada muestra";
2540 INPUT " = ",A$
2545 IF LEN(A$)=0 THEN RETURN
2550 NXM=VAL(A$)
2555 KX=1 : IF NM>1 THEN KX=2
2560 IF NXM<KX THEN KE=5 : B$=">="+STR$(KX) : GOSUB 900 : GOTO 2530
2564 LI=INT(10000*RND)
2565 PRINT : PRINT "Definicion de Secuencia Nros.Aleatorios"
2570 PRINT " Entero >-32768 y <32767 (";LI; : INPUT ") = ",A$
2575 IF LEN(A$)=0 THEN 2590
2580 X=VAL(A$)
2585 IF X<=-32768! OR X>=32767 THEN KE=5 : B$=">-32768 y <32767" :
GOSUB 900 : GOTO 2510
2587 LI=X
2590 WHILE NM=1
2600 FOR K=1 TO KNV
2605 A$="X" : IF K=2 THEN A$="Y" : KVA=1
2606 PRINT : PRINT
2607 PRINT "ALMACENAMIENTO DE VALORES DE ";A$;" EN MEMORIA DE TRABAJO"
2615 GOSUB 390 : JJ(K)=J
2620 IF J>0 AND NXM>NFM THEN KE=6 : GOSUB 900 : RETURN
2625 NEXT K
2627 '
2630 KS=1
2635 WHILE KS=1
2640 X=RND(-LI)
2645 GOSUB 555 : GOSUB 1555
2650 PRINT#3,
2655 PRINT#3, : PRINT#3," Nro. Inicial de Secuencia = ";LI : PRINT#3,
2670 KXX=0
2675 FOR I=1 TO NXM
2676 WHILE KXX=0
2677 IF KNV=1 THEN PRINT#3," Nro."," X" : M=33
2678 IF KNV=2 THEN PRINT#3," Nro."," X"," Y" : M=46
2679 KA=3 : KB=M : GOSUB 695
2680 IL=3 : KXX=1
2681 WEND
2682 IP=3 : GOSUB 8060
2695 PRINT#3,TAB(3);I,FNR(X,NDF),
2700 IF KNV=2 THEN PRINT#3,FNR(Y,NDF) ELSE PRINT#3,
2705 IF JJ(1)>0 THEN A(I,JJ(1))=X
2710 IF KNV=2 AND JJ(2)>0 THEN A(I,JJ(2))=Y
2712 IL=IL+1
2713 IF IL>22 AND DS$="SCRN:" THEN INPUT "",A$ : KXX=0
2715 NEXT I
2720 IF JJ(1)>0 AND NF<NXM THEN NF=NXM : NX=NXM
2725 PRINT : GOSUB 650
2730 WEND
2735 NM=0
2740 WEND
2743 '
2745 WHILE NM>1
2750 FOR M=1 TO 5 : KF(M)=0 : JJ(M)=0 : TP(M)=0 : NEXT M
2755 KS=0
2760 WHILE KS=0
2763 GOSUB 555
2765 PRINT : PRINT "ESTADISTICAS A OBTENER PARA CADA MUESTRA"
2770 TF$(1)="Valor Medio" : TG$(1)="ValMed"
2775 TF$(2)="Desvio Estandar" : TG$(2)="DesvEst"
2780 TF$(3)="Estad. t" : TG$(3)="Est. t"
2785 TF$(4)="Estad. Chi2" : TG$(4)="Est.Chi2"
2790 TF$(5)="Estadist. definida por el usuario": TG$(5)="Est.Usu"
2795 KL=5 : GOSUB 980
2800 IF ISP=0 THEN KS=1 : GOTO 2815
2801 IF ISP=5 THEN PRINT : PRINT "Se Ingreso Rutina para Calculo"; : INPUT
" de Estadistica ? (N) = ",A$
2802 IF ISP=5 AND (A$<>"S" OR A$<>"s") THEN KS=1 : GOTO 2815
2803 PRINT : PRINT
2805 PRINT "Almacenamiento de Valores de Estadistica en Memoria de Trabajo"
2810 GOSUB 390 : JJ(ISP)=J : KF(ISP)=1
2815 WEND
2816 '
2817 WHILE KS=1
2818 X=RND(-LI)
2820 GOSUB 555
2821 PRINT#3,"ESTADISTICAS DE MUESTRAS ALEATORIAS" : PRINT#3,
2822 PRINT#3," Cantidad de Valores en cada Muestra = ",NXM : PRINT#3,
2823 PRINT#3," Nro. Inicial de Secuencia = ";LI : PRINT#3,
2824 GOSUB 1555
2825 PRINT#3, : IL=11+KP
2830 IP=1 : X=0 : GOSUB 8060
2835 PRINT#3,TAB(3);"Muestra"; : K=0
2840 FOR M=1 TO 5
2845 IF KF(M)>0 THEN K=K+1 : PRINT#3,TAB(12*K+3);TG$(M);
2850 NEXT M
2855 PRINT#3,
2860 KA=3 : KB=12*(K+1)+2 : GOSUB 695
2865 FOR KI=1 TO NM
2875 SX=0 : SCX=0
2880 FOR I=1 TO NXM
2885 IP=3 : GOSUB 8060
2890 SX=SX+X : SCX=SCX+X*X
2895 NEXT I
2900 PX=SX/NXM : DEX=SQR((SCX-SX*SX/NXM)/(NXM-1))
2905 IF KF(1)>0 THEN TP(1)=PX
2910 IF KF(2)>0 THEN TP(2)=DEX
2915 IF KF(3)>0 THEN TP(3)=(PX-XMU)*SQR(NXM)/DEX
2920 IF KF(4)>0 THEN TP(4)=(NXM-1)*(DEX/SIG)^2
2925 IF KF(5)>0 THEN GOSUB 3010 : TP(5)=Y
2930 FOR M=1 TO 5
2935 J=JJ(M) : IF J>0 THEN A(KI,J)=TP(M)
2937 IF J>0 AND KI>NF THEN NF=KI : NX=KI
2940 NEXT M
2945 PRINT#3,TAB(3);KI;
2950 K=0
2955 FOR M=1 TO 5
2960 IF KF(M)>0 THEN K=K+1 : PRINT#3,TAB(12*K+3);FNR(TP(M),NDF);
2965 NEXT M : PRINT#3,
2970 IL=IL+1
2975 IF IL>22 AND DS$="SCRN:" THEN IL=1 : INPUT"",A$
2980 NEXT KI
2985 PRINT : GOSUB 650
2987 WEND
2988 NM=0
2990 WEND
3000 WEND
3005 '
3010 ' EST331 - Rutina para obtener estadistica definida por el usuario
3015 ' ----------------------------------------------------------------
3020 LI(1,1)=0 : LI(2,1)=.5 : LI(3,1)=1 : LI(4,1)=1.5 : LI(5,1)=2
3025 TI(1,1)=0 : TI(2,1)=0 : TI(3,1)=0 : TI(4,1)=0 : TI(5,1)=0
3030 NI(1)=5 : Y=NI(1)
3035 FOR I=1 TO NXX
3040 FOR M=1 TO NI(1)
3045 IF VX(I)<LI(M,1) THEN Y=M-1 : M=NI(1)
3050 NEXT M
3055 TI(Y,1)=TI(Y,1)+1
3060 NEXT I
3065 FPA=0 : IP=1 : CHI=0
3070 FOR M=1 TO NI(1)+1
3075 IF M<NI(1)+1 THEN X=LI(M,1)-.0001 : GOSUB 8060 ELSE FP=1
3080 IF FP-FPA=0 THEN 3100
3085 TIT=(FP-FPA)*NXX
3090 FPA=FP
3095 CHI=CHI+(TI(M-1,1)-TIT)^2/TIT
3100 NEXT M
3105 Y=CHI
3110 RETURN
3115 '
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 '
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 '
6010 ' EST221 - Ingreso de Valores de Clasificacion
6015 ' --------------------------------------------
6017 IJ(1)=PAR1 : IJ(2)=PAR2
6020 IF NVC(K)=0 THEN 6045
6025 PRINT : PRINT " Valores Actuales" : PRINT TAB(4);
6030 FOR M=1 TO NVC(K) : PRINT VC(M,K);" - "; : NEXT M : PRINT
6035 PRINT : INPUT " Ingreso de Nuevos Valores ? (N) = ",A$
6040 IF A$<>"S" AND A$<>"s" THEN VC(0,K)=VC(1,K) : RETURN
6044 NVC(K)=0
6045 KW=0
6046 WHILE KW=0
6047 IF KX=1 THEN 6060
6050 GOSUB 5480
6055 PRINT " (Valores Maximo y Minimo de los Datos = ";XMI;"-";XMA;")"
6060 IF NVC(K)=0 THEN PRINT
6063 KE=0
6064 WHILE KE=0
6065 INPUT " Valor = ",A$
6070 IF LEN(A$)=0 THEN VC(0,K)=VC(1,K) : RETURN
6075 XB=VAL(A$)
6080 IF NVC(K)>0 AND XB<=X THEN KE=5 : B$=">="+STR$(X) :
GOSUB 900 : PRINT : GOTO 6065
6085 IF NVC(K)=0 THEN 6130
6090 INPUT " Incremento para obtener Valores intermedios (No) = ",A$
6091 PRINT
6093 IF LEN(A$)=0 THEN DI=0 : GOTO 6130
6095 DI=VAL(A$)
6100 IF DI<0 OR DI>XB-X THEN KE=5 : B$=">0 y <="+STR$(XB-X) :
GOSUB 900 : PRINT : GOTO 6090
6110 WHILE DI>0 AND X+DI<XB-.000001
6115 X=X+DI
6120 NVC(K)=NVC(K)+1
6121 IF NVC(K)>IJ(K)-1 THEN DI=0 : GOTO 6125
6122 VC(NVC(K),K)=X
6125 WEND
6130 NVC(K)=NVC(K)+1
6131 IF NVC(K)>IJ(K) THEN KE=5 : B$="Numero de Valores <= Parametro2 ("
+STR$(IJ(K))+")" : GOSUB 900 : KE=1 : NVC(K)=0 : GOTO 6133
6132 VC(NVC(K),K)=XB : X=XB
6133 WEND
6135 WEND
6136 '
6745 ' EST241 - Proceso de Graficacion
6750 ' -------------------------------
6755 DEF FNC(X)=60*(X-XMN(1))/(XMX(1)-XMN(1))
6760 DEF FNF(X)=20*(X-XMN(2))/(XMX(2)-XMN(2))
6765 CLS
6770 X=21-FNF(0) : KC=0
6775 IF X>0 AND X<21 THEN KC=1
6780 FOR I=1 TO 60
6785 IF KC=1 THEN LOCATE X,I+20 : PRINT "."
6790 LOCATE 1,I+20 : PRINT "-"
6795 LOCATE 21,I+20 : PRINT "-"
6800 NEXT I
6805 FOR X=XMN(1) TO XMX(1) STEP DEL(1)
6810 XC=FNC(X)
6815 LOCATE 1,XC+20 : PRINT "+"
6820 LOCATE 21,XC+20 : PRINT "+"
6825 IF X<XMX(1) THEN LOCATE 22,XC+18 : PRINT FNR(X,2)
6830 NEXT X
6835 LOCATE 23,70 : PRINT TG$(0)
6840 X=FNC(0)+20 : KC=0
6845 IF X>20 AND X<80 THEN KC=1
6850 FOR I=1 TO 20
6855 IF KC=1 THEN LOCATE I,X : PRINT "."
6860 LOCATE I,20 : PRINT CHR$(124)
6865 LOCATE I,80 : PRINT CHR$(124)
6870 NEXT I
6875 FOR X=XMN(2) TO XMX(2) STEP DEL(2)
6880 XF=21-FNF(X)
6885 LOCATE XF,20 : PRINT "+"
6890 LOCATE XF,80 : PRINT "+"
6895 LOCATE XF,13 : PRINT FNR(X,2)
6900 NEXT X
6905 TF$(1)="*" : TF$(2)="+" : TF$(3)="x"
6910 IF KTG=2 THEN C$="ABCDEFGHIJKLMNOPQRTSUVWXYZ"
6915 FOR J=1 TO NG
6920 LOCATE 3+3*J,1 : IF ISP=1 THEN PRINT TF$(J)
6925 PRINT TG$(J)
6930 NEXT J
6935 IF KTG=2 THEN PRINT : PRINT : PRINT "Var.Codif=" : PRINT JV;" - ";TC$(JV)
6940 NXX=0
6945 FOR I=1 TO NPG
6950 IF KA=0 THEN IF A(I,0)=1 THEN 7105
6955 IF KX=0 THEN X=I : GOTO 6975
6960 IF KA=0 THEN X=A(I,KX)
6965 IF KA=0 AND X=XVF THEN 7105
6970 IF KA=1 THEN X=TI(I,0)
6975 XC=FNC(X)+20
6980 IF XC<20 OR XC>80 THEN 7100
6985 FOR J=1 TO NG
6990 IF KA=0 THEN Y=A(I,JY(J))
6995 IF KA=0 AND Y=XVF THEN 7105
7000 IF KA=1 THEN Y=TI(I,JY(J))
7005 YF=21-FNF(Y)
7010 IF YF<1 OR YF>21 THEN 7090
7015 FOR XF=YF TO 21
7020 LOCATE XF,XC
7025 A$=TF$(J)
7030 IF KTG=1 THEN 7075
7035 IF JV>0 THEN X=A(I,JV)
7040 IF JV>0 AND X=XVF THEN XF=21 : GOTO 7085
7045 IF JV>0 THEN X=INT(X)
7050 IF JV=0 THEN X=I
7055 IF X<0 THEN A$="-"
7060 IF X>=0 AND X<10 THEN A$=STR$(X)
7065 IF X>=10 AND X<35 THEN A$=MID$(C$,X-9,1)
7070 IF X>35 THEN A$="+"
7075 PRINT A$
7080 IF KB(J)=0 THEN XF=21
7085 NEXT XF
7090 NEXT J
7095 NXX=NXX+1
7100 LOCATE 23,1
7105 NEXT I
7107 IF KB(1)=0 AND KA=0 THEN LOCATE 2 : PRINT "Nro.Observ." : PRINT "
Tot. :";NF : PRINT " Graf.:";NXX
7110 LOCATE 24 : INPUT "Enter ",A$
7115 RETURN
7120 '
7250 ' EST30 - Seleccion de Distribucion
7255 ' ---------------------------------
7257 TF=0
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";
7398 INPUT " = ",A$
7399 IF LEN(A$)=0 THEN RETURN
7400 TF=INT(VAL(A$))
7410 IF TF<1 OR TF>15 THEN PRINT CHR$(7) : GOTO 7395
7412 IF KTP=4 AND (TF=10 OR TF=11) THEN PRINT CHR$(7) : GOTO 7395
7415 TFX$=TF$(TF)
7420 KNV=1 : IF TF=11 THEN KNV=2
7425 KDI=0 : IF TF>=12 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 KTP=2 THEN B$="A Estimar"
7525 PRINT " Valor (";B$;")";TAB(25); : INPUT " = ",A$
7530 IF LEN(A$)=0 AND KTP=2 THEN KF(K)=1 : GOTO 7610
7535 IF LEN(A$)=0 AND KTP<>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=5
7575 IF KM=2 AND X<>INT(X) THEN KE=5
7580 IF KM=3 AND X>=1 THEN KE=5
7585 IF KM=4 AND X<=P(1) THEN KE=5
7590 IF KM=5 AND (X<=-1 OR X>=1) THEN KE=5
7595 NEXT M
7600 IF KE=5 THEN B$=TG$(KM) : GOSUB 900 : PRINT : GOTO 7520
7605 P(K)=X
7610 NEXT K
7615 '
7620 WHILE TF=12 AND KTP=3
7625 P(3)=0 : P(4)=0
7630 PRINT : INPUT " Generacion sin Reposicion ? (N) = ",A$
7635 IF A$="S" OR A$="s" THEN P(3)=1
7640 RETURN
7645 WEND
7650 WHILE TF=11 AND (KTP=1 OR KTP=2)
7655 PRINT : INPUT " Valor de la Variable Y = ",A$
7660 Y=VAL(A$)
7665 RETURN
7670 WEND
7675 WHILE TF=4 AND KTP=2 AND KF(1)=1
7680 PRINT : INPUT " Parametro Alfa Entero ? (N) = ",A$
7685 P(3)=0 : IF A$="S" OR A$="s" THEN P(3)=1
7690 RETURN
7695 WEND
7700 RETURN
7705 '
7710 ' EST320 - Calculo del valor x para F(x)
7715 '
7725 IP=1 : X=0 : 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 KM=0
7755 WHILE KM=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 : KM=1
7780 IF DI>0 AND FP>0 THEN XD=XY : XE=X : FPD=FPY : FPE=FP : KM=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 '
7930 ' EST313 - creacion de Archivos de Resultados
7935 '
7940 GOSUB 555
7945 XA$=".EST"
7950 PRINT: PRINT "Nombre del Archivo a Grabar (";DDA$;":---";XA$; : INPUT ") =
7955 IF LEN(A$)=0 THEN RETURN
7960 KE=0
7965 GOSUB 950
7966 XNA$=A$
7967 IF KAR=0 THEN PRINT : INPUT "Archivo Existente - Se Reemplaza ? (N) = ",A$
7968 IF KAR=0 AND (A$<>"S" AND A$<>"s") THEN 7950
7970 IF KE=1 THEN 7950
7975 OPEN XDDA$+XNA$+EXT$ FOR OUTPUT AS #1
7980 B$="" : FOR K=1 TO KP : B$=B$+STR$(P(K))+" " : NEXT K
7985 IF KXX=2 THEN PRINT#1,"Ajuste ";
7990 PRINT#1,"Distribucion "+TFX$+" - Parametros = "+B$
7993 N=3 : IF KXX=1 THEN N=2
7995 PRINT#1,NPG,N
8000 IF KXX=1 THEN PRINT#1,"F(x)"
8005 PRINT#1,"Valor x"
8010 IF KXX=0 THEN PRINT#1,"f/p(x)" : PRINT#1,"F(x)"
8015 IF KXX=2 THEN PRINT#1,"FrecExpe" : PRINT#1,"FrecTeor"
8020 FOR I=1 TO NPG
8025 PRINT#1,FNR(TI(I,0),NDF);FNR(TI(I,1),NDF);
8030 IF KXX<>1 THEN PRINT#1,FNR(TI(I,2),NDF) ELSE PRINT#1,
8035 NEXT I
8040 CLOSE#1
8045 PRINT : INPUT "Grabacion Terminada - Enter para continuar",A$
8050 RETURN
8055 '
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)
8092 ON IP GOTO 8096,8116,8128
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
8116 IF KF(1)=1 THEN P(1)=PX-1.732051*DEX
8120 IF KF(2)=1 THEN P(2)=PX+1.732051*DEX
8122 IF P(2)<=P(1) THEN P(2)=P(1)+.0001
8124 RETURN
8128 X=A+(B-A)*RND
8132 RETURN
8136 '
8140 ' EST302 - Dist.Normal
8144 '
8148 XMU=P(1) : SIG=P(2)
8152 ON IP GOTO 8156,8196,8208
8156 U=(X-XMU)/SIG
8164 FD=.39894228#*EXP(-U*U/2)
8168 C=1/(1+.2316419*ABS(U))
8172 FP=FD*C*(.3193815+C*(-.3565638+C*(1.781478+C*(-1.821256+1.330274*C))))
8176 IF U>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
8196 IF KF(1)=1 THEN P(1)=PX
8200 IF KF(2)=1 THEN P(2)=DEX
8201 IF P(2)=0 THEN P(2)=.0001
8204 RETURN
8208 X=SIG*SQR(-2*LOG(RND))*COS(6.283185*RND)+XMU
8212 RETURN
8216 '
8220 ' EST303 - Dist.Exponencial
8224 '
8228 XMU=P(1)
8232 ON IP GOTO 8236,8256,8268
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
8256 IF KF(1)=1 THEN P(1)=PX
8260 IF P(1)<=0 THEN P(1)=.001
8264 RETURN
8268 X=-XMU*LOG(RND)
8272 RETURN
8276 '
8280 ' EST304 - Dist.Gamma
8284 '
8288 AL=P(1) : BE=P(2)
8292 ON IP GOTO 8296,8348,8376
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)
8337 IF FP>1 THEN FP=1
8338 IF FP<0 THEN FP=0
8340 X=XGA
8344 RETURN
8348 IF KF(1)=1 THEN P(1)=(PX/DEX)^2
8352 IF P(1)=0 THEN P(1)=.001
8356 IF KF(1)=1 AND P(3)=1 THEN P(1)=INT(P(1)+.5)
8360 IF P(3)=1 AND P(1)=0 THEN P(1)=1
8364 IF KF(2)=1 THEN P(2)=DEX^2/PX
8368 IF P(2)<=0 THEN P(2)=.001
8372 RETURN
8376 WHILE AL<1
8380 CA=1+AL/2.718282
8384 UA=RND : UB=RND
8388 CB=CA*UA
8392 IF CB>0 THEN 8404
8396 X=CB^(1/AL)
8400 IF UB<=EXP(-X) THEN X=BE*X : RETURN ELSE 8384
8404 X=-LOG((CA-CB)/AL)
8408 IF UB<X^(AL-1) THEN X=BE*X : RETURN ELSE 8384
8412 WEND
8416 IF AL=1 THEN X=-AL*BE*LOG(RND) : RETURN
8420 WHILE AL>1
8422 CS=(2*AL-1)^.5 : CT=AL-1.386294 : CU=AL+1/AL
8424 UA=RND : UB=RND
8428 CA=CS*LOG(UA/(1-UA))
8432 X=AL*EXP(CA)
8436 CB=UA*UA*UB
8440 CC=CT+CU*CA-X
8444 IF CC+2.504077-4.5*CB>=0 THEN X=BE*X : RETURN
8448 IF CC>=LOG(CB) THEN X=BE*X : RETURN
8452 GOTO 8424
8456 WEND
8460 '
8464 ' EST305 - Dist.Beta
8468 '
8472 AL=P(1) : BE=P(2)
8476 ON IP GOTO 8480,8584,8604
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
8584 IF KF(1)=1 THEN P(1)=PX*(PX-PX*PX-DEX*DEX)/(DEX*DEX)
8588 IF P(1)<=0 THEN P(1)=.001
8592 IF KF(2)=1 THEN P(2)=P(1)*(1/PX-1)
8596 IF P(2)<=0 THEN P(2)=.001
8600 RETURN
8604 CM=P(1) : CN=P(2)
8608 P(2)=1 : GOSUB 8280
8612 XX=X
8616 P(1)=CN : GOSUB 8280
8620 X=XX/(XX+X)
8624 P(1)=CM : P(2)=CN
8628 RETURN
8632 '
8636 ' EST306 - Dist.Log-normal
8640 '
8644 ON IP GOTO 8648,8676,8692
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
8676 XA=PX : IF PX<=0 THEN XA=.001
8680 IF KF(1)=1 THEN P(1)=.5*LOG(XA^2/((DEX/XA)^2+1))
8684 IF KF(2)=1 THEN P(2)=SQR(LOG((DEX/XA)^2+1))
8688 RETURN
8692 GOSUB 8140 : X=EXP(X)
8696 RETURN
8700 '
8704 ' EST307 - Dist.Chi^2
8708 '
8712 K=P(1)
8716 ON IP GOTO 8720,8768,8780
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 : P(2)=0
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
8768 IF KF(1)=1 THEN P(1)=INT(PX+.5)
8772 IF P(1)<1 THEN P(1)=1
8776 RETURN
8780 P(1)=K/2 : P(2)=2
8784 GOSUB 8280
8788 P(1)=K : P(2)=0
8792 RETURN
8796 '
8800 ' EST308 - Distribucion t
8804 K=P(1)
8808 ON IP GOTO 8812,8896,8908
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
8896 IF KF(1)=1 THEN P(1)=INT(2*DEX^2/(DEX^2-1)+.5)
8900 IF KF(1)=1 AND P(1)<3 THEN P(1)=3
8904 RETURN
8908 P(1)=0 : P(2)=1 : GOSUB 8140
8912 U=X : P(1)=K : P(2)=0
8916 GOSUB 8704
8920 X=U/SQR(X/K)
8924 RETURN
8928 '
8932 ' EST309 - Dist. F
8936 '
8940 KM=P(1) : KN=P(2)
8944 ON IP GOTO 8948,9008,9040
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
9008 XA=PX : IF XA=1 THEN XA=1.001
9012 N=2*XA/(XA-1)
9016 IF KF(1)=1 THEN P(2)=INT(N+.5)
9020 IF KF(1)=1 AND P(2)<5 THEN P(2)=5
9024 IF KF(2)=0 THEN 9032
9028 P(1)=INT((2*P(2)-4)/(DEX^2*(P(2)-2)^2*(P(2)-4)/P(2)^2-2)+.5)
9032 IF KF(2)=1 AND P(1)<1 THEN P(1)=1
9036 RETURN
9040 GOSUB 8704
9044 XX=X : P(1)=KN
9048 GOSUB 8704
9052 X=XX*KN/(X*KM)
9056 P(1)=KM : P(2)=KN
9060 RETURN
9064 '
9068 ' EST310 - Dist.Normal Autocorr.
9072 '
9076 ON IP GOTO 9080,9088,9104
9080 GOSUB 8140
9084 RETURN
9088 IF KF(1)=1 THEN P(1)=PX
9092 IF KF(2)=1 THEN P(2)=DEX
9096 IF KF(3)=1 THEN P(3)=R
9100 RETURN
9104 L=INT(20*P(3))
9108 K=20-L : X=0
9112 FOR M=1 TO L
9116 IF VY(M+K)=0 THEN VY(M+K)=RND
9120 VY(M)=VY(M+K) : X=X+VY(M)
9124 NEXT M
9128 FOR M=L+1 TO 20
9132 VY(M)=RND : X=X+VY(M)
9136 NEXT M
9140 X=P(2)*(X-10)/1.291+P(1)
9144 RETURN
9148 '
9152 ' EST311 - Dist.Normal Bidimensional
9156 '
9160 XMUX=P(1) : SIGX=P(2)
9162 XMUY=P(3) : SIGY=P(4) : RO=P(5)
9164 ON IP GOTO 9168,9196,9220
9168 XMUC=XMUX+RO*(SIGX/SIGY)*(Y-XMUY)
9172 SIC=SIGX*SQR(1-RO^2)
9176 P(1)=XMUC : P(2)=SIC
9180 GOSUB 8140
9184 P(1)=XMUX: P(2)=SIGX
9188 XMU=XMUX : SIG=SIGX
9192 RETURN
9196 IF KF(1)=1 THEN P(1)=PM(1)
9200 IF KF(2)=1 THEN P(2)=DE(1)
9204 IF KF(3)=1 THEN P(3)=PM(2)
9208 IF KF(4)=1 THEN P(4)=DE(2)
9212 IF KF(5)=1 THEN P(5)=R
9216 RETURN
9220 P(1)=XMUY : P(2)=SIGY
9224 GOSUB 8140 : Y=X
9228 P(1)=XMUX+RO*(SIGX/SIGY)*(X-XMUY)
9232 P(2)=SIGX*SQR(1-RO^2)
9236 GOSUB 8140
9240 P(1)=XMUX : P(2)=SIGX
9244 RETURN
9248 '
9252 ' EST312 - Dist.Uniforme Discreta
9256 '
9260 A=P(1) : B=P(2)
9264 ON IP GOTO 9268,9296,9308
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
9296 IF KF(1)=1 THEN P(1)=INT(XMI+.5)
9300 IF KF(2)=1 THEN P(2)=INT(XMA+.5)
9304 RETURN
9308 WHILE P(3)=0
9312 X=INT((B-A+1)*RND+A)
9316 RETURN
9320 WEND
9324 WHILE P(3)=1
9328 K=P(4)
9332 IF K=0 THEN K=B-A+1 : FOR M=1 TO K : VY(M)=A+M-1 : NEXT M
9336 M=INT(K*RND+1)
9340 X=VY(M) : IF M<K THEN VY(M)=VY(K)
9344 K=K-1 : P(4)=K
9348 RETURN
9352 WEND
9356 '
9360 ' EST313 - Dist.Binomial
9364 '
9368 N=P(1) : PR=P(2)
9372 ON IP GOTO 9376,9484,9504
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
9484 IF KF(1)=1 THEN P(1)=INT(PX^2/(PX-DEX^2)+.5)
9488 IF P(1)<1 THEN P(1)=1
9492 IF KF(2)=1 THEN P(2)=(PX-DEX^2)/PX
9496 IF P(2)<=0 THEN P(2)=.001
9500 RETURN
9504 MK=0
9508 IF (PR<=.5 AND MU>5) OR (PR>.5 AND N*(1-PR)>5) OR N>30 THEN MK=1
9512 WHILE MK=0
9516 X=0
9520 FOR K=1 TO N
9524 IF RND<=PR THEN X=X+1
9528 NEXT K
9532 RETURN
9536 WEND
9540 WHILE MK=1
9544 P(1)=N*PR : P(2)=SQR(N*PR*(1-PR))
9548 GOSUB 8140
9552 X=INT(X+.5) : P(1)=N : P(2)=PR
9556 RETURN
9560 WEND
9564 '
9568 ' EST314 - Dist.Binomial negativa
9572 '
9576 R=P(1) : PR=P(2)
9580 ON IP GOTO 9584,9632,9656
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
9632 IF KF(1)=1 THEN P(1)=INT(PX^2/(DEX^2-PX)+.5)
9636 IF P(1)<1 THEN P(1)=1
9640 IF KF(2)=1 THEN P(2)=PX/DEX^2
9644 IF P(2)<=0 THEN P(2)=.001
9648 IF P(2)>=1 THEN P(2)=.999
9652 RETURN
9656 X=0 : Y=0
9660 WHILE Y<R
9664 IF RND<=PR THEN Y=Y+1 ELSE X=X+1
9668 WEND
9672 RETURN
9676 '
9680 ' EST315 - Dist.Poisson
9684 '
9688 XMU=P(1)
9692 ON IP GOTO 9700,9788,9800
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
9788 IF KF(1)=1 THEN P(1)=PX
9792 IF P(1)<=0 THEN P(1)=.001
9796 RETURN
9800 MK=0 : IF XMU>10 THEN MK=1
9804 WHILE MK=0
9808 CA=EXP(-XMU) : X=-1 : XR=1
9812 WHILE CA<=XR
9816 XR=XR*RND : X=X+1
9820 WEND
9824 RETURN
9828 WEND
9832 WHILE MK=1
9836 P(2)=SQR(XMU)
9840 GOSUB 8140
9844 X=INT(X+.5)
9846 IF X<0 THEN X=0
9848 RETURN
9852 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
9936 ' Calculo de F(x) por integracion de f(x)
9940 '
9944 PRINT : INPUT " x = ",XZ
9948 NIN=10 : FPA=0 : DIF=1
9952 WHILE DIF>.0001
9956 FPZ=0 : DX=XZ/NIN
9960 FOR Z=0 TO NIN
9964 X=Z*XZ/NIN
9968 IP=1 : GOSUB 8060
9972 IF Z>0 THEN FPZ=FPZ+(FD+FDI)*DX/2
9976 FDI=FD
9980 NEXT Z
9984 PRINT FPZ
9988 DIF=ABS((FPZ-FPA)) : NIN=2*NIN : FPA=FPZ
9992 WEND
9996 PRINT "f(x) = ";FD,"F(x) = ";FPZ : INPUT "",A$
9998 RETURN
9999 '
10000 RETURN
10004 '